After r166977, we are wrongly rejecting:
struct {} && m = {};
because our code to diagnose a missing ; after a class definition doesn't
realize that && can follow a class definition.
This is simlar in nature to what was done for `::` in
r12-8304-g851031b2fcd5210b9676.
Bootstrapped and tested on x86_64-linux-gnu.
Changes since v1:
* v2: Remove the check on c++11 and add a few more testcases.
* v3: Move CPP_AND_AND right below CPP_AND_AND and add enum case to the
testcase.
PR c++/65271
gcc/cp/ChangeLog:
* parser.cc (cp_parser_class_specifier): Accept &&.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/rv-decl1.C: New test.
Signed-off-by: Andrew Pinski <[email protected]>
(cherry picked from commit 44c5485dac70d7f0d62e880b1162d49805404ed8)
---
gcc/cp/parser.cc | 1 +
gcc/testsuite/g++.dg/cpp0x/rv-decl1.C | 7 +++++++
2 files changed, 8 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-decl1.C
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index f44450519ae..d52f5c97039 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -29826,6 +29826,7 @@ cp_parser_class_specifier (cp_parser* parser)
case CPP_SEMICOLON:
case CPP_MULT:
case CPP_AND:
+ case CPP_AND_AND:
case CPP_OPEN_PAREN:
case CPP_CLOSE_PAREN:
case CPP_COMMA:
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-decl1.C
b/gcc/testsuite/g++.dg/cpp0x/rv-decl1.C
new file mode 100644
index 00000000000..16c4cb31959
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-decl1.C
@@ -0,0 +1,7 @@
+// PR c++/65271
+// { dg-do compile { target c++11 } }
+
+struct {} && m0 = {};
+union {} && m1 = {};
+class {} && m2 = {};
+enum {} && m3 = {};
--
2.43.0