]> granicus.if.org Git - clang/commitdiff
[PCH] Fix bug where we failed to update an identifier for a single token
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 17 Dec 2011 04:13:31 +0000 (04:13 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 17 Dec 2011 04:13:31 +0000 (04:13 +0000)
macro expansion.

rdar://10588825

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146818 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPMacroExpansion.cpp
test/PCH/single-token-macro.c [new file with mode: 0644]

index 20ebb40f534b96f26dfa9a880fcc6dca78838777..5cd656527bd4cecbaff86f7e23ec7966826ec7fa 100644 (file)
@@ -116,6 +116,11 @@ static bool isTrivialSingleTokenExpansion(const MacroInfo *MI,
   // If the token isn't an identifier, it's always literally expanded.
   if (II == 0) return true;
 
+  // If the information about this identifier is out of date, update it from
+  // the external source.
+  if (II->isOutOfDate())
+    PP.getExternalSource()->updateOutOfDateIdentifier(*II);
+
   // If the identifier is a macro, and if that macro is enabled, it may be
   // expanded so it's not a trivial expansion.
   if (II->hasMacroDefinition() && PP.getMacroInfo(II)->isEnabled() &&
diff --git a/test/PCH/single-token-macro.c b/test/PCH/single-token-macro.c
new file mode 100644 (file)
index 0000000..104dc13
--- /dev/null
@@ -0,0 +1,26 @@
+// rdar://10588825
+
+// Test this without pch.
+// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only
+
+// Test with pch.
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only
+
+#ifndef HEADER
+#define HEADER
+
+#define SKATA
+
+#define __stdcall
+#define STDCALL __stdcall
+
+void STDCALL Foo(void);
+
+#else
+
+void STDCALL Foo(void)
+{
+}
+
+#endif