[cfe-commits] [patch] rejects-valid: explicit specialization of redeclaration of a deleted function template

Richard Smith richard at metafoo.co.uk
Fri Jul 13 17:02:58 PDT 2012


1-modify.diff LGTM.

These function names seem to be rather unclear: isDeletedAsWritten means
"is this declaration explicitly deleted?", setDeletedAsWritten means "set
that this declaration is (implicitly or explicitly) deleted". :(

On Mon, Jul 9, 2012 at 9:51 AM, David Blaikie <dblaikie at gmail.com> wrote:

> Ping.
>
> On Mon, Jul 2, 2012 at 9:35 AM, David Blaikie <dblaikie at gmail.com> wrote:
> > Ping.
> >
> > On Tue, Jun 26, 2012 at 11:37 AM, David Blaikie <dblaikie at gmail.com>
> wrote:
> >> 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?
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120713/8633b23d/attachment.html>


More information about the cfe-commits mailing list