<html><head></head><body bgcolor="#ffffff" text="#2e3436" link="#2a76c6" vlink="#2e3436"><div>El mar, 10-10-2017 a las 22:48 -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"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 9, 2017 at 7:47 PM, Richard Smith 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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On 6 October 2017 at 07:36, Javier López Gómez 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">Hi,<br>
<br>
I'm new to Clang hacking. Recently -prior to addition of a new attribute-, I tried adding a C++11 spelling of the DiagnoseIf attribute in the file<br>
`tools/clang/include/clang/Bas<wbr>ic/Attr.td':<br>
<br>
  let Spellings = [GNU<"diagnose_if">,<br>
                   CXX11<"", "diagnose_if", 201603>];<br>
<br>
but the parser complains if the expression contains references to<br>
function arguments, even if `LateParsed = 1' is specified, i.e. this<br>
works<br>
<br>
  int foo(int arg) __attribute__((diagnose_if(arg == 0, "text",<br>
"warning")));<br>
<br>
but this will not:<br>
<br>
  [[diagnose_if(arg == 0, "text", "warning")]] int foo(int arg);<br>
<br>
<br>
Am I missing something? Any help will be much appreciated.<br></blockquote><div><br></div></span><div>There is nowhere that a C++11-syntax attribute can be written where it appertains to the function entity and the function parameter names are in scope. The two locations where attributes can be applied to a name introduced by a declarator are:</div><div><br></div><div>  [[here]] int f [[and_here]] (int x);</div><div><br></div><div>... and neither of them follows the "x" parameter's declaration. After some discussion with Aaron, we think the best way forward is to recast such attributes as attributes on the function *type* (that perhaps don't change the canonical type, but do affect how the function declarator is interpreted as forming a function in some way). That'd mean you'd put the attributes:</div><div><br></div><div>  int f(int x) [[here]];</div><div><br></div><div>... which conveniently is a place where the function parameters are in scope. The downside is that we don't have parsing support for attributes that appertain to function types yet. That would need to be added.</div></div></div></div><br></blockquote><div><br></div><div>I've been working on a fix for this; But if you want to hack on this, I'm happy to yield.</div></div></div></div></blockquote><div><br></div><div>Yes, I will be working on this for the next days.  Thanks.</div><div> </div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex">
<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></div>
</blockquote><div><span><pre><br></pre></span></div></body></html>