void Sema::ActOnTranslationUnitScope(Scope *S) {
TUScope = S;
PushDeclContext(S, Context.getTranslationUnitDecl());
-
- VAListTagName = PP.getIdentifierInfo("__va_list_tag");
}
Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
= dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
ExternalSema->InitializeSema(*this);
+ // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
+ // will not be able to merge any duplicate __va_list_tag decls correctly.
+ VAListTagName = PP.getIdentifierInfo("__va_list_tag");
+
// Initialize predefined 128-bit integer types, if needed.
if (Context.getTargetInfo().hasInt128Type()) {
// If either of the 128-bit integer types are unavailable to name lookup,
--- /dev/null
+module stdarg [system] {
+ header "stdarg.h" // note: supplied by the compiler
+}
+module va_list_a { header "va_list_a.h" }
+module va_list_b { header "va_list_b.h" }
--- /dev/null
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
+// RUN: -x objective-c-header %s -o %t.pch -emit-pch
+
+// Include the pch, as a sanity check.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
+// RUN: -x objective-c %s -fsyntax-only
+
+// Repeat the previous emit-pch, but not we will have a global module index.
+// For some reason, this results in an identifier for __va_list_tag being
+// emitted into the pch.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -DPREFIX -I %S/Inputs/va_list \
+// RUN: -x objective-c-header %s -o %t.pch -emit-pch
+
+// Include the pch, which now has __va_list_tag in it, which needs to be merged.
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10 -fmodules -fmodules-cache-path=%t \
+// RUN: -fmodules-ignore-macro=PREFIX -I %S/Inputs/va_list -include-pch %t.pch \
+// RUN: -x objective-c %s -fsyntax-only
+
+// rdar://18039719
+
+#ifdef PREFIX
+@import va_list_b;
+#endif