This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/57532 (bogus error with int() & int())

In C++98 mode we were complaining about trying to apply a ref-qualifier to the function type int() during tentative parsing; the easiest fix is just not to try to tentatively parse ref-qualifiers in C++98 mode, which also lets us fail the tentative parse faster.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit 7d3bb96439735e08dd02af1e6d031b9a676dacb3
Author: Jason Merrill <>
Date:   Tue Jul 9 02:34:46 2013 -0400

    	PR c++/57532
    	* parser.c (cp_parser_ref_qualifier_opt): Don't tentatively parse
    	a ref-qualifier in C++98 mode.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e2c3c3e..614cf43 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
index 0000000..a78597b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/ref-qual2.C
@@ -0,0 +1,6 @@
+// PR c++/57532
+int main()
+    return (int() & int());

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]