<div dir="ltr">[class.dtor] (12.4)/1:<div><br></div><div>"A declaration of a destructor uses a function declarator (<span class="">8.3.5</span>) of the form<div>
<p class="">    ptr-declarator ( parameter-declaration-clause ) exception-specification<span class="">opt </span>attribute-specifier-seq<span class="">opt</span></p>
<p class="">where the ptr-declarator consists solely of an id-expression, an optional attribute-specifier-seq, and optional surrounding parentheses, and the id-expression has one of the following forms:</p>
<p class="">-- in a member-declaration that belongs to the member-specification of a class but is not a friend declaration (<span class="">11.3</span>), the id-expression is <span class="">~</span>class-name and the class-name is the injected-class-name (Clause <span class="">9</span>) of the immediately-enclosing class;</p><p class="">[... bullets 2 and 3 do not apply ...]"</p><p class="">A decltype-specifier is never a class-name, so ~decltype(...) cannot be used to declare a destructor.</p></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Feb 22, 2015 at 12:51 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 class="h5">On Sun, Feb 22, 2015 at 7:56 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hi,<br></div>I am trying to fix this bug,<br><a href="http://llvm.org/bugs/show_bug.cgi?id=22508" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=22508</a><br><br></div>In short, <br>struct A <br>{ <br>    ~decltype(auto){} <br>};<br></div>is accepted when it should not be.<br><br></div>In Parser::ParseUnqualifiedId (ParseExprCXX.cpp:2488 ), <br><br>// Parse the '~'.<br>    SourceLocation TildeLoc = ConsumeToken();<br><br>    if (SS.isEmpty() && Tok.is(tok::kw_decltype)) {<br>      DeclSpec DS(AttrFactory);<br>      SourceLocation EndLoc = ParseDecltypeSpecifier(DS);<br>      if (ParsedType Type = Actions.getDestructorType(DS, ObjectType)) {<br>        Result.setDestructorName(TildeLoc, Type, EndLoc);<br>        return false;<br>      }<br>      return true;<br>    }<br><br></div><div>After this, clang handles the identifier case.<br><br></div><div>Removing this block results in clang reporting the correct diagnostic:<br>"error: expected a class name after '~' to name a destructor"<br><br>Why is this block present ?<br></div></div>Can anyone point out what is the expected behavior ?<br></div></div></blockquote></div></div><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.<br><br>I can't find any particular words in the spec about taht, but I could believe it's not intended (I didn't test it, at least) for dtor declarations/definitions to use this syntax.<br><br><a href="http://llvm.org/bugs/show_bug.cgi?id=15801" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=15801</a> was also filed about this<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Manasij Mukherjee<br></div><div><div><div><br></div></div></div></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>