diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-12-15 21:57:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-12-15 21:57:59 +0000 |
commit | cff163e3cc78277496b30fa40070b46abdc290db (patch) | |
tree | 64b5a13def2d80adb22477ededecd0dedbf900be | |
parent | 9ef75899bae6dd9a4be1252ae9cadcb619c170ff (diff) |
Test that all of the relevant types properly compute the "contains
unexpanded parameter pack" bit and that the recursive AST visitor can
then find those unexpanded parameter packs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121899 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaTemplateVariadic.cpp | 11 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 92 |
2 files changed, 97 insertions, 6 deletions
diff --git a/lib/Sema/SemaTemplateVariadic.cpp b/lib/Sema/SemaTemplateVariadic.cpp index 677b14635f..057792914b 100644 --- a/lib/Sema/SemaTemplateVariadic.cpp +++ b/lib/Sema/SemaTemplateVariadic.cpp @@ -103,9 +103,14 @@ namespace { return true; } - /// \brief Suppress traversal of declarations, since they cannot - /// contain unexpanded parameter packs. - bool TraverseDecl(Decl *D) { return true; } + /// \brief Suppress traversal of non-parameter declarations, since + /// they cannot contain unexpanded parameter packs. + bool TraverseDecl(Decl *D) { + if (D && isa<ParmVarDecl>(D)) + return inherited::TraverseDecl(D); + + return true; + } }; } diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index fa2c2dcb2e..760dc342db 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -1,13 +1,99 @@ -// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++0x -fblocks -fsyntax-only -verify %s // An appearance of a name of a parameter pack that is not expanded is // ill-formed. -template<typename ... Types> + +template<typename T, typename U> struct pair; + +// Test for unexpanded parameter packs in each of the type nodes. +template<typename T, int N, typename ... Types> struct TestPPName - : public Types // expected-error{{base type contains unexpanded parameter pack 'Types'}} + : public Types, public T // expected-error{{base type contains unexpanded parameter pack 'Types'}} { + // BuiltinType is uninteresting + // FIXME: ComplexType is uninteresting? + // PointerType typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // BlockPointerType + typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // LValueReferenceType + typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // RValueReferenceType + typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // MemberPointerType + typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // ConstantArrayType + typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // IncompleteArrayType + typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // VariableArrayType + void f(int i) { + Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + } + + // DependentSizedArrayType + typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // DependentSizedExtVectorType + typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // VectorType is uninteresting + + // ExtVectorType + typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // FunctionProtoType + typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // FunctionNoProtoType is uninteresting + // UnresolvedUsingType is uninteresting + // ParenType is uninteresting + // TypedefType is uninteresting + + // TypeOfExprType + typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // TypeOfType + typedef __typeof__(Types) typeof_type; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // DecltypeType + typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // RecordType is uninteresting + // EnumType is uninteresting + // ElaboratedType is uninteresting + + // TemplateTypeParmType + typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // SubstTemplateTypeParmType is uninteresting + + // TemplateSpecializationType + typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // InjectedClassName is uninteresting. + + // DependentNameType + typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // DependentTemplateSpecializationType + typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + + // ObjCObjectType is uninteresting + // ObjCInterfaceType is uninteresting + // ObjCObjectPointerType is uninteresting }; template<typename ... Types> |