Hi,

On 01/03/2013 10:56 PM, Jason Merrill wrote:
On 01/03/2013 05:44 AM, Paolo Carlini wrote:
+          /* C++11 - 2.5 p3, bullet 2. */

Please flesh out this comment some more.
Ok, I extended it like this.

Thanks,
Paolo.

/////////////////////
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c     (revision 194884)
+++ gcc/cp/parser.c     (working copy)
@@ -1,6 +1,6 @@
 /* C++ Parser.
    Copyright (C) 2000, 2001, 2002, 2003, 2004,
-   2005, 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+   2005, 2007-2013  Free Software Foundation, Inc.
    Written by Mark Mitchell <m...@codesourcery.com>.
 
    This file is part of GCC.
@@ -12655,11 +12655,9 @@ cp_parser_template_id (cp_parser *parser,
          return error_mark_node;
        }
       /* Otherwise, emit an error about the invalid digraph, but continue
-        parsing because we got our argument list.  In C++11 do not emit
-        any error, per 2.5/3.  */
-      if (cxx_dialect < cxx0x
-         && permerror (next_token->location,
-                       "%<<::%> cannot begin a template-argument list"))
+        parsing because we got our argument list.  */
+      if (permerror (next_token->location,
+                    "%<<::%> cannot begin a template-argument list"))
        {
          static bool hint = false;
          inform (next_token->location,
Index: gcc/testsuite/g++.dg/cpp0x/parse2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/parse2.C (revision 194884)
+++ gcc/testsuite/g++.dg/cpp0x/parse2.C (working copy)
@@ -10,3 +10,6 @@ int main()
 {
   X<::A> x;
 }
+
+int a;
+bool b = 0<::a;
Index: gcc/testsuite/g++.old-deja/g++.other/crash28.C
===================================================================
--- gcc/testsuite/g++.old-deja/g++.other/crash28.C      (revision 194884)
+++ gcc/testsuite/g++.old-deja/g++.other/crash28.C      (working copy)
@@ -31,5 +31,5 @@ class foo
 };
 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 194884)
+++ libcpp/lex.c        (working copy)
@@ -1,6 +1,6 @@
 /* CPP Library - lexical analysis.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
-   2011, 2012 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007-2013
+   Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -2290,6 +2290,17 @@ _cpp_lex_direct (cpp_reader *pfile)
        {
          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;

Reply via email to