diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-08-20 22:15:03 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-08-20 22:15:03 +0200 |
commit | 1db5ca04da365ac57f7d788a85055edcf13da708 (patch) | |
tree | e69c16a5af8ea60dbaf2f5d5a85f28f435adcac1 /gcc/cp/parser.cc | |
parent | 3676816caa510de226b357be1c68cf798da63576 (diff) | |
download | gcc-1db5ca04da365ac57f7d788a85055edcf13da708.zip gcc-1db5ca04da365ac57f7d788a85055edcf13da708.tar.gz gcc-1db5ca04da365ac57f7d788a85055edcf13da708.tar.bz2 |
c++: Parse and ignore attributes on base specifiers [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 third issue I found.
https://eel.is/c++draft/class.derived#general-1 has attribute-specifier-seq
at the start of base-specifier. The following patch parses it there and
warns about those.
2024-08-20 Jakub Jelinek <jakub@redhat.com>
PR c++/110345
* parser.cc (cp_parser_base_specifier): Parse standard attributes
at the start and emit a warning if there are any non-ignored ones.
* g++.dg/cpp0x/gen-attrs-83.C: New test.
Diffstat (limited to 'gcc/cp/parser.cc')
-rw-r--r-- | gcc/cp/parser.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index c438898..28ebf2b 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -28995,11 +28995,12 @@ cp_parser_base_clause (cp_parser* parser) /* Parse a base-specifier. base-specifier: - :: [opt] nested-name-specifier [opt] class-name - virtual access-specifier [opt] :: [opt] nested-name-specifier - [opt] class-name - access-specifier virtual [opt] :: [opt] nested-name-specifier - [opt] class-name + attribute-specifier-seq [opt] :: [opt] nested-name-specifier [opt] + class-name + attribute-specifier-seq [opt] virtual access-specifier [opt] :: [opt] + nested-name-specifier [opt] class-name + attribute-specifier-seq [opt] access-specifier virtual [opt] :: [opt] + nested-name-specifier [opt] class-name Returns a TREE_LIST. The TREE_PURPOSE will be one of ACCESS_{DEFAULT,PUBLIC,PROTECTED,PRIVATE}_[VIRTUAL]_NODE to @@ -29017,6 +29018,12 @@ cp_parser_base_specifier (cp_parser* parser) bool class_scope_p, template_p; tree access = access_default_node; tree type; + location_t attrs_loc = cp_lexer_peek_token (parser->lexer)->location; + tree std_attrs = cp_parser_std_attribute_spec_seq (parser); + + if (std_attrs != NULL_TREE && any_nonignored_attribute_p (std_attrs)) + warning_at (attrs_loc, OPT_Wattributes, + "attributes on base specifiers are ignored"); /* Process the optional `virtual' and `access-specifier'. */ while (!done) |