summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-17 04:13:31 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-17 04:13:31 +0000
commit2072fbd77550e5a45e38925f0cbb7bda12de3ebe (patch)
tree79222733252def751f34d69377cda11e763274a2
parent97ea7d6fc932e03843907bc5656ffa685189de99 (diff)
downloadbcm5719-llvm-2072fbd77550e5a45e38925f0cbb7bda12de3ebe.tar.gz
bcm5719-llvm-2072fbd77550e5a45e38925f0cbb7bda12de3ebe.zip
[PCH] Fix bug where we failed to update an identifier for a single token
macro expansion. rdar://10588825 llvm-svn: 146818
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp5
-rw-r--r--clang/test/PCH/single-token-macro.c26
2 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 20ebb40f534..5cd656527bd 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -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/clang/test/PCH/single-token-macro.c b/clang/test/PCH/single-token-macro.c
new file mode 100644
index 00000000000..104dc130f61
--- /dev/null
+++ b/clang/test/PCH/single-token-macro.c
@@ -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
OpenPOWER on IntegriCloud