Skip to content

Commit 3251689

Browse files
committed
Try to fix name mangling issues with GCC and static call operators
1 parent 3e3edea commit 3251689

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ if(SQLITE_ORM_OMITS_CODECVT)
5555
target_compile_definitions(unit_tests PRIVATE SQLITE_ORM_OMITS_CODECVT=1)
5656
endif()
5757

58-
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
59-
# GCC would complain about name mangling errors (with type traits for locally defined lambdas) if the ABI version is not set to 0
60-
add_compile_options(-fabi-version=0)
61-
elseif(MSVC)
58+
if(MSVC)
6259
target_compile_options(unit_tests PUBLIC
6360
# multi-processor compilation
6461
/MP

tests/static_tests/function_static_tests.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,29 +315,30 @@ TEST_CASE("function static") {
315315
}
316316
#endif
317317
};
318+
#ifdef SQLITE_ORM_STATIC_CALL_OPERATOR_SUPPORTED
319+
constexpr auto lambda_static = [](unsigned long errcode) static {
320+
return errcode != 0;
321+
};
322+
#endif
318323

319324
SECTION("detect overloaded call operator") {
320-
constexpr auto lambda = [](unsigned long errcode) {
321-
return errcode != 0;
322-
};
325+
constexpr auto lambda = [](unsigned long) {};
323326
using lambda_type = std::remove_const_t<decltype(lambda)>;
324327

325328
STATIC_REQUIRE(
326-
polyfill::is_detected_v<internal::overloaded_callop_t, bool(unsigned long) const, lambda_type>);
329+
polyfill::is_detected_v<internal::overloaded_callop_t, void(unsigned long) const, lambda_type>);
327330
STATIC_REQUIRE_FALSE(
328-
polyfill::is_detected_v<internal::overloaded_static_callop_t, bool(unsigned long) const, lambda_type>);
331+
polyfill::is_detected_v<internal::overloaded_static_callop_t, void(unsigned long) const, lambda_type>);
329332
}
330333
#ifdef SQLITE_ORM_STATIC_CALL_OPERATOR_SUPPORTED
331334
SECTION("detect overloaded static call operator") {
332-
constexpr auto lambda = [](unsigned long errcode) static {
333-
return errcode != 0;
334-
};
335-
using lambda_type = std::remove_const_t<decltype(lambda)>;
335+
constexpr auto lambda_static = [](unsigned long) static {};
336+
using lambda_type = std::remove_const_t<decltype(lambda_static)>;
336337

337338
STATIC_REQUIRE_FALSE(
338-
polyfill::is_detected_v<internal::overloaded_callop_t, bool(unsigned long), lambda_type>);
339+
polyfill::is_detected_v<internal::overloaded_callop_t, void(unsigned long), lambda_type>);
339340
STATIC_REQUIRE(
340-
polyfill::is_detected_v<internal::overloaded_static_callop_t, bool(unsigned long), lambda_type>);
341+
polyfill::is_detected_v<internal::overloaded_static_callop_t, void(unsigned long), lambda_type>);
341342
}
342343
#endif
343344
SECTION("freestanding function") {
@@ -424,11 +425,11 @@ TEST_CASE("function static") {
424425
}
425426
#ifdef SQLITE_ORM_STATIC_CALL_OPERATOR_SUPPORTED
426427
SECTION("static lambda") {
427-
constexpr auto lambda = [](unsigned long errcode) static {
428+
constexpr auto lambda_static = [](unsigned long errcode) static {
428429
return errcode != 0;
429430
};
430-
using lambda_type = std::remove_const_t<decltype(lambda)>;
431-
constexpr auto quotedScalar = "f"_scalar.quote(lambda);
431+
using lambda_type = std::remove_const_t<decltype(lambda_static)>;
432+
constexpr auto quotedScalar = "f"_scalar.quote(lambda_static);
432433
using quoted_type = std::remove_const_t<decltype(quotedScalar)>;
433434

434435
STATIC_REQUIRE(quotedScalar._nme[0] == 'f' && quotedScalar._nme[1] == '\0');

0 commit comments

Comments
 (0)