[PATCH] Fix PR19169:Crash on invalid attempting to specialize a template method as a template variable
Richard Smith
richard at metafoo.co.uk
Tue May 6 14:08:13 PDT 2014
================
Comment at: lib/Sema/SemaTemplate.cpp:2431
@@ +2430,3 @@
+ else {
+ if (OverloadedTemplateStorage *OST = Name.getAsOverloadedTemplate()) {
+ OverloadedTemplateStorage::iterator I = OST->begin();
----------------
Please fold the two cases together:
NamedDecl *FnTemplate;
if (auto *OTS = Name.getAsOverloadedTemplate())
FnTemplate = *OTS->begin();
else
FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
if (FnTemplate)
// ...
================
Comment at: lib/Sema/SemaTemplate.cpp:2432-2434
@@ +2431,5 @@
+ if (OverloadedTemplateStorage *OST = Name.getAsOverloadedTemplate()) {
+ OverloadedTemplateStorage::iterator I = OST->begin();
+ OverloadedTemplateStorage::iterator IEnd = OST->end();
+ if (I != IEnd) {
+ return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template_but_method)
----------------
This check seems unnecessary; if we have an overloaded template name then by definition there are two or more function templates in the storage.
http://reviews.llvm.org/D3198
More information about the cfe-commits
mailing list