diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 16 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 5 | ||||
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 12 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/p5.cpp | 3 |
4 files changed, 24 insertions, 12 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 1d3239b3d4..aca160632f 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -1824,26 +1824,26 @@ def note_template_parameter_pack_here : Note< def err_unexpanded_parameter_pack_0 : Error< "%select{expression|base type|declaration type|data member type|bit-field " "size|static assertion|fixed underlying type|enumerator value|" - "using declaration|friend declaration|qualifier|initializer|default argument" - "}0 " + "using declaration|friend declaration|qualifier|initializer|default argument|" + "non-type template parameter type}0 " "contains an unexpanded parameter pack">; def err_unexpanded_parameter_pack_1 : Error< "%select{expression|base type|declaration type|data member type|bit-field " "size|static assertion|fixed underlying type|enumerator value|" - "using declaration|friend declaration|qualifier|initializer|default argument" - "}0 " + "using declaration|friend declaration|qualifier|initializer|default argument|" + "non-type template parameter type}0 " "contains unexpanded parameter pack %1">; def err_unexpanded_parameter_pack_2 : Error< "%select{expression|base type|declaration type|data member type|bit-field " "size|static assertion|fixed underlying type|enumerator value|" - "using declaration|friend declaration|qualifier|initializer|default argument" - "}0 " + "using declaration|friend declaration|qualifier|initializer|default argument|" + "non-type template parameter type}0 " "contains unexpanded parameter packs %1 and %2">; def err_unexpanded_parameter_pack_3_or_more : Error< "%select{expression|base type|declaration type|data member type|bit-field " "size|static assertion|fixed underlying type|enumerator value|" - "using declaration|friend declaration|qualifier|initializer|default argument" - "}0 " + "using declaration|friend declaration|qualifier|initializer|default argument|" + "non-type template parameter type}0 " "contains unexpanded parameter packs %1, %2, ...">; def err_unexpected_typedef : Error< diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index db0faa806d..e2aa49cbe8 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -3172,7 +3172,10 @@ public: UPPC_Initializer, /// \brief A default argument. - UPPC_DefaultArgument + UPPC_DefaultArgument, + + /// \brief The type of a non-type template parameter. + UPPC_NonTypeTemplateParameterType }; /// \brief If the given type contains an unexpanded parameter pack, diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index a79c17cdbf..f94f34626d 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -626,12 +626,18 @@ Decl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, PrevDecl); } - T = CheckNonTypeTemplateParameterType(T, D.getIdentifierLoc()); - if (T.isNull()) { + if (DiagnoseUnexpandedParameterPack(D.getIdentifierLoc(), TInfo, + UPPC_NonTypeTemplateParameterType)) { T = Context.IntTy; // Recover with an 'int' type. Invalid = true; + } else { + T = CheckNonTypeTemplateParameterType(T, D.getIdentifierLoc()); + if (T.isNull()) { + T = Context.IntTy; // Recover with an 'int' type. + Invalid = true; + } } - + NonTypeTemplateParmDecl *Param = NonTypeTemplateParmDecl::Create(Context, Context.getTranslationUnitDecl(), D.getIdentifierLoc(), diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index 2352234f86..e277219ca4 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -141,6 +141,9 @@ struct TestUnexpandedDecls : T{ struct default_template_args_2; template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} struct default_template_args_3; + + template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}} + struct non_type_template_param_type; }; // Test for diagnostics in the presence of multiple unexpanded |