]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Define __cpp_lib_replaceable_contract_violation_handler.
authorTomasz Kamiński <tkaminsk@redhat.com>
Wed, 8 Apr 2026 13:46:28 +0000 (15:46 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Mon, 13 Apr 2026 10:57:58 +0000 (12:57 +0200)
This implements P3886R0: Wording for AT1-057, by defining the
__cpp_lib_replaceable_contract_violation_handler. The macro is defined
only if contracts are supported (i.e. under same conditions as
__cpp_lib_contracts).

GCC supports providing custom violation handler by providing an separate
defintion of handle_contract_violation. This is supported on the targets
that uses ELF format, so the macro is defined for with non-zero value
for them.

libstdc++-v3/ChangeLog:

* include/bits/version.def (replaceable_contract_violation_handler)
[(__cplusplus > 202302L) && (__cpp_contracts >= 202502L)]:
Define to 202603 for ELF targets, and 0 otherwise.
* include/bits/version.h: Regenerate.
* include/std/contracts: Define
__cpp_lib_replaceable_contract_violation_handler.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/bits/version.def
libstdc++-v3/include/bits/version.h
libstdc++-v3/include/std/contracts

index 3b4a0d4fdc054fd7f539ff928d7144e021029ef8..b88d9c3483f8290be9a93083f369bc4ae6f79272 100644 (file)
@@ -2349,6 +2349,21 @@ ftms = {
   };
 };
 
+ftms = {
+  name = replaceable_contract_violation_handler;
+  values = {
+    v = 202603;
+    cxxmin = 26;
+    extra_cond = "__cpp_contracts >= 202502L "
+    "&& __ELF__";
+  };
+  values = {
+    v = 0;
+    cxxmin = 26;
+    extra_cond = "__cpp_contracts >= 202502L";
+  };
+};
+
 ftms = {
   name = simd;
   values = {
index 59719b4f8116b0f0d383503e0a4299654bc60a7f..24ec0175e1e417608e047280a42508aae695be8a 100644 (file)
 #endif /* !defined(__cpp_lib_contracts) */
 #undef __glibcxx_want_contracts
 
+#if !defined(__cpp_lib_replaceable_contract_violation_handler)
+# if (__cplusplus >  202302L) && (__cpp_contracts >= 202502L && __ELF__)
+#  define __glibcxx_replaceable_contract_violation_handler 202603L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)
+#   define __cpp_lib_replaceable_contract_violation_handler 202603L
+#  endif
+# elif (__cplusplus >  202302L) && (__cpp_contracts >= 202502L)
+#  define __glibcxx_replaceable_contract_violation_handler 0L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_replaceable_contract_violation_handler)
+#   define __cpp_lib_replaceable_contract_violation_handler 0L
+#  endif
+# endif
+#endif /* !defined(__cpp_lib_replaceable_contract_violation_handler) */
+#undef __glibcxx_want_replaceable_contract_violation_handler
+
 #if !defined(__cpp_lib_simd)
 # if (__cplusplus >  202302L) && _GLIBCXX_HOSTED && (__cpp_structured_bindings >= 202411L && __cpp_expansion_statements >= 202411L && __SSE2__)
 #  define __glibcxx_simd 202506L
index c1fe54750af96b207bef492956251abb403e75cc..a0575fbefd934bcf3cb2ed3c50b3d87c11aebfc5 100644 (file)
@@ -33,6 +33,7 @@
 #pragma GCC system_header
 
 #define __glibcxx_want_contracts
+#define __glibcxx_want_replaceable_contract_violation_handler
 #include <bits/version.h>
 
 #ifdef __cpp_lib_contracts