From 7ecf6a71b0c875880db49deba52d447ce262c054 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 May 2018 07:09:43 +0100 Subject: [PATCH] test-suite support for gcc-8 targeting C++11 and C++14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some code in this test case is actually only supported in c++17... cpp11_lambda_functions_wrap.cxx:275:87: error: the type ‘const’ of ‘constexpr’ variable ‘lambda18’ is not literal CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; ^ cpp11_lambda_functions_wrap.cxx:275:28: note: ‘’ is not literal because: CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; ^ cc1plus: note: ‘’ is a closure type, which is only literal in C++17 and later cpp11_lambda_functions_wrap.cxx:278:89: error: the type ‘const Space1::’ of ‘constexpr’ variable ‘Space1::lambda19’ is not literal CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; --- Examples/test-suite/cpp11_lambda_functions.i | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i index c50839913..eb368a626 100644 --- a/Examples/test-suite/cpp11_lambda_functions.i +++ b/Examples/test-suite/cpp11_lambda_functions.i @@ -67,12 +67,17 @@ auto lambda14 = [] () TESTCASE_THROW() {}; auto lambda15 = [] () mutable TESTCASE_THROW() {}; auto lambda16 = [] { return thing; }; auto lambda17 = [] { return thing; }(); -constexpr auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; +#if defined(SWIG) || (defined(__cplusplus) && __cplusplus >= 201703L) +#define CONSTEXPR constexpr +#else +#define CONSTEXPR +#endif +CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space1 { - constexpr auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space2 { - constexpr auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; } }