From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 1EDA73945065; Tue, 8 Jun 2021 03:55:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EDA73945065 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1271] c++: fix modules binfo merging X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/master X-Git-Oldrev: a1b3484a8e6c53c8084723e3f1738d402374198e X-Git-Newrev: 715614ec3ec5390293e508bb190335d28db1fa8b Message-Id: <20210608035512.1EDA73945065@sourceware.org> Date: Tue, 8 Jun 2021 03:55:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jun 2021 03:55:12 -0000 https://gcc.gnu.org/g:715614ec3ec5390293e508bb190335d28db1fa8b commit r12-1271-g715614ec3ec5390293e508bb190335d28db1fa8b Author: Jason Merrill Date: Mon Jun 7 17:51:24 2021 -0400 c++: fix modules binfo merging My coming fix for PR91706 caused some regressions in the modules testsuite. This turned out to be because the change to properly use the base subobject BINFO as BASELINK_BINFO hit problems with the code for merging binfos. The tree reader needed a typo fix. The duplicate_hash function was crashing on the BINFO for a variadic base in . I started fixing the hash function, but then noticed that there's no ::equal function defined; duplicate_hash just uses pointer equality, so we might as well also use the normal pointer hash for the moment. gcc/cp/ChangeLog: * module.cc (duplicate_hash::hash): Comment out. (trees_in::tree_value): Adjust loop counter. Diff: --- gcc/cp/module.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index f0fb0144706..f259515a498 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -2820,12 +2820,16 @@ struct merge_key { struct duplicate_hash : nodel_ptr_hash { +#if 0 + /* This breaks variadic bases in the xtreme_header tests. Since ::equal is + the default pointer_hash::equal, let's use the default hash as well. */ inline static hashval_t hash (value_type decl) { if (TREE_CODE (decl) == TREE_BINFO) decl = TYPE_NAME (BINFO_TYPE (decl)); return hashval_t (DECL_UID (decl)); } +#endif }; /* Hashmap of merged duplicates. Usually decls, but can contain @@ -8908,7 +8912,7 @@ trees_in::tree_value () dump (dumper::MERGE) && dump ("Deduping binfo %N[%u]", type, ix); existing = TYPE_BINFO (type); - while (existing && ix) + while (existing && ix--) existing = TREE_CHAIN (existing); if (existing) register_duplicate (t, existing);