From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8BB81385840E; Wed, 24 Nov 2021 09:09:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BB81385840E From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/103365] [12 Regression] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a" Date: Wed, 24 Nov 2021 09:09:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.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: P1 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2021 09:09:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103365 --- Comment #4 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:709716b9f49f2fcf46f319000562cf6e61bd2f71 commit r12-5493-g709716b9f49f2fcf46f319000562cf6e61bd2f71 Author: Jakub Jelinek Date: Wed Nov 24 10:08:35 2021 +0100 attribs: Fix ICEs on attributes starting with _ [PR103365] As the patch shows, we have quite a few asserts that we don't call lookup_attribute etc. with attr_name that starts with an underscore, to make sure nobody is trying to call it with non-canonicalized attribute name like "__cold__" instead of "cold". We canonicalize only attributes that start with 2 underscores and end with 2 underscores though. Before Marek's patch, that wasn't an issue, we had no attributes like "_foo" or "__bar_" etc., so lookup_scoped_attribute_spec would always return NULL for those and we wouldn't try to register them, look them up etc., just with -Wattributes would warn about them. But now, as the new testcases show, users can actually request such attributes to be ignored, and we ICE for those during register_scoped_attribute and when that is fixed, ICE later on when somebody uses those attributes because they will be looked up to find out that they should be ignored. So, the following patch instead of or in addition to, depending on how performance sensitive a particular spot is, checking that attribute doesn't start with underscore allows attribute names that start with underscore as long as it doesn't canonicalize (i.e. doesn't start and end with 2 underscores). In addition to that, I've noticed lookup_attribute_by_prefix was calling get_attribute_name twice unnecessarily, and 2 tests were running in c++98 mode with -std=3Dc++98 -std=3Dc++11 which IMHO isn't useful because -std=3Dc++11 testing is done too when testing all language versions. 2021-11-24 Jakub Jelinek PR middle-end/103365 * attribs.h (lookup_attribute): Allow attr_name to start with underscore, as long as canonicalize_attr_name returns false. (lookup_attribute_by_prefix): Don't call get_attribute_name twi= ce. * attribs.c (extract_attribute_substring): Reimplement using canonicalize_attr_name. (register_scoped_attribute): Change gcc_assert into gcc_checking_assert, verify !canonicalize_attr_name rather than that str.str doesn't start with '_'. * c-c++-common/Wno-attributes-1.c: Require effective target c || c++11 and drop dg-additional-options. * c-c++-common/Wno-attributes-2.c: Likewise. * c-c++-common/Wno-attributes-4.c: New test. * c-c++-common/Wno-attributes-5.c: New test.=