From 9a3970ddfc50ed831d621c77a0b2157700302fa8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 9 Jul 2013 13:56:14 -0400 Subject: [PATCH] re PR c++/57532 (operator& broken when used on rvalues) 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 | 4 ++++ gcc/cp/parser.c | 4 ++++ gcc/testsuite/g++.dg/parse/ref-qual2.C | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/parse/ref-qual2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index aab2844e138..2d6fa73d011 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-07-09 Jason Merrill + 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. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e2c3c3e95e4..614cf4364b8 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 00000000000..a78597b0cd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ref-qual2.C @@ -0,0 +1,6 @@ +// PR c++/57532 + +int main() +{ + return (int() & int()); +}