From f9997a0834e0e0298b04ef044ad2699c727a7979 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 1 Feb 2011 15:24:58 +0000 Subject: [PATCH] Fix a thinko where I didn't update a consistency check for PackExpansionType in the AST reader. We need more testing for variadic templates + PCH, but this fixes PR9073. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124662 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Serialization/ASTReader.cpp | 2 +- test/PCH/cxx-variadic-templates.cpp | 11 +++++++++++ test/PCH/cxx-variadic-templates.h | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/PCH/cxx-variadic-templates.cpp create mode 100644 test/PCH/cxx-variadic-templates.h diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 1e07e76314..f8f281d999 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2964,7 +2964,7 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) { } case TYPE_PACK_EXPANSION: { - if (Record.size() != 1) { + if (Record.size() != 2) { Error("incorrect encoding of pack expansion type"); return QualType(); } diff --git a/test/PCH/cxx-variadic-templates.cpp b/test/PCH/cxx-variadic-templates.cpp new file mode 100644 index 0000000000..9b1df9a737 --- /dev/null +++ b/test/PCH/cxx-variadic-templates.cpp @@ -0,0 +1,11 @@ +// Test this without pch. +// RUN: %clang_cc1 -std=c++0x -include %S/cxx-variadic-templates.h -verify %s -ast-dump -o - +// RUN: %clang_cc1 -std=c++0x -include %S/cxx-variadic-templates.h %s -emit-llvm -o - | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -std=c++0x -x c++-header -emit-pch -o %t %S/cxx-variadic-templates.h +// RUN: %clang_cc1 -std=c++0x -include-pch %t -verify %s -ast-dump -o - +// RUN: %clang_cc1 -std=c++0x -include-pch %t %s -emit-llvm -o - | FileCheck %s + +// CHECK: allocate_shared +shared_ptr spi = shared_ptr::allocate_shared(1, 2); diff --git a/test/PCH/cxx-variadic-templates.h b/test/PCH/cxx-variadic-templates.h new file mode 100644 index 0000000000..f6ee7876c2 --- /dev/null +++ b/test/PCH/cxx-variadic-templates.h @@ -0,0 +1,18 @@ +// PR9073 +template +class shared_ptr{ +public: + template + static + shared_ptr<_Tp> + allocate_shared(const _Alloc& __a, _Args&& ...__args); +}; + +template +template +shared_ptr<_Tp> +shared_ptr<_Tp>::allocate_shared(const _Alloc& __a, _Args&& ...__args) +{ + shared_ptr<_Tp> __r; + return __r; +} -- 2.40.0