Back-port revision 194909 to google/gcc-4_7 branch:
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194909
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54526
Google ref: b/7427993
Index: gcc/testsuite/g++.old-deja/g++.other/crash28.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.other/crash28.C (revision 194909)
+++ gcc/testsuite/g++.old-deja/g++.other/crash28.C (working copy)
@@ -31,5 +31,5 @@
};
void foo::x() throw(bar)
{
- if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda
expressions|expected" } parse error
+ if (!b) throw bar (static_cast<::N::X*>(this)); // { dg-error "lambda
expressions|expected|invalid" } parse error
}
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c (revision 194909)
+++ libcpp/lex.c (working copy)
@@ -2224,6 +2224,17 @@
{
if (*buffer->cur == ':')
{
+ /* C++11 [2.5/3 lex.pptoken], "Otherwise, if the next
+ three characters are <:: and the subsequent character
+ is neither : nor >, the < is treated as a preprocessor
+ token by itself". */
+ if (CPP_OPTION (pfile, cplusplus)
+ && (CPP_OPTION (pfile, lang) == CLK_CXX11
+ || CPP_OPTION (pfile, lang) == CLK_GNUCXX11)
+ && buffer->cur[1] == ':'
+ && buffer->cur[2] != ':' && buffer->cur[2] != '>')
+ break;
+
buffer->cur++;
result->flags |= DIGRAPH;
result->type = CPP_OPEN_SQUARE;
--
This patch is available for review at http://codereview.appspot.com/7028052