110345 – [C++26] P2552R3 - On the ignorability of standard attributes (original) (raw)

| Comment 1 Jakub Jelinek 2023-08-25 09:29:25 UTC Created attachment 55791 [details] gcc14-pr110345-wip.patch So, parts of this paper has been already fixed in r13-3848-g05119c345797bc04c . The fallthrough stuff is still outstanding I think and I'll have a look. The largest nightmare is diagnostics on standard attributes which appertain to something that shouldn't allow them, I'm lost there. I went through the grammar (except for modules) and tried to find all spots where standard allows attribute-specifier-seq and tried to write that into a testcase in the attached patch, for now for deprecated attribute and marked all -pedantic-errors diagnostics. I've added lots of FIXMEs in there where I don't really know. There are even 4 spots where we don't parse the attributes at all (and clang++ does), on the other side there are 4 spots where we do parse them and clang++ doesn't. I think to mark this paper fully resolved we'd need to resolve the FIXMEs and copy/adjust the test for all other standard attributes and verify we emit at least some diagnostics with -pedantic-errors where the standard attributes aren't allowed to appertain to. Comment 3 GCC Commits 2024-08-16 09:44:00 UTC The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:2f90f3850eaf9d703d9eb63d5f0347158aa11027 commit r15-2948-g2f90f3850eaf9d703d9eb63d5f0347158aa11027 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Aug 16 11:43:18 2024 +0200 c++: Pedwarn on [[]]; at class scope [PR110345] For C++ 26 P2552R3 I went through all the spots (except modules) where attribute-specifier-seq appears in the grammar and tried to construct a testcase in all those spots, for now for [[deprecated]] attribute. The fourth issue is that we just emit (when enabled) -Wextra-semi warning not just for lone semicolon at class scope (correct), but also for [[]]; or [[whatever]]; there too. While just semicolon is valid in C++11 and newer, https://eel.is/c++draft/class.mem#nt:member-declaration allows empty-declaration, unlike namespace scope or block scope something like attribute-declaration or empty statement with attributes applied for it aren't supported. While syntactically it matches attribute-specifier-seq [opt] decl-specifier-seq [opt] member-declarator-list [opt] ; with the latter two omitted, there is https://eel.is/c++draft/class.mem#general-3 which says that is not valid. So, the following patch emits a pedwarn in that case. 2024-08-16 Jakub Jelinek <jakub@redhat.com> PR c++/110345 * parser.cc (cp_parser_member_declaration): Call maybe_warn_extra_semi only if it is empty-declaration, if there are some tokens like attribute, pedwarn that the declaration doesn't declare anything. * g++.dg/cpp0x/gen-attrs-84.C: New test. Comment 5 GCC Commits 2024-08-20 20🔞45 UTC The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:d05949558ef1c8eeeb07399174a64f968f70e3ee commit r15-3046-gd05949558ef1c8eeeb07399174a64f968f70e3ee Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Aug 20 22:17:41 2024 +0200 c++: Appertain standard attributes after array closing square bracket to array type rather than declarator [PR110345] For C++ 26 P2552R3 I went through all the spots (except modules) where attribute-specifier-seq appears in the grammar and tried to construct a testcase in all those spots, for now for [[deprecated]] attribute. This is the second issue I found. The comment already correctly says that attributes after closing ] appertain to the array type, but we were appending them to returned_attrs, so effectively applying them to the declarator (as if they appeared right after declarator-id). 2024-08-20 Jakub Jelinek <jakub@redhat.com> PR c++/110345 * decl.cc (grokdeclarator): Apply declarator->std_attributes for cdk_array to type, rather than chaining it to returned_attrs. * g++.dg/cpp0x/gen-attrs-82.C: New test. * g++.dg/gomp/attrs-3.C (foo): Expect different diagnostics for omp::directive attribute after closing square bracket of an automatic declaration and add a test with the attribute after array's declarator-id. Comment 6 GCC Commits 2024-08-30 07:41:42 UTC The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>: https://gcc.gnu.org/g:b748e2eed0df9e691a530a0b8faea9f673bdf2b5 commit r15-3315-gb748e2eed0df9e691a530a0b8faea9f673bdf2b5 Author: Jakub Jelinek <jakub@redhat.com> Date: Fri Aug 30 09:40:34 2024 +0200 c++: Allow standard attributes after closing square bracket in new-type-id [PR110345] For C++ 26 P2552R3 I went through all the spots (except modules) where attribute-specifier-seq appears in the grammar and tried to construct a testcase in all those spots, for now for [[deprecated]] attribute. The first thing I found is that we aren't parsing standard attributes in noptr-new-declarator - https://eel.is/c++draft/expr.new#1 The following patch parses it there, for the non-outermost arrays applies normally the attributes to the array type, for the outermost where we just set *nelts and don't really build an array type just warns that we ignore those attributes (or, do you think we should just build an array type in that case and just take its element type?). 2024-08-30 Jakub Jelinek <jakub@redhat.com> PR c++/110345 * parser.cc (make_array_declarator): Add STD_ATTRS argument, set declarator->std_attributes to it. (cp_parser_new_type_id): Warn on non-ignored std_attributes on the array declarator which is being omitted. (cp_parser_direct_new_declarator): Parse standard attributes after closing square bracket, pass it to make_array_declarator. (cp_parser_direct_declarator): Pass std_attrs to make_array_declarator instead of setting declarator->std_attributes manually. * g++.dg/cpp0x/gen-attrs-80.C: New test. * g++.dg/cpp0x/gen-attrs-81.C: New test. | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |