[PATCH] [Review Request] PR15466 - clang accepts incorrect explicit instantiation
Serge Pavlov
sepavloff at gmail.com
Thu May 2 05:38:16 PDT 2013
Updated pathch
Hi rsmith,
http://llvm-reviews.chandlerc.com/D731
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D731?vs=1792&id=1797#toc
Files:
include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseDeclCXX.cpp
test/Parser/cxx-template-decl.cpp
Index: include/clang/Basic/DiagnosticParseKinds.td
===================================================================
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -589,6 +589,9 @@
def err_explicit_instantiation_enum : Error<
"enumerations cannot be explicitly instantiated">;
def err_expected_template_parameter : Error<"expected template parameter">;
+def err_template_missing_parameters : Error<
+ "missing template parameter list in %select{class|struct|union|interface}0 "
+ "template definition">;
def err_missing_dependent_template_keyword : Error<
"use 'template' keyword to treat '%0' as a dependent template name">;
Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -1536,6 +1536,14 @@
MultiTemplateParamsArg(
TemplateParams? &(*TemplateParams)[0] : 0,
TemplateParams? TemplateParams->size() : 0));
+ } else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
+ TUK == Sema::TUK_Definition) {
+ if (!TemplateParams)
+ Diag (TemplateInfo.TemplateLoc, diag::err_template_missing_parameters) <<
+ (TagType == DeclSpec::TST_class ? 0
+ : TagType == DeclSpec::TST_struct ? 1
+ : TagType == DeclSpec::TST_union ? 2
+ : 3);
} else {
if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
ProhibitAttributes(attrs);
Index: test/Parser/cxx-template-decl.cpp
===================================================================
--- test/Parser/cxx-template-decl.cpp
+++ test/Parser/cxx-template-decl.cpp
@@ -113,3 +113,15 @@
template <typename T>
void N::bar(typename T::x) { }
}
+
+// PR15466
+template struct pr15466 { int a; }; // expected-error {{missing template parameter list in struct template definition}}
+
+template <class T> struct pr15466a;
+template struct pr15466a { int a; }; // expected-error {{missing template parameter list in struct template definition}}
+
+namespace pr15466b { template <class T> class abc; };
+template class pr15466b::abc { int a; }; // expected-error {{missing template parameter list in class template definition}}
+
+struct pr15466c { template <int N> union abc; };
+template union pr15466c::abc { int a; }; // expected-error {{missing template parameter list in union template definition}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D731.2.patch
Type: text/x-patch
Size: 2536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130502/ea968312/attachment.bin>
More information about the cfe-commits
mailing list