c++: friend contracts are in complete-class context
Comparing friend contracts to a previous declaration was awkward
because at the point of duplicate_decls we haven't parsed the new ones yet,
and we're about to throw away one of the decls. But conveniently, there's
already defer_guarded_contract_match to handle this.
This reverts commit
9c0d8bfebc32d5e2c35ed61753440fb175a87dcf.
gcc/cp/ChangeLog:
* contracts.cc (check_for_mismatched_contracts):
Only check new_contract for deferred.
(match_deferred_contracts): Set processing_template_decl.
(duplicate_contracts): Call defer_guarded_contract_match
for friend decl. Handle templates.
* decl.cc (duplicate_decls): Use it for templates.
* parser.h (struct cp_parser): Remove declaring_friend_p.
* parser.cc (cp_parser_new): Don't clear it.
(cp_parser_direct_declarator): Don't set it.
(cp_parser_contract_attribute_spec): Don't check it.
* contracts.h (match_contract_conditions): Remove.
gcc/testsuite/ChangeLog:
* g++.dg/contracts/contracts-friend1.C: Revert.
* g++.dg/contracts/contracts-nested-class1.C: Revert.
* g++.dg/contracts/contracts-redecl7.C: Revert.
* g++.dg/contracts/contracts-redecl8.C: Revert.