aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/c_std/cstdio
diff options
context:
space:
mode:
authorNina Ranns <dinka.ranns@gmail.com>2025-08-28 17:56:56 +0100
committerIain Sandoe <iain@sandoe.co.uk>2026-01-28 01:26:26 +0000
commit9a8c08aaad5e19f8f5dd5986a62c3a1148f61f3a (patch)
treed61351067997cda732c3287a04077cca9819174e /libstdc++-v3/include/c_std/cstdio
parent64674a295b63f46ac9b6776348ae6bbda63fd1ef (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
c++, contracts: Add caller-side contract checks, and controls.HEADtrunkmaster
This a (currently GCC-only) extension that implements caller-side checking of pre and post conditions. It is completely in scope with the C++26 CDIS wording, but is not mandated. The implementation here allows applying caller or callee-side checking independently. gcc/c-family/ChangeLog: * c.opt (fcontracts-definition-check=, fcontracts-client-check=): New. * c.opt.urls: Regenerate. gcc/cp/ChangeLog: * call.cc (build_cxx_call): Where enabled, wrap calls to functions with contract specifiers. * contracts.cc (enum contract_match_kind): Move to contracts header. (build_contract_condition_function): Copy caller-side wrapper state. (set_contract_wrapper_function, get_contract_wrapper_function, get_orig_func_for_wrapper, contracts_fixup_cdtorname, build_contract_wrapper_function, get_or_create_contract_wrapper_function): New. (start_function_contracts): Handle caller-side wrappers. (maybe_apply_function_contracts): Likewise. (copy_and_remap_contracts): Likewise. (should_contract_wrap_call, maybe_contract_wrap_call, define_contract_wrapper_func, emit_contract_wrapper_func): New. (finish_function_contracts): Handle caller-side wrappers. (get_src_loc_impl_ptr): Likewise. * contracts.h (DECL_IS_WRAPPER_FN_P): New. (enum contract_match_kind): Moved from contracts.cc. (copy_and_remap_contracts): Allow selection on the specific contract kind. (maybe_contract_wrap_call, emit_contract_wrapper_func): New. (set_decl_contracts): Delete dead code. * cp-tree.h (struct lang_decl_fn): Add wrapper function bit. (DECL_CONTRACT_WRAPPER): New. * decl2.cc (c_parse_final_cleanups): Emit wrappers. gcc/ChangeLog: * doc/invoke.texi: Document -fcontracts-client-check= and -fcontracts-definition-check=. gcc/testsuite/ChangeLog: * g++.dg/contracts/cpp26/callerside-checks/callerside-checks-all.C: New test. * g++.dg/contracts/cpp26/callerside-checks/callerside-checks-non-trivial.C: New test. * g++.dg/contracts/cpp26/callerside-checks/callerside-checks-none.C: New test. * g++.dg/contracts/cpp26/callerside-checks/callerside-checks-pre.C: New test. * g++.dg/contracts/cpp26/callerside-checks/ctor.C: New test. * g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-post.C: New test. * g++.dg/contracts/cpp26/callerside-checks/freefunc-noexcept-pre.C: New test. * g++.dg/contracts/cpp26/definition-checks/contract-assert-no-def-check.C: New test. * g++.dg/contracts/cpp26/non-trivial-ice.C: New test. Co-Authored-by: Iain Sandoe <iain@sandoe.co.uk> Co-Authored-by: Ville Voutilainen <ville.voutilainen@gmail.com> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'libstdc++-v3/include/c_std/cstdio')
0 files changed, 0 insertions, 0 deletions