libstdc++: Define __cpp_lib_replaceable_contract_violation_handler.

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>
This commit is contained in:
Tomasz Kamiński
2026-04-08 15:46:28 +02:00
parent 7762443b9e
commit 8beabc8851
3 changed files with 31 additions and 0 deletions

View 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 = {

View File

@@ -2616,6 +2616,21 @@
#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

View 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