aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-08-07 17:32:12 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-08-07 17:32:12 +0000
commit842901d0ca0baa25ea510089a21162a6e8ae8f29 (patch)
tree5a8afe56299429972de78b7dcff8b844ddb47e4c
parentc822ac7daa0d0c920bbb87cdba847fed6331ba73 (diff)
downloadgcc-842901d0ca0baa25ea510089a21162a6e8ae8f29.zip
gcc-842901d0ca0baa25ea510089a21162a6e8ae8f29.tar.gz
gcc-842901d0ca0baa25ea510089a21162a6e8ae8f29.tar.bz2
PR c++/81429 - wrong parsing of constructor with C++11 attribute.
* parser.c (cp_parser_constructor_declarator_p): Handle the scenario when a parameter declaration begins with [[attribute]]. * g++.dg/cpp0x/gen-attrs-68.C: New test. * g++.dg/cpp0x/gen-attrs-69.C: New test. From-SVN: r274181
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C40
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C40
5 files changed, 95 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 64714e0..bae5147 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2019-08-07 Marek Polacek <polacek@redhat.com>
+ PR c++/81429 - wrong parsing of constructor with C++11 attribute.
+ * parser.c (cp_parser_constructor_declarator_p): Handle the scenario
+ when a parameter declaration begins with [[attribute]].
+
+2019-08-07 Marek Polacek <polacek@redhat.com>
+
PR c++/91346 - Implement P1668R1, allow unevaluated asm in constexpr.
* constexpr.c (cxx_eval_constant_expression): Handle ASM_EXPR.
(potential_constant_expression_1) <case ASM_EXPR>: Allow.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ccf89f0..14b7240 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -27857,7 +27857,9 @@ cp_parser_constructor_declarator_p (cp_parser *parser, cp_parser_flags flags,
/* A parameter declaration begins with a decl-specifier,
which is either the "attribute" keyword, a storage class
specifier, or (usually) a type-specifier. */
- && !cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer))
+ && !cp_lexer_next_token_is_decl_specifier_keyword (parser->lexer)
+ /* A parameter declaration can also begin with [[attribute]]. */
+ && !cp_next_tokens_can_be_std_attribute_p (parser))
{
tree type;
tree pushed_scope = NULL_TREE;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f2e6afc..e69e59b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,11 @@
2019-08-07 Marek Polacek <polacek@redhat.com>
+ PR c++/81429 - wrong parsing of constructor with C++11 attribute.
+ * g++.dg/cpp0x/gen-attrs-68.C: New test.
+ * g++.dg/cpp0x/gen-attrs-69.C: New test.
+
+2019-08-07 Marek Polacek <polacek@redhat.com>
+
PR c++/91346 - Implement P1668R1, allow unevaluated asm in constexpr.
* g++.dg/cpp2a/inline-asm1.C: New test.
* g++.dg/cpp2a/inline-asm2.C: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C
new file mode 100644
index 0000000..6bede06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-68.C
@@ -0,0 +1,40 @@
+// PR c++/81429 - wrong parsing of constructor with C++11 attribute.
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wunused-parameter -Wno-pedantic" }
+
+void fn1([[maybe_unused]] int a) { }
+void fn2(int a [[maybe_unused]]) { }
+void fn3(__attribute__((unused)) int a) { }
+void fn4(int a __attribute__((unused))) { }
+
+struct S1 {
+ S1([[maybe_unused]] int a) { }
+};
+
+struct S2 {
+ S2([[maybe_unused]] int f, [[maybe_unused]] int a) { }
+};
+
+struct S3 {
+ S3(int a [[maybe_unused]]) { }
+};
+
+struct S4 {
+ S4(int f [[maybe_unused]], int a [[maybe_unused]]) { }
+};
+
+struct S5 {
+ S5(__attribute__((unused)) int a) { }
+};
+
+struct S6 {
+ S6(__attribute__((unused)) int f, __attribute__((unused)) int a) { }
+};
+
+struct S7 {
+ S7(int a __attribute__((unused))) { }
+};
+
+struct S8 {
+ S8(int f __attribute__((unused)), int a __attribute__((unused))) { }
+};
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C
new file mode 100644
index 0000000..43173db
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-69.C
@@ -0,0 +1,40 @@
+// PR c++/81429 - wrong parsing of constructor with C++11 attribute.
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-Wno-pedantic" }
+
+void fn1([[maybe_unused]] int);
+void fn2(int a [[maybe_unused]]);
+void fn3(__attribute__((unused)) int);
+void fn4(int __attribute__((unused)));
+
+struct S1 {
+ S1([[maybe_unused]] int);
+};
+
+struct S2 {
+ S2([[maybe_unused]] int, [[maybe_unused]] int);
+};
+
+struct S3 {
+ S3(int a [[maybe_unused]]);
+};
+
+struct S4 {
+ S4(int a [[maybe_unused]], int b [[maybe_unused]]);
+};
+
+struct S5 {
+ S5(__attribute__((unused)) int);
+};
+
+struct S6 {
+ S6(__attribute__((unused)) int, __attribute__((unused)) int);
+};
+
+struct S7 {
+ S7(int __attribute__((unused)));
+};
+
+struct S8 {
+ S8(int __attribute__((unused)), int __attribute__((unused)));
+};