1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:27:45 +00:00

Everywhere: Make Lagom build with GCC 13

GCC 13 was released on 2023-04-26. This commit fixes Lagom build errors
when using an updated host toolchain:
- Adds a workaround for a bug in constraint handling, which made LibJS
  fail to compile: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
- Silences the new `-Wdangling-reference` diagnostic globally. It
  produces multiple false positives with no clear way to silence them
  without `#pragmas`.
- Silences `-Wself-move` in `RefPtr` tests as GCC 13 adds this
  previously Clang-exclusive warning.
This commit is contained in:
Daniel Bertalan 2023-05-01 16:59:46 +02:00 committed by Tim Flynn
parent 1422f7f904
commit 00b4976f2c
3 changed files with 10 additions and 9 deletions

View file

@ -130,15 +130,16 @@ struct VariantConstructTag {
template<typename T, typename Base> template<typename T, typename Base>
struct VariantConstructors { struct VariantConstructors {
// The pointless `typename Base` constraints are a workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
ALWAYS_INLINE VariantConstructors(T&& t) ALWAYS_INLINE VariantConstructors(T&& t)
requires(requires { T(move(t)); }) requires(requires { T(move(t)); typename Base; })
{ {
internal_cast().clear_without_destruction(); internal_cast().clear_without_destruction();
internal_cast().set(move(t), VariantNoClearTag {}); internal_cast().set(move(t), VariantNoClearTag {});
} }
ALWAYS_INLINE VariantConstructors(T const& t) ALWAYS_INLINE VariantConstructors(T const& t)
requires(requires { T(t); }) requires(requires { T(t); typename Base; })
{ {
internal_cast().clear_without_destruction(); internal_cast().clear_without_destruction();
internal_cast().set(t, VariantNoClearTag {}); internal_cast().set(t, VariantNoClearTag {});

View file

@ -28,4 +28,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Only ignore expansion-to-defined for g++, clang's implementation doesn't complain about function-like macros # Only ignore expansion-to-defined for g++, clang's implementation doesn't complain about function-like macros
add_compile_options(-Wno-expansion-to-defined) add_compile_options(-Wno-expansion-to-defined)
add_compile_options(-Wno-literal-suffix) add_compile_options(-Wno-literal-suffix)
# FIXME: This warning seems useful but has too many false positives with GCC 13.
add_compile_options(-Wno-dangling-reference)
endif() endif()

View file

@ -97,14 +97,11 @@ TEST_CASE(assign_moved_self)
{ {
RefPtr<Object> object = adopt_ref(*new Object); RefPtr<Object> object = adopt_ref(*new Object);
EXPECT_EQ(object->ref_count(), 1u); EXPECT_EQ(object->ref_count(), 1u);
#if defined(AK_COMPILER_CLANG) #pragma GCC diagnostic push
# pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wpragmas"
# pragma clang diagnostic ignored "-Wself-move" #pragma GCC diagnostic ignored "-Wself-move"
#endif
object = move(object); object = move(object);
#if defined(AK_COMPILER_CLANG) #pragma GCC diagnostic pop
# pragma clang diagnostic pop
#endif
EXPECT_EQ(object->ref_count(), 1u); EXPECT_EQ(object->ref_count(), 1u);
} }