<div dir="ltr"><div>> One side of this interface is wrong<br></div>Any reasons for handling this in Sema instead of Parser?<br><div><br></div><div>The following (in ParseUnqualifiedId) seems to work:<br><br>      if (ObjectType.get().isNull()) {<br>        Diag(Tok, diag::err_destructor_tilde_identifier);<br>        return true;<br>      }<br><br>      if (DS.getTypeSpecType() == DeclSpec::TST_decltype_auto) {<br>        Diag(Tok, diag::err_destructor_tilde_identifier);<br>        //needs a better diag. which one ?<br>        return true;<br>      }<br></div><div><br></div><div>The first one handles the declaration of dtor using decltype.<br></div><div>But the assertion failure for <br>A().~decltype(auto);<br></div><div>remains.<br></div><div>The second one handles that.<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 24, 2015 at 1:39 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Mon, Feb 23, 2015 at 11:13 AM, Manasij Mukherjee <span dir="ltr"><<a href="mailto:manasij7479@gmail.com" target="_blank">manasij7479@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>So, an extra condition takes care of not allowing the decltype when declaring the dtor.<br>! getCurScope()->isClassScope()<br><br></div>Am I correct ?</div></div></blockquote><div><br></div></span><div>No; ~decltype can appear in class scope in default arguments, default member initializers, initializers for static data members, template arguments, and so on.</div><div><br></div><div>The bug is due to confusion over the contract of Sema::getDestructorType. It is assuming that a null ObjectType implies that an error has already been produced, but ParseUnqualifiedId calls it with a null ObjectType to mean simply that no ObjectType was provided. One side of this interface is wrong; we need to pick which one, and produce a diagnostic on that side if ObjectType is in fact null.</div><div><br></div><div>(We should be using TypeResult here rather than ParsedType, to make it clear whose responsibility it is to produce the diagnostic.)</div><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><div>> you can use ~decltype(...)() to invoke a destructor<br></div></span><div>Why is that allowed?<br></div><div>And what exactly is a valid use of this ?<br></div><div><br>From the report,<br>A().~decltype(auto); // ICE, and A can be an empty struct<br></div><div><div><br></div><div>Does the standard say anything about what can the decltype contain ?<br></div><div>Should the compiler figure something out from the auto here ?<br></div></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 24, 2015 at 12:26 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Sun, Feb 22, 2015 at 3:24 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sun, Feb 22, 2015 at 2:33 PM, Manasij Mukherjee <span dir="ltr"><<a href="mailto:manasij7479@gmail.com" target="_blank">manasij7479@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><span><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>5.1.1 [expr.prim.general] in paragraph 8 states that "The form ~ decltype-specifier also denotes the destructor, but it shall not be used as
the unqualified-id in a qualified-id."<br><br>I implemented this a while ago, but it looks like (r146155) it was for expressions (x.~decltype(*x)(), for example) not necessarily for dtor declarations.</div></div><br></div></div>
</blockquote></div></span>I do not clearly understand what this sentence implies.<br></div><div class="gmail_extra">Could you elaborate?<br><br></div><div class="gmail_extra">Also, if the meaning is as you interpreted it, what is the rationale for allowing x.~decltype(*x)() ?<br></div></div></blockquote></div></div><div><br>Not quite sure I understand this question (though I did make a mistake in that example, should've been x->~decltype(*x)())<br></div></div></div></div></blockquote><div><br></div></span><div>That doesn't work either: decltype(*x) is a reference type. It'd need to be something ridiculous like</div><div><br></div><div>  X x;</div><div>  x.~decltype(x)();</div><div>  new (&x) X;</div><span><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>5.1.1 talks about how ~decltype(...) is a valid unqualified id, except in the case of a qualified id (ie, you can't write "x::y::~decltype(...)"). So that's how x->~decltype(*x)() is valid, as far as I see/read/understand it - wherever you can use an unqualified-id that would name a dtor, you can use ~decltype(...) too (ecxept in the qualified-id case).</div></div></div></div></blockquote><div><br></div></span><div>Right; you can use ~decltype(...)() to invoke a destructor, but you can't use ~decltype to declare a destructor.</div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div>