[PATCH] [Review Request] PR15466 - clang accepts incorrect explicit instantiation

Richard Smith richard at metafoo.co.uk
Wed May 1 09:59:09 PDT 2013



================
Comment at: include/clang/Basic/DiagnosticParseKinds.td:592
@@ -591,2 +591,3 @@
 def err_expected_template_parameter : Error<"expected template parameter">;
+def err_missed_templ_params : Error<"template parameter list is missed">;
 
----------------
Maybe "missing template parameter list in %select{class|struct|union}0 template definition", and rename to something like err_template_missing_parameters. But... if the 'template' keyword is just spurious here, this might still be confusing. Maybe we should just say "unexpected 'template' keyword before %select{class|struct|union}0 definition"?

================
Comment at: lib/Parse/ParseDeclCXX.cpp:1541-1542
@@ -1539,1 +1540,4 @@
+             TUK == Sema::TUK_Definition) {
+    if (!TemplateParams)
+      Diag (TemplateInfo.TemplateLoc, diag::err_missed_templ_params);
   } else {
----------------
Is it possible for TemplateParams to be non-null for an ExplicitInstantiation?

If we expect this to happen due to a missing template parameter list, we're not going to recover very well here -- the class body is going to have a bunch of undeclared identifiers in it, and later uses of the class template are going to hit parse errors, because we won't treat the class name as a template name.


http://llvm-reviews.chandlerc.com/D731



More information about the cfe-commits mailing list