[cfe-commits] r159446 - in /cfe/trunk: lib/Lex/Preprocessor.cpp test/PCH/pch__VA_ARGS__.c test/PCH/pch__VA_ARGS__.h
Douglas Gregor
dgregor at apple.com
Fri Jun 29 11:27:59 PDT 2012
Author: dgregor
Date: Fri Jun 29 13:27:59 2012
New Revision: 159446
URL: http://llvm.org/viewvc/llvm-project?rev=159446&view=rev
Log:
Patch for handling C99 veriadic macros when using precompiled headers,
from Filipe Cabecinhas!
Added:
cfe/trunk/test/PCH/pch__VA_ARGS__.c
cfe/trunk/test/PCH/pch__VA_ARGS__.h
Modified:
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=159446&r1=159445&r2=159446&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Jun 29 13:27:59 2012
@@ -515,9 +515,19 @@
// 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
Added: cfe/trunk/test/PCH/pch__VA_ARGS__.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pch__VA_ARGS__.c?rev=159446&view=auto
==============================================================================
--- cfe/trunk/test/PCH/pch__VA_ARGS__.c (added)
+++ cfe/trunk/test/PCH/pch__VA_ARGS__.c Fri Jun 29 13:27:59 2012
@@ -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
Added: cfe/trunk/test/PCH/pch__VA_ARGS__.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pch__VA_ARGS__.h?rev=159446&view=auto
==============================================================================
--- cfe/trunk/test/PCH/pch__VA_ARGS__.h (added)
+++ cfe/trunk/test/PCH/pch__VA_ARGS__.h Fri Jun 29 13:27:59 2012
@@ -0,0 +1,2 @@
+// Header for PCH test fuzzy-pch.c
+void f(int X);
More information about the cfe-commits
mailing list