[cfe-commits] r69536 - /cfe/trunk/lib/Lex/TokenLexer.cpp

Chris Lattner sabre at nondot.org
Sun Apr 19 13:06:34 PDT 2009


Author: lattner
Date: Sun Apr 19 15:06:32 2009
New Revision: 69536

URL: http://llvm.org/viewvc/llvm-project?rev=69536&view=rev
Log:
Fix PR3918: Invalid use of __VA_ARGS__ not diagnosed,
by rejecting invalid poisoned tokens in the token
pasting path.

Modified:
    cfe/trunk/lib/Lex/TokenLexer.cpp

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

==============================================================================
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Sun Apr 19 15:06:32 2009
@@ -457,7 +457,6 @@
       // operator.
       if (Result.is(tok::hashhash))
         Result.setKind(tok::unknown);
-      // FIXME: Turn __VA_ARGS__ into "not a token"?
     }
       
     // Transfer properties of the LHS over the the Result.
@@ -475,7 +474,19 @@
   if (Tok.is(tok::identifier)) {
     // Look up the identifier info for the token.  We disabled identifier lookup
     // by saying we're skipping contents, so we need to do this manually.
-    Tok.setIdentifierInfo(PP.LookUpIdentifierInfo(Tok, ResultTokStrPtr));
+    IdentifierInfo *II = PP.LookUpIdentifierInfo(Tok, ResultTokStrPtr);
+    Tok.setIdentifierInfo(II);
+    
+    // If this identifier was poisoned, emit an error.  This won't be handled by
+    // Preprocessor::HandleIdentifier because this is coming from a macro
+    // expansion.
+    if (II->isPoisoned()) {
+      // We warn about __VA_ARGS__ with poisoning.
+      if (II->isStr("__VA_ARGS__"))
+        PP.Diag(Tok, diag::ext_pp_bad_vaargs_use);
+      else
+        PP.Diag(Tok, diag::err_pp_used_poisoned_id);
+    }
   }
   return false;
 }





More information about the cfe-commits mailing list