The following code is (incorrectly) rejected:

template<typename> void foo() = delete;
template<typename> void foo(); // remove this line & the error is not produced
template void foo<int>(); // "explicit instantiation of undefined
function template 'foo'"

There's a few ways to fix this & I'm not sure which one is preferred:

1) Correct the first 3 lines of
TemplateDeclInstantiator::InitFunctionInstantiation:

  if (Tmpl->isDeletedAsWritten())
    New->setDeletedAsWritten()

to

  if (Tmpl->isDeleted())
    New->setDeletedAsWritten()

In this way, the implicit specialization will always correctly reflect
the fact that it's deleted and intervening redeclarations won't
confuse/break this invariant.

2) Remove the first 3 lines of
TemplateDeclInstantiator::InitFunctionInstantiator. Since we're only
instantiating the declaration, one could argue that it shouldn't be
prematurely turned into a definition just because it's deleted
(conversely: = delete has to be the first declaration, so having a
declaration that isn't an = delete definition is also a bit
questionable). In this case we'd need to also fix line
SemaTemplateInstantiateDecl:2572 (SemaInstantiateFunctionDefinition)
to test "IsDefined()" not just "IsDefaulted()". If that's the way
we're going to deal with deleted templates, we could go & change
SemaTemplateInstantiateDecl.cpp:1537 for member functions to match
this too (hmm, actually removing the setDefaulted/setDeleted calls
does cause at least one test to fail, so I'd have to poke around more
if I was going to do that)

Any thoughts/preferences?

Attachment: 2-remove.diff
Description: Binary data

Attachment: 1-modify.diff
Description: Binary data

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to