Pedwarn on a non-standard position of a C++ attribute.
From-SVN: r260682
This commit is contained in:
parent
fd657f1acb
commit
9635923dc8
5 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2018-05-24 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
Pedwarn on a non-standard position of a C++ attribute.
|
||||
* parser.c (cp_parser_namespace_definition): Pedwarn about attributes
|
||||
after the namespace name.
|
||||
|
||||
2018-05-24 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* cp-tree.h (INDIRECT_TYPE_P): New.
|
||||
|
|
|
@ -18656,6 +18656,11 @@ cp_parser_namespace_definition (cp_parser* parser)
|
|||
{
|
||||
identifier = cp_parser_identifier (parser);
|
||||
|
||||
if (cp_next_tokens_can_be_std_attribute_p (parser))
|
||||
pedwarn (input_location, OPT_Wpedantic,
|
||||
"standard attributes on namespaces must precede "
|
||||
"the namespace name");
|
||||
|
||||
/* Parse any attributes specified after the identifier. */
|
||||
attribs = attr_chainon (attribs, cp_parser_attributes_opt (parser));
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
// { dg-do compile { target c++11 } }
|
||||
|
||||
namespace foo __attribute__((visibility("default"))) {}
|
||||
namespace bar [[gnu::visibility("default")]] {}
|
||||
namespace [[gnu::visibility("default")]] bar {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// PR c++/85140
|
||||
// { dg-do compile { target c++11 } }
|
||||
|
||||
namespace N alignas() {} // { dg-error "expected" }
|
||||
namespace alignas() N {} // { dg-error "expected" }
|
||||
|
|
7
gcc/testsuite/g++.dg/cpp1z/namespace-attribs2.C
Normal file
7
gcc/testsuite/g++.dg/cpp1z/namespace-attribs2.C
Normal file
|
@ -0,0 +1,7 @@
|
|||
// { dg-options "-std=c++17" }
|
||||
// { dg-additional-options "-pedantic" }
|
||||
|
||||
namespace B [[deprecated]] {} // { dg-warning "ignored|must precede" }
|
||||
|
||||
namespace [[deprecated]] D {} // { dg-warning "ignored" }
|
||||
|
Loading…
Add table
Reference in a new issue