]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: friend contracts are in complete-class context
authorJason Merrill <jason@redhat.com>
Wed, 2 Nov 2022 19:21:29 +0000 (15:21 -0400)
committerJason Merrill <jason@redhat.com>
Wed, 2 Nov 2022 20:23:20 +0000 (16:23 -0400)
commite378b7f8250d1e1b029c0254dc17492fa16e9de4
tree95b850a427660b828771e62220c50c504d0d77fa
parenta05f106bafd5a74e677e3bddab6eeabbae362dc8
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.
gcc/cp/contracts.cc
gcc/cp/contracts.h
gcc/cp/decl.cc
gcc/cp/parser.cc
gcc/cp/parser.h
gcc/testsuite/g++.dg/contracts/contracts-friend1.C
gcc/testsuite/g++.dg/contracts/contracts-nested-class1.C
gcc/testsuite/g++.dg/contracts/contracts-redecl7.C
gcc/testsuite/g++.dg/contracts/contracts-redecl8.C