[PATCH] PR12262 - assertion when substituting explicit template arguments does not substitute a sizeof-pack expression.
Richard Smith
richard at metafoo.co.uk
Wed Jul 10 22:42:50 PDT 2013
> http://llvm-reviews.chandlerc.com/D869
Here's a different approach that addresses the bug (plus all
duplicates, plus my non-type pack case):
Index: lib/Sema/SemaTemplateInstantiate.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiate.cpp (revision 186060)
+++ lib/Sema/SemaTemplateInstantiate.cpp (working copy)
@@ -2700,6 +2700,12 @@
break;
}
+ // If we're performing a partial substitution during template argument
+ // deduction, we may not have values for template parameters yet.
+ if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
+ isa<TemplateTemplateParmDecl>(D))
+ return 0;
+
// If we didn't find the decl, then we either have a sema bug, or we have a
// forward reference to a label declaration. Return null to indicate that
// we have an uninstantiated label.
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiateDecl.cpp (revision 186060)
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp (working copy)
@@ -3588,6 +3588,13 @@
return cast<NamedDecl>((*Found->get<DeclArgumentPack *>())[PackIdx]);
}
+ // If we're performing a partial substitution during template argument
+ // deduction, we may not have values for template parameters yet. They
+ // just map to themselves.
+ if (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
+ isa<TemplateTemplateParmDecl>(D))
+ return D;
+
// If we didn't find the decl, then we must have a label decl that hasn't
// been found yet. Lazily instantiate it and return it now.
assert(isa<LabelDecl>(D));
It might be cleaner to teach template argument deduction to add
mappings from the unknown template parameters to themselves during its
partial substitution, but in any case, there's no need to clone them.
More information about the cfe-commits
mailing list