re PR c++/57532 (operator& broken when used on rvalues)
authorJason Merrill <jason@redhat.com>
Tue, 9 Jul 2013 17:56:14 +0000 (13:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 Jul 2013 17:56:14 +0000 (13:56 -0400)
PR c++/57532
* parser.c (cp_parser_ref_qualifier_opt): Don't tentatively parse
a ref-qualifier in C++98 mode.

From-SVN: r200842

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/parse/ref-qual2.C [new file with mode: 0644]

index aab2844e138fe36135a8261fcd6ff9c9c9235d87..2d6fa73d01178b02d8db6c6b3404fae8490b3ae8 100644 (file)
@@ -1,5 +1,9 @@
 2013-07-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/57532
+       * parser.c (cp_parser_ref_qualifier_opt): Don't tentatively parse
+       a ref-qualifier in C++98 mode.
+
        PR c++/57545
        * pt.c (convert_nontype_argument) [INTEGER_CST]: Force the
        argument to have the exact type of the parameter.
index e2c3c3e95e47dcba81d8e874cc4d8a3066b01784..614cf4364b805e20e014424a6a69ba0792ca1c48 100644 (file)
@@ -17374,6 +17374,10 @@ cp_parser_ref_qualifier_opt (cp_parser* parser)
 {
   cp_ref_qualifier ref_qual = REF_QUAL_NONE;
 
+  /* Don't try to parse bitwise '&' as a ref-qualifier (c++/57532).  */
+  if (cxx_dialect < cxx11 && cp_parser_parsing_tentatively (parser))
+    return ref_qual;
+
   while (true)
     {
       cp_ref_qualifier curr_ref_qual = REF_QUAL_NONE;
diff --git a/gcc/testsuite/g++.dg/parse/ref-qual2.C b/gcc/testsuite/g++.dg/parse/ref-qual2.C
new file mode 100644 (file)
index 0000000..a78597b
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/57532
+
+int main()
+{
+    return (int() & int());
+}