diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5fb94e1d4403..77e5087b8c73 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -6389,6 +6389,7 @@ CreateAAPCSABIBuiltinVaListDecl(const ASTContext *Context) { // }; VaListDecl->completeDefinition(); + Context->VaListTagDecl = VaListDecl; // typedef struct __va_list __builtin_va_list; QualType T = Context->getRecordType(VaListDecl); diff --git a/clang/test/PCH/Inputs/__va_list_tag-typedef.h b/clang/test/PCH/Inputs/__va_list_tag-typedef.h new file mode 100644 index 000000000000..33dc6ad48425 --- /dev/null +++ b/clang/test/PCH/Inputs/__va_list_tag-typedef.h @@ -0,0 +1,4 @@ +// Header for PCH test __va_list_tag-typedef.c + +#include +typedef va_list va_list_1; diff --git a/clang/test/PCH/__va_list_tag-typedef.c b/clang/test/PCH/__va_list_tag-typedef.c new file mode 100644 index 000000000000..c3745ca2cb8c --- /dev/null +++ b/clang/test/PCH/__va_list_tag-typedef.c @@ -0,0 +1,14 @@ +// This test checks the patch for the compilation error / crash described in D18557. + +// Test as a C source +// RUN: %clang_cc1 -emit-pch -x c-header -o %t %S/Inputs/__va_list_tag-typedef.h +// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s + +// Test as a C++ source +// RUN: %clang_cc1 -emit-pch -x c++-header -o %t %S/Inputs/__va_list_tag-typedef.h +// RUN: %clang_cc1 -x c++ -fsyntax-only -include-pch %t %s + +// expected-no-diagnostics + +typedef __builtin_va_list va_list_2; +void test(const char* format, ...) { va_list args; va_start( args, format ); }