From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 26A07383802C; Sat, 4 Jun 2022 13:59:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26A07383802C From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/69585] [C++ 11] parser errors mixing alignas, C++ 11 and GNU attributes on class declaration Date: Sat, 04 Jun 2022 13:59:51 +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: 6.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Sat, 04 Jun 2022 13:59:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D69585 --- Comment #4 from CVS Commits --- The trunk branch has been updated by Marek Polacek : https://gcc.gnu.org/g:aec868578d8515763d75693c1fdfbc30ff0a1e68 commit r13-991-gaec868578d8515763d75693c1fdfbc30ff0a1e68 Author: Marek Polacek Date: Thu Jun 2 15:44:20 2022 -0400 c++: Allow mixing GNU/std-style attributes [PR69585] cp_parser_attributes_opt doesn't accept GNU attributes followed by [[]] attributes and vice versa; only a sequence of attributes of the same kind. That causes grief for code like: struct __attribute__ ((may_alias)) alignas (2) struct S { }; or #define EXPORT __attribute__((visibility("default"))) struct [[nodiscard]] EXPORT F { }; It doesn't seem to a documented restriction, so this patch fixes the problem. However, the patch does not touch the C FE. The C FE doesn't have a counterpart to C++'s cp_parser_attributes_opt -- it only has c_parser_transaction_attributes (which parses both GNU and [[]] attributes), but that's TM-specific. The C FE seems to use either c_parser_gnu_attributes or c_parser_std_attribute_specifier_sequence. As a consequence, this works: [[maybe_unused]] __attribute__((deprecated)) void f2 (); but this doesn't: __attribute__((deprecated)) [[maybe_unused]] void f1 (); I'm not sure what, if anything, should be done about this. PR c++/102399 PR c++/69585 gcc/cp/ChangeLog: * parser.cc (cp_parser_attributes_opt): Accept GNU attributes followed by [[]] attributes and vice versa. gcc/testsuite/ChangeLog: * g++.dg/ext/attrib65.C: New test. * g++.dg/ext/attrib66.C: New test. * g++.dg/ext/attrib67.C: New test.=