[cfe-commits] r38769 - /cfe/cfe/trunk/Lex/Preprocessor.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:24:28 PDT 2007


Author: sabre
Date: Wed Jul 11 11:24:28 2007
New Revision: 38769

URL: http://llvm.org/viewvc/llvm-project?rev=38769&view=rev
Log:
If the varargs token is missing, add an empty argument to represent it.  This
fixes Preprocessor/macro_fn_varargs_named.c

Modified:
    cfe/cfe/trunk/Lex/Preprocessor.cpp

Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38769&r1=38768&r2=38769&view=diff

==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:24:28 2007
@@ -795,16 +795,7 @@
     } else if (MI->getNumArgs() == 1) {
       // #define A(x)
       //   A()
-      // is ok because it is an empty argument.  Add it explicitly.
-      
-      
-      // Add a marker EOF token to the end of the token list for this argument.
-      SourceLocation EndLoc = Tok.getLocation();
-      Tok.StartToken();
-      Tok.SetKind(tok::eof);
-      Tok.SetLocation(EndLoc);
-      Tok.SetLength(0);
-      ArgTokens.push_back(Tok);
+      // is ok because it is an empty argument.
       
       // Empty arguments are standard in C99 and supported as an extension in
       // other modes.
@@ -815,6 +806,14 @@
       Diag(Tok, diag::err_too_few_args_in_macro_invoc);
       return 0;
     }
+    
+    // Add a marker EOF token to the end of the token list for this argument.
+    SourceLocation EndLoc = Tok.getLocation();
+    Tok.StartToken();
+    Tok.SetKind(tok::eof);
+    Tok.SetLocation(EndLoc);
+    Tok.SetLength(0);
+    ArgTokens.push_back(Tok);
   }
   
   return MacroArgs::create(MI, &ArgTokens[0], ArgTokens.size());





More information about the cfe-commits mailing list