<html dir="ltr"><head></head><body style="text-align:left; direction:ltr;" bgcolor="#ffffff" text="#2e3436" link="#2a76c6" vlink="#2e3436"><div>Hi Eric, I wrote a workaround for that issue a few months ago (as part of the implementation of P0542R5, now included in the current C++ working draft).  These attributes are manually moved to the attribute list of the declarator.  To illustrate this, a patch is included in this mail.</div><div><br></div><div><font face="monospace" size="3">--- a/tools/clang/lib/Sema/SemaType.cpp</font></div><div><font face="monospace" size="3">+++ b/tools/clang/lib/Sema/SemaType.cpp</font></div><div><font face="monospace" size="3">@@ -7039,6 +7039,14 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,</font></div><div><font face="monospace" size="3">           << attr.getName();</font></div><div><font face="monospace" size="3">       break;</font></div><div><font face="monospace" size="3"> </font></div><div><font face="monospace" size="3">+    // These attributes appertain to the declarator, although they occur</font></div><div><font face="monospace" size="3">+    //  void identifier(void) [[here]];</font></div><div><font face="monospace" size="3">+    case AttributeList::AT_Expects:</font></div><div><font face="monospace" size="3">+    case AttributeList::AT_Ensures:</font></div><div><font face="monospace" size="3">+      moveAttrFromListToList(attr, state.getCurrentAttrListRef(),</font></div><div><font face="monospace" size="3">+                             state.getDeclarator().getAttrListRef());</font></div><div><font face="monospace" size="3">+      break;</font></div><div><font face="monospace" size="3">+</font></div><div><font face="monospace" size="3"></font></div><div><font face="monospace" size="3"></font><br></div><div>Regards.</div><div><br></div><div>El mié, 27-06-2018 a las 04:15 -0600, Eric Fiselier escribió:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr">Wooh! Thanks for working on this.<div><br></div><div>Clang's `diagnose_if` attribute would certainly benefit from this change. Currently it's usable only</div><div>as a GCC attribute.</div><div><br></div><div>I tried working on this a while back. IIRC the main issue is that C++11 attributes placed at the end of</div><div>a function declaration apply to the function type and not the declaration itself. (See [dcl.spec]p1).</div><div><br></div><div>After discussing this with Richard and Aaron about attributes appearing after a function-specifier, I believe the</div><div>consensus was to only apply the attribute to the type if said attribute is a "type attribute". Otherwise the</div><div>attribute would apply to the entity being declared. For example, I think we should accept `int foo() [[noreturn]];`</div><div><br></div><div>/Eric</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 27, 2018 at 2:20 AM, Javier López via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div style="text-align:left;direction:ltr" bgcolor="#ffffff" text="#2e3436" link="#2a76c6" vlink="#2e3436"><div>OK, unless Aaron replies that someone is currently implementing this, I will be working on a patch.</div><div><br></div><div>I know :-)  I have been working for months in the implementation of P0542 in Clang.  Late parsing is one of the missing features.</div><div><div class="h5"><div><br></div><div>El mar, 26-06-2018 a las 17:05 -0700, Richard Smith escribió:</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr">I'm not aware of anyone working on this (CC'd Aaron, who might know if someone is). Patches would be very much welcome :)<div><br></div><div>Also relevant is <a href="http://wg21.link/p0542r5" target="_blank">http://wg21.link/p0542r5</a> (voted into the current C++ working draft a couple of weeks ago), which requires late parsing for C++11 attributes within a class.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 21 June 2018 at 04:16, Javier López via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div style="text-align:left;direction:ltr" bgcolor="#ffffff" text="#2e3436" link="#2a76c6" vlink="#2e3436"><div>Hello everyone,</div><div><br></div><div>AFAIK, GNU attributes can be late parsed within a class (see ParseDecl.cpp, Parser::ParseGNUAttributes), but late parsing of CXX11 attributes is not yet implemented. </div><div><br></div><div>Is there any plans to do it or anyone already working on it?  Anyway, if no one is owning that issue, I could work on it.</div><div><br></div><div>Thanks, </div><div>-- </div><div><span><div>Javier López</div><div>2.2.B.08 ARCOS lab, Computer Architecture Group</div><div>University Carlos III of Madrid</div><div>e-mail: <a href="mailto:jalopezg@inf.uc3m.es" target="_blank">jalopezg@inf.uc3m.es</a></div></span></div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote><div><span><pre>-- <br></pre><div>Javier López</div><div>2.2.B.08 ARCOS lab, Computer Architecture Group</div><div>University Carlos III of Madrid</div><div>e-mail: <a href="mailto:jalopezg@inf.uc3m.es" target="_blank">jalopezg@inf.uc3m.es</a></div></span></div></div></div></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>
</blockquote><div><span><pre>-- <br></pre><div>Javier López</div><div>2.2.B.08 ARCOS lab, Computer Architecture Group</div><div>University Carlos III of Madrid</div><div>e-mail: <a href="mailto:jalopezg@inf.uc3m.es">jalopezg@inf.uc3m.es</a></div></span></div></body></html>