C++/Contracts: Unify pseudo-template mode condition.
Standardizes conditions for parsing contract postconditions in pseudo-template mode to avoid substitution errors.
This change unifies the conditions under which contract postconditions are parsed and substituted in pseudo-template mode within the C++ frontend. Previously, differing conditions led to issues when substituting non-template trees. The fix ensures this approach is consistently applied only to postconditions that have result identifiers and deduced return types.
In Details
In GCC's C++ frontend, contract postconditions can be processed in a 'pseudo-template mode'. This commit standardizes the conditions for entering this mode in tsubst_contract and rebuild_postconditions within pt.cc and contracts.cc. It now requires undeduced result bindings and deducible return types, aligning with cp_parser_late_contract_condition in parser.cc and preventing errors from substituting non-template trees.
- pseudo-template mode
- A mode in the C++ compiler where template-like substitutions are performed on contract conditions, even if they are not true C++ templates. This is used to resolve contract expressions at compile time.
- contract postcondition
- A condition that must hold true after a function executes, as specified by C++20 contracts. These can involve result identifiers and return types.
- result identifier
- A special identifier used within a contract clause to refer to the return value of the function.
- deduced return type
- The compiler infers the return type of a function automatically, rather than it being explicitly declared.