diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2015-07-01 09:08:17 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2015-07-01 09:08:17 +0000 |
commit | a31dc4e516d2816c6be4c5f7329718223fced1e3 (patch) | |
tree | e5175fe43c39b8951c80af2483cba321b1a172da /gcc | |
parent | d0baaae35172c6cfb7a0c314842bf2cfc62a40f2 (diff) | |
download | gcc-a31dc4e516d2816c6be4c5f7329718223fced1e3.zip gcc-a31dc4e516d2816c6be4c5f7329718223fced1e3.tar.gz gcc-a31dc4e516d2816c6be4c5f7329718223fced1e3.tar.bz2 |
re PR c++/60365 (multiple noreturn attribute specifiers in a single declaration doesn't result in a diagnostic)
/cp
2015-07-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60365
* parser.c (cp_parser_check_std_attribute): New.
(cp_parser_std_attribute_list): Call it.
/testsuite
2015-07-01 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60365
* g++.dg/cpp0x/gen-attrs-60.C: New.
* g++.dg/cpp1y/attr-deprecated-2.C: Likewise.
From-SVN: r225234
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/gen-attrs-60.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/attr-deprecated-2.C | 4 |
5 files changed, 44 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e343641..33fe38e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-07-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/60365 + * parser.c (cp_parser_check_std_attribute): New. + (cp_parser_std_attribute_list): Call it. + 2015-07-01 Patrick Palka <ppalka@gcc.gnu.org> PR c++/66686 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bb3d636..35191a1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -22535,6 +22535,28 @@ cp_parser_std_attribute (cp_parser *parser) return attribute; } +/* Check that the attribute ATTRIBUTE appears at most once in the + attribute-list ATTRIBUTES. This is enforced for noreturn (7.6.3) + and deprecated (7.6.5). Note that carries_dependency (7.6.4) + isn't implemented yet in GCC. */ + +static void +cp_parser_check_std_attribute (tree attributes, tree attribute) +{ + if (attributes) + { + tree name = get_attribute_name (attribute); + if (is_attribute_p ("noreturn", name) + && lookup_attribute ("noreturn", attributes)) + error ("attribute noreturn can appear at most once " + "in an attribute-list"); + else if (is_attribute_p ("deprecated", name) + && lookup_attribute ("deprecated", attributes)) + error ("attribute deprecated can appear at most once " + "in an attribute-list"); + } +} + /* Parse a list of standard C++-11 attributes. attribute-list: @@ -22557,6 +22579,7 @@ cp_parser_std_attribute_list (cp_parser *parser) break; if (attribute != NULL_TREE) { + cp_parser_check_std_attribute (attributes, attribute); TREE_CHAIN (attribute) = attributes; attributes = attribute; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8f76813..65ce5f9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ +2015-07-01 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/60365 + * g++.dg/cpp0x/gen-attrs-60.C: New. + * g++.dg/cpp1y/attr-deprecated-2.C: Likewise. + 2015-07-01 Jiong Wang <jiong.wang@arm.com> - * lib/target-supports.exp (check_effective_target_aarch64_small_fpic): New function. + * lib/target-supports.exp (check_effective_target_aarch64_small_fpic):New function. * gcc.target/aarch64/pic-small.c: Restrict this test under check_effective_target_aarch64_small_fpic. diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-60.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-60.C new file mode 100644 index 0000000..cb0c31e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-60.C @@ -0,0 +1,4 @@ +// PR c++/60365 +// { dg-do compile { target c++11 } } + +void func [[noreturn, noreturn]] (); // { dg-error "at most once" } diff --git a/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-2.C b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-2.C new file mode 100644 index 0000000..12c75c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/attr-deprecated-2.C @@ -0,0 +1,4 @@ +// PR c++/60365 +// { dg-do compile { target c++14 } } + +void func [[deprecated, deprecated]] (); // { dg-error "at most once" } |