Commit ab3dd132 by Marek Polacek Committed by Marek Polacek

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
parent f99aba15
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> 2019-08-21 Richard Sandiford <richard.sandiford@arm.com>
PR c++/91505 PR c++/91505
......
...@@ -12066,6 +12066,10 @@ cp_parser_condition (cp_parser* parser) ...@@ -12066,6 +12066,10 @@ cp_parser_condition (cp_parser* parser)
/* Restore the saved message. */ /* Restore the saved message. */
parser->type_definition_forbidden_message = 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, cp_parser_maybe_commit_to_declaration (parser,
type_specifiers.any_specifiers_p); type_specifiers.any_specifiers_p);
...@@ -12116,7 +12120,7 @@ cp_parser_condition (cp_parser* parser) ...@@ -12116,7 +12120,7 @@ cp_parser_condition (cp_parser* parser)
/* Create the declaration. */ /* Create the declaration. */
decl = start_decl (declarator, &type_specifiers, decl = start_decl (declarator, &type_specifiers,
/*initialized_p=*/true, /*initialized_p=*/true,
attributes, /*prefix_attributes=*/NULL_TREE, attributes, prefix_attributes,
&pushed_scope); &pushed_scope);
/* Parse the initializer. */ /* Parse the initializer. */
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> 2019-08-22 Martin Sebor <msebor@redhat.com>
PR middle-end/91490 PR middle-end/91490
......
// 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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment