diff mbox

[google,4_7] Backport r194909 (<:: is incorrectly treated as digraph ...) to google/gcc-4_7 branch (issue7028052)

Message ID 20130104173258.9F8B81908AC@elbrus2.mtv.corp.google.com
State New
Headers show

Commit Message

Paul Pluzhnikov Jan. 4, 2013, 5:32 p.m. UTC
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


--
This patch is available for review at http://codereview.appspot.com/7028052

Comments

Xinliang David Li Jan. 4, 2013, 5:41 p.m. UTC | #1
ok.

thanks,

David

On Fri, Jan 4, 2013 at 9:32 AM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> 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
diff mbox

Patch

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;