https://gcc.gnu.org/g:3e448005c51320801c0e2fa6ddf577da51cec7c7
commit r16-113-g3e448005c51320801c0e2fa6ddf577da51cec7c7 Author: Jason Merrill <ja...@redhat.com> Date: Thu Apr 24 05:15:01 2025 -0400 c++: attribute duplication [PR116954] As a followup to the previous patch for 116954, there's no reason to do anything in remove_contract_attributes if contracts aren't enabled. PR c++/116954 gcc/cp/ChangeLog: * contracts.cc (remove_contract_attributes): Return early if not enabled. Diff: --- gcc/cp/contracts.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 3ca2102e8663..d0cfd2efd552 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -860,6 +860,9 @@ cp_contract_assertion_p (const_tree attr) void remove_contract_attributes (tree fndecl) { + if (!flag_contracts) + return; + tree list = NULL_TREE; for (tree p = DECL_ATTRIBUTES (fndecl); p; p = TREE_CHAIN (p)) if (!cxx_contract_attribute_p (p))