[cfe-commits] r121964 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaTemplate.cpp test/CXX/temp/temp.decls/temp.variadic/p5.cpp
Douglas Gregor
dgregor at apple.com
Thu Dec 16 00:56:23 PST 2010
Author: dgregor
Date: Thu Dec 16 02:56:23 2010
New Revision: 121964
URL: http://llvm.org/viewvc/llvm-project?rev=121964&view=rev
Log:
Check for unexpanded parameter packs in non-type template parameter types.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=121964&r1=121963&r2=121964&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Dec 16 02:56:23 2010
@@ -1824,26 +1824,26 @@
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<
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=121964&r1=121963&r2=121964&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec 16 02:56:23 2010
@@ -3172,7 +3172,10 @@
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,
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=121964&r1=121963&r2=121964&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Dec 16 02:56:23 2010
@@ -626,12 +626,18 @@
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(),
Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp?rev=121964&r1=121963&r2=121964&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.variadic/p5.cpp Thu Dec 16 02:56:23 2010
@@ -141,6 +141,9 @@
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
More information about the cfe-commits
mailing list