Patch for handling C99 veriadic macros when using precompiled headers,

from Filipe Cabecinhas!

llvm-svn: 159446
This commit is contained in:
Douglas Gregor 2012-06-29 18:27:59 +00:00
parent 4a031bdc8f
commit 3f568c100e
3 changed files with 18 additions and 0 deletions

View File

@ -515,9 +515,19 @@ void Preprocessor::HandleIdentifier(Token &Identifier) {
// If the information about this identifier is out of date, update it from
// the external source.
// We have to treat __VA_ARGS__ in a special way, since it gets
// serialized with isPoisoned = true, but our preprocessor may have
// unpoisoned it if we're defining a C99 macro.
if (II.isOutOfDate()) {
bool CurrentIsPoisoned = false;
if (&II == Ident__VA_ARGS__)
CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
ExternalSource->updateOutOfDateIdentifier(II);
Identifier.setKind(II.getTokenID());
if (&II == Ident__VA_ARGS__)
II.setIsPoisoned(CurrentIsPoisoned);
}
// If this identifier was poisoned, and if it was not produced from a macro

View File

@ -0,0 +1,6 @@
// Test with pch.
// RUN: %clang_cc1 -emit-pch -o %t %S/pch__VA_ARGS__.h
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -Weverything %s 2>&1 | FileCheck %s
#define mylog(...) printf(__VA_ARGS__)
// CHECK-NOT: warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro

View File

@ -0,0 +1,2 @@
// Header for PCH test fuzzy-pch.c
void f(int X);