Skip to content

Commit 00b4976

Browse files
BertalanDtrflynn89
authored andcommitted
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.
1 parent 1422f7f commit 00b4976

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

AK/Variant.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,16 @@ struct VariantConstructTag {
130130

131131
template<typename T, typename Base>
132132
struct VariantConstructors {
133+
// The pointless `typename Base` constraints are a workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109683
133134
ALWAYS_INLINE VariantConstructors(T&& t)
134-
requires(requires { T(move(t)); })
135+
requires(requires { T(move(t)); typename Base; })
135136
{
136137
internal_cast().clear_without_destruction();
137138
internal_cast().set(move(t), VariantNoClearTag {});
138139
}
139140

140141
ALWAYS_INLINE VariantConstructors(T const& t)
141-
requires(requires { T(t); })
142+
requires(requires { T(t); typename Base; })
142143
{
143144
internal_cast().clear_without_destruction();
144145
internal_cast().set(t, VariantNoClearTag {});

Meta/CMake/common_compile_options.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2828
# Only ignore expansion-to-defined for g++, clang's implementation doesn't complain about function-like macros
2929
add_compile_options(-Wno-expansion-to-defined)
3030
add_compile_options(-Wno-literal-suffix)
31+
32+
# FIXME: This warning seems useful but has too many false positives with GCC 13.
33+
add_compile_options(-Wno-dangling-reference)
3134
endif()

Tests/AK/TestRefPtr.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,11 @@ TEST_CASE(assign_moved_self)
9797
{
9898
RefPtr<Object> object = adopt_ref(*new Object);
9999
EXPECT_EQ(object->ref_count(), 1u);
100-
#if defined(AK_COMPILER_CLANG)
101-
# pragma clang diagnostic push
102-
# pragma clang diagnostic ignored "-Wself-move"
103-
#endif
100+
#pragma GCC diagnostic push
101+
#pragma GCC diagnostic ignored "-Wpragmas"
102+
#pragma GCC diagnostic ignored "-Wself-move"
104103
object = move(object);
105-
#if defined(AK_COMPILER_CLANG)
106-
# pragma clang diagnostic pop
107-
#endif
104+
#pragma GCC diagnostic pop
108105
EXPECT_EQ(object->ref_count(), 1u);
109106
}
110107

0 commit comments

Comments
 (0)