diff options
author | Marek Polacek <polacek@redhat.com> | 2019-08-23 00:06:25 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2019-08-23 00:06:25 +0000 |
commit | ab3dd132a12c33815912a236c961a5c0d40d1818 (patch) | |
tree | 2fb865d84e0ea2aa36a38159cb785b1dad1b159f /gcc | |
parent | f99aba156210eba620b6e774543d3e0adfdf09c2 (diff) | |
download | gcc-ab3dd132a12c33815912a236c961a5c0d40d1818.zip gcc-ab3dd132a12c33815912a236c961a5c0d40d1818.tar.gz gcc-ab3dd132a12c33815912a236c961a5c0d40d1818.tar.bz2 |
PR c++/91304 - prefix attributes ignored in condition.
* parser.c (cp_parser_condition): Handle prefix attributes.
* g++.dg/cpp0x/gen-attrs-70.C: New test.
From-SVN: r274839
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/gen-attrs-70.C | 13 |
4 files changed, 28 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d47c2f7..d2b9623 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-08-22 Marek Polacek <polacek@redhat.com> + + PR c++/91304 - prefix attributes ignored in condition. + * parser.c (cp_parser_condition): Handle prefix attributes. + 2019-08-21 Richard Sandiford <richard.sandiford@arm.com> PR c++/91505 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index dbbfe1d..b410a6c 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12066,6 +12066,10 @@ cp_parser_condition (cp_parser* parser) /* Restore the saved message. */ parser->type_definition_forbidden_message = saved_message; + /* Gather the attributes that were provided with the + decl-specifiers. */ + tree prefix_attributes = type_specifiers.attributes; + cp_parser_maybe_commit_to_declaration (parser, type_specifiers.any_specifiers_p); @@ -12116,7 +12120,7 @@ cp_parser_condition (cp_parser* parser) /* Create the declaration. */ decl = start_decl (declarator, &type_specifiers, /*initialized_p=*/true, - attributes, /*prefix_attributes=*/NULL_TREE, + attributes, prefix_attributes, &pushed_scope); /* Parse the initializer. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7c4ec3..ad5aa69 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-22 Marek Polacek <polacek@redhat.com> + + PR c++/91304 - prefix attributes ignored in condition. + * g++.dg/cpp0x/gen-attrs-70.C: New test. + 2019-08-22 Martin Sebor <msebor@redhat.com> PR middle-end/91490 diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-70.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-70.C new file mode 100644 index 0000000..90a2e97 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-70.C @@ -0,0 +1,13 @@ +// PR c++/91304 - prefix attributes ignored in condition. +// { dg-do compile { target c++11 } } +// { dg-additional-options "-Wall -Wextra" } + +int f(); + +void g() +{ + if ([[maybe_unused]] int i = f()) { } + if ([[deprecated]] int i = f()) { i = 10; } // { dg-warning ".i. is deprecated" } + if (int i [[maybe_unused]] = f()) { } + if (int i [[deprecated]] = f()) { i = 10; } // { dg-warning ".i. is deprecated" } +} |