The COW std::string is not constexpr, so the <stdexcept> exception
classes can't be constexpr either when they're defined in terms of the
COW string.
While constexpr exceptions for <typeinfo>, <new>, and <exception>
classes would work, __cpp_constexpr_exceptions >= 202411L implies that
everything including <stdexcept> should work. So when we can't support
it fully, we shouldn't announce it.
libstdc++-v3/ChangeLog:
* include/bits/version.def (constexpr_exceptions): Add
cxx11abi=yes.
* include/bits/version.h: Regenerate.
* testsuite/18_support/exception/version.cc: Require effectiove
target cxx11_abi.
* testsuite/18_support/exception_ptr/exception_ptr_cast.cc: Only
check for constexpr support in cxx11 ABI.
* testsuite/19_diagnostics/headers/stdexcept/version.cc: Require
effective target cxx11_abi.
* testsuite/19_diagnostics/logic_error/constexpr.cc: Likewise.
* testsuite/19_diagnostics/runtime_error/constexpr.cc: Likewise.
* testsuite/20_util/expected/version.cc: Only check for
__cpp_lib_constexpr_exceptions macro for cxx11 ABI.
* testsuite/20_util/optional/version.cc: Likewise.
* testsuite/20_util/variant/version.cc: Likewise.
Reviewed-by: Jakub Jelinek <[email protected]>
---
v2: I forgot to include the testsuite changes in the patch!
Tested x86_64-linux. Pushed to trunk.
libstdc++-v3/include/bits/version.def | 1 +
libstdc++-v3/include/bits/version.h | 2 +-
libstdc++-v3/testsuite/18_support/exception/version.cc | 1 +
.../testsuite/18_support/exception_ptr/exception_ptr_cast.cc | 2 ++
.../testsuite/19_diagnostics/headers/stdexcept/version.cc | 1 +
.../testsuite/19_diagnostics/logic_error/constexpr.cc | 1 +
.../testsuite/19_diagnostics/runtime_error/constexpr.cc | 1 +
libstdc++-v3/testsuite/20_util/expected/version.cc | 4 ++--
libstdc++-v3/testsuite/20_util/optional/version.cc | 4 ++++
libstdc++-v3/testsuite/20_util/variant/version.cc | 4 ++--
10 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/include/bits/version.def
b/libstdc++-v3/include/bits/version.def
index 1cd75fba8329..9fe6ada4ff46 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -2233,6 +2233,7 @@ ftms = {
v = 202502;
cxxmin = 26;
extra_cond = "__cpp_constexpr_exceptions >= 202411L";
+ cxx11abi = yes;
};
};
diff --git a/libstdc++-v3/include/bits/version.h
b/libstdc++-v3/include/bits/version.h
index ab17d0444eb1..08c738d410fb 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -2497,7 +2497,7 @@
#undef __glibcxx_want_bitset
#if !defined(__cpp_lib_constexpr_exceptions)
-# if (__cplusplus > 202302L) && (__cpp_constexpr_exceptions >= 202411L)
+# if (__cplusplus > 202302L) && _GLIBCXX_USE_CXX11_ABI &&
(__cpp_constexpr_exceptions >= 202411L)
# define __glibcxx_constexpr_exceptions 202502L
# if defined(__glibcxx_want_all) ||
defined(__glibcxx_want_constexpr_exceptions)
# define __cpp_lib_constexpr_exceptions 202502L
diff --git a/libstdc++-v3/testsuite/18_support/exception/version.cc
b/libstdc++-v3/testsuite/18_support/exception/version.cc
index a1cf532cd3f6..2dd2f2171a90 100644
--- a/libstdc++-v3/testsuite/18_support/exception/version.cc
+++ b/libstdc++-v3/testsuite/18_support/exception/version.cc
@@ -1,5 +1,6 @@
// { dg-do preprocess { target c++26 } }
// { dg-add-options no_pch }
+// { dg-require-effective-target cxx11_abi }
#include <exception>
diff --git
a/libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc
b/libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc
index de371d1b7b7f..64c706401441 100644
--- a/libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc
+++ b/libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc
@@ -78,7 +78,9 @@ constexpr bool test01(bool x)
return true;
}
+#if _GLIBCXX_USE_CXX11_ABI
static_assert(test01(false));
+#endif
int main()
{
diff --git a/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc
b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc
index ab2b9a5e9ea4..5d3325d64fb0 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc
@@ -1,5 +1,6 @@
// { dg-do preprocess { target c++26 } }
// { dg-add-options no_pch }
+// { dg-require-effective-target cxx11_abi }
#include <stdexcept>
diff --git a/libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc
b/libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc
index ae37b82ab8df..c742bc16bd61 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc
@@ -1,4 +1,5 @@
// { dg-do compile { target c++26 } }
+// { dg-require-effective-target cxx11_abi }
#include <string>
#include <stdexcept>
diff --git a/libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc
b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc
index a7d96eb73a3c..a10423eedc60 100644
--- a/libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc
+++ b/libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc
@@ -1,4 +1,5 @@
// { dg-do compile { target c++26 } }
+// { dg-require-effective-target cxx11_abi }
#include <string>
#include <stdexcept>
diff --git a/libstdc++-v3/testsuite/20_util/expected/version.cc
b/libstdc++-v3/testsuite/20_util/expected/version.cc
index aacd61b7f0a9..17c7fe4a5d65 100644
--- a/libstdc++-v3/testsuite/20_util/expected/version.cc
+++ b/libstdc++-v3/testsuite/20_util/expected/version.cc
@@ -15,7 +15,7 @@
# error "Feature-test macro for freestanding expected has wrong value in
<version>"
#endif
-#if __cplusplus > 202302L
+#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
# ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <version>"
# elif __cpp_lib_constexpr_exceptions < 202502L
@@ -40,7 +40,7 @@
# error "Feature-test macro for freestanding expected has wrong value in
<expected>"
#endif
-#if __cplusplus > 202302L
+#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
# ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <expected>"
# elif __cpp_lib_constexpr_exceptions < 202502L
diff --git a/libstdc++-v3/testsuite/20_util/optional/version.cc
b/libstdc++-v3/testsuite/20_util/optional/version.cc
index f59cb9966fb7..d869e47a80d1 100644
--- a/libstdc++-v3/testsuite/20_util/optional/version.cc
+++ b/libstdc++-v3/testsuite/20_util/optional/version.cc
@@ -30,11 +30,13 @@
# error "Feature test macro for optional range support has wrong value for
C++26 in <version>"
# endif
+# if _GLIBCXX_USE_CXX11_ABI
# ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <version>"
# elif __cpp_lib_constexpr_exceptions < 202502L
# error "Feature test macro for constexpr_exceptions has wrong value in
<version>"
# endif
+# endif
#endif
#undef __cpp_lib_optional
@@ -59,9 +61,11 @@
# error "Feature test macro for optional range support has wrong value for
C++26 in <optional>"
# endif
+# if _GLIBCXX_USE_CXX11_ABI
# ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <optional>"
# elif __cpp_lib_constexpr_exceptions < 202502L
# error "Feature test macro for constexpr_exceptions has wrong value in
<optional>"
# endif
+# endif
#endif
diff --git a/libstdc++-v3/testsuite/20_util/variant/version.cc
b/libstdc++-v3/testsuite/20_util/variant/version.cc
index 8c4f08a2e59a..ad9e14068229 100644
--- a/libstdc++-v3/testsuite/20_util/variant/version.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/version.cc
@@ -19,7 +19,7 @@
#endif
#endif
-#if __cplusplus > 202302L
+#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
#ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <version>"
#elif __cpp_lib_constexpr_exceptions < 202502L
@@ -40,7 +40,7 @@
#endif
#endif
-#if __cplusplus > 202302L
+#if __cplusplus > 202302L && _GLIBCXX_USE_CXX11_ABI
#ifndef __cpp_lib_constexpr_exceptions
# error "Feature test macro for constexpr_exceptions is missing in <variant>"
#elif __cpp_lib_constexpr_exceptions < 202502L
--
2.52.0