]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make __cpp_lib_constexpr_exceptions depend on cxx11 ABI
authorJonathan Wakely <jwakely@redhat.com>
Tue, 16 Dec 2025 11:12:33 +0000 (11:12 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 17 Dec 2025 21:28:57 +0000 (21:28 +0000)
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 <jakub@redhat.com>
libstdc++-v3/include/bits/version.def
libstdc++-v3/include/bits/version.h
libstdc++-v3/testsuite/18_support/exception/version.cc
libstdc++-v3/testsuite/18_support/exception_ptr/exception_ptr_cast.cc
libstdc++-v3/testsuite/19_diagnostics/headers/stdexcept/version.cc
libstdc++-v3/testsuite/19_diagnostics/logic_error/constexpr.cc
libstdc++-v3/testsuite/19_diagnostics/runtime_error/constexpr.cc
libstdc++-v3/testsuite/20_util/expected/version.cc
libstdc++-v3/testsuite/20_util/optional/version.cc
libstdc++-v3/testsuite/20_util/variant/version.cc

index 1cd75fba8329ddf683d347aba6a41c58ad0cab72..9fe6ada4ff46b2d728d27653ed2a595d66a442dd 100644 (file)
@@ -2233,6 +2233,7 @@ ftms = {
     v = 202502;
     cxxmin = 26;
     extra_cond = "__cpp_constexpr_exceptions >= 202411L";
+    cxx11abi = yes;
   };
 };
 
index ab17d0444eb15fde64a7ad45f325437c280b1b0b..08c738d410fbbed463ebc708be51506808a629e5 100644 (file)
 #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
index a1cf532cd3f68369b23dc463de56bc547a187a11..2dd2f2171a9082dfd977f72e38320013a665dc97 100644 (file)
@@ -1,5 +1,6 @@
 // { dg-do preprocess { target c++26 } }
 // { dg-add-options no_pch }
+// { dg-require-effective-target cxx11_abi }
 
 #include <exception>
 
index de371d1b7b7ffe47abd36180addaa8dac17705f7..64c706401441fc2fd36cee687d808957d17e0d58 100644 (file)
@@ -78,7 +78,9 @@ constexpr bool test01(bool x)
   return true;
 }
 
+#if _GLIBCXX_USE_CXX11_ABI
 static_assert(test01(false));
+#endif
 
 int main()
 {
index ab2b9a5e9ea43aa8cf54b7c7f59450bc88f7d3f2..5d3325d64fb0eb61d2883fbe43588e4b876d9efc 100644 (file)
@@ -1,5 +1,6 @@
 // { dg-do preprocess { target c++26 } }
 // { dg-add-options no_pch }
+// { dg-require-effective-target cxx11_abi }
 
 #include <stdexcept>
 
index ae37b82ab8dfcdb4019cc695ee3bea9c85fa0386..c742bc16bd61c7d9f801e460e3f82a84a0ca3d0d 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++26 } }
+// { dg-require-effective-target cxx11_abi }
 
 #include <string>
 #include <stdexcept>
index a7d96eb73a3c00b221fd2ea9ae18a69ee5b79d6e..a10423eedc60134aa20a7b51e641910959d9cd48 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do compile { target c++26 } }
+// { dg-require-effective-target cxx11_abi }
 
 #include <string>
 #include <stdexcept>
index aacd61b7f0a9b3eaca68c9325f5924c6a33a897a..17c7fe4a5d65d1f8be270a86f6bcc5184371e84b 100644 (file)
@@ -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
index f59cb9966fb780cf1a79b000435cee633dff28fd..d869e47a80d1e299a6b5e16c6b18d15fdf167bd0 100644 (file)
 #  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
 #  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
index 8c4f08a2e59ab22c6660472cd198e922873c5d97..ad9e14068229ef77741c02ffd907583446c5eed7 100644 (file)
@@ -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