Fix PR4006, incorrect handling of __VA_ARGS__ when it was the first token
in a function-like macro body.  This has the added bonus of moving some
function-like macro specific code out of the object-like macro codepath.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69530 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index e0bd5a1..15477b6 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/lib/Lex/PPDirectives.cpp
@@ -1306,6 +1306,15 @@
       return;
     }
 
+    // If this is a definition of a variadic C99 function-like macro, not using
+    // the GNU named varargs extension, enabled __VA_ARGS__.
+    
+    // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.
+    // This gets unpoisoned where it is allowed.
+    assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned!");
+    if (MI->isC99Varargs())
+      Ident__VA_ARGS__->setIsPoisoned(false);
+    
     // Read the first token after the arg list for down below.
     LexUnexpandedToken(Tok);
   } else if (Features.C99) {
@@ -1334,15 +1343,6 @@
       Diag(Tok, diag::warn_missing_whitespace_after_macro_name);
   }
   
-  // If this is a definition of a variadic C99 function-like macro, not using
-  // the GNU named varargs extension, enabled __VA_ARGS__.
-  
-  // "Poison" __VA_ARGS__, which can only appear in the expansion of a macro.
-  // This gets unpoisoned where it is allowed.
-  assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned!");
-  if (MI->isC99Varargs())
-    Ident__VA_ARGS__->setIsPoisoned(false);
-  
   // Read the rest of the macro body.
   if (MI->isObjectLike()) {
     // Object-like macros are very simple, just read their body.