[cfe-commits] r73408 - in /cfe/trunk: lib/Lex/TokenConcatenation.cpp test/Lexer/token-concat-2.c

Eli Friedman eli.friedman at gmail.com
Mon Jun 15 12:48:50 PDT 2009


Author: efriedma
Date: Mon Jun 15 14:48:50 2009
New Revision: 73408

URL: http://llvm.org/viewvc/llvm-project?rev=73408&view=rev
Log:
PR4395: Don't detect token concatenation in C mode for 
C++-specific tokens.


Added:
    cfe/trunk/test/Lexer/token-concat-2.c
Modified:
    cfe/trunk/lib/Lex/TokenConcatenation.cpp

Modified: cfe/trunk/lib/Lex/TokenConcatenation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenConcatenation.cpp?rev=73408&r1=73407&r2=73408&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/TokenConcatenation.cpp (original)
+++ cfe/trunk/lib/Lex/TokenConcatenation.cpp Mon Jun 15 14:48:50 2009
@@ -192,7 +192,8 @@
     return isalnum(FirstChar) || Tok.is(tok::numeric_constant) ||
     FirstChar == '+' || FirstChar == '-' || FirstChar == '.';
   case tok::period:          // ..., .*, .1234
-    return FirstChar == '.' || isdigit(FirstChar) || FirstChar == '*';
+    return FirstChar == '.' || isdigit(FirstChar) ||
+    (PP.getLangOptions().CPlusPlus && FirstChar == '*');
   case tok::amp:             // &&
     return FirstChar == '&';
   case tok::plus:            // ++
@@ -210,10 +211,11 @@
   case tok::percent:         // %>, %:
     return FirstChar == '>' || FirstChar == ':';
   case tok::colon:           // ::, :>
-    return FirstChar == ':' ||FirstChar == '>';
+    return FirstChar == '>' ||
+    (PP.getLangOptions().CPlusPlus && FirstChar == ':');
   case tok::hash:            // ##, #@, %:%:
     return FirstChar == '#' || FirstChar == '@' || FirstChar == '%';
   case tok::arrow:           // ->*
-    return FirstChar == '*';
+    return PP.getLangOptions().CPlusPlus && FirstChar == '*';
   }
 }

Added: cfe/trunk/test/Lexer/token-concat-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/token-concat-2.c?rev=73408&view=auto

==============================================================================
--- cfe/trunk/test/Lexer/token-concat-2.c (added)
+++ cfe/trunk/test/Lexer/token-concat-2.c Mon Jun 15 14:48:50 2009
@@ -0,0 +1,4 @@
+// RUN: clang-cc -E -x c -o - %s | grep '[.][*]'
+// PR4395
+#define X .*
+X





More information about the cfe-commits mailing list