From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EFD853857BB2; Thu, 2 Mar 2023 16:02:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFD853857BB2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677772930; bh=1jJewqj+igZnO4zdSIwvSjVffU1YqBz5YOGbXlxLB+E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AaZQpLg4aJ0k8YOyrYwt/y2QRdFysDXhfdeTZhYLParHnzTV4277YgSSIWNSb+GoG AgoUjFKxhaXQdmLNgbm6MOGoMyg8jsSAQU/+zEA6+1ULDLRK+289Qx958tIzniK+vn +hA/KRO3Rq34rolssL+hJ0s+neBXa2oWlnnKSAeo= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106259] [10/11/12/13 Regression] ICE in diag_mismatched_tags, at cp/parser.cc:33896 Date: Thu, 02 Mar 2023 16:02:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106259 --- Comment #6 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:71afd0628419c5d670701cb35bc9860380c7d9fb commit r13-6417-g71afd0628419c5d670701cb35bc9860380c7d9fb Author: Marek Polacek Date: Wed Mar 1 14:28:46 2023 -0500 c++: ICE with -Wmismatched-tags and member template [PR106259] -Wmismatched-tags warns about the (harmless) struct/class mismatch. For, e.g., template struct A { }; class A a; it works by adding A to the class2loc hash table while parsing the class-head and then, while parsing the elaborate type-specifier, we add A. At the end of c_parse_file we go through the table and warn about the class-key mismatches. In this PR we crash though; we have template struct A { template struct W { }; }; struct A::W w; // #1 where while parsing A and #1 we've stashed A A::W A::W into class2loc. Then in class_decl_loc_t::diag_mismatched_tags TYPE is A::W, and specialization_of gets us A::W, which is not in class2loc, so we crash on gcc_assert (cdlguide). But it's OK not to have found A::W, we should just look one "level" up, that is, A::W. It's important to handle class specializations, so e.g. template<> struct A { template class W { }; }; where W's class-key is different than in the primary template above, so we should warn depending on whether we're looking into A or into a different instantiation. PR c++/106259 gcc/cp/ChangeLog: * parser.cc (class_decl_loc_t::diag_mismatched_tags): If the fi= rst lookup of SPEC didn't find anything, try to look for most_general_template. gcc/testsuite/ChangeLog: * g++.dg/warn/Wmismatched-tags-11.C: New test.=