<div dir="ltr">Oh, also: please add test cases for #pragmas appearing near the attributes.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 1:16 PM, 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>+  // Read label attributes, if present. TempAttrs will contain both C++11 and</div><div>+  // GNU attributes (if present) after this point.</div>
<div><br></div><div>This isn't true: we're only parsing GNU attributes here.</div>
<div><br></div><div><div>+    } else {</div><div>+      StmtVector Stmts;</div><div>+      SubStmt = ParseStatementOrDeclarationAfterAttributes(Stmts, true, 0,</div><div>+                                                           TempAttrs);</div>

<div><br></div><div>This doesn't look like it'll correctly handle the case where ParseStatementOrDeclarationAfterAttributes returns null (because we parsed a pragma or the like). If you're relying on this being impossible (because an attribute can't apply to a #pragma), please insert an assert here (that SubStmt is invalid or usable).</div>

</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Oct 5, 2013 at 2:09 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here is another attempt at this patch, without the tentative parsing.<br>
<br>
Thanks!<br>
<span><font color="#888888"><br>
~Aaron<br>
</font></span><div><div><br>
On Tue, Oct 1, 2013 at 12:43 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>
> OK, that makes some sense, since the pragma acts like a statement that<br>
> cannot have an attribute.<br>
><br>
> On 1 Oct 2013 05:26, "Aaron Ballman" <<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>> wrote:<br>
>><br>
>> On Mon, Sep 30, 2013 at 6:03 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>><br>
>> wrote:<br>
>> > It should be possible to handle this case without tentative parsing or<br>
>> > lookahead. Consume the attributes onto a new list; if the next token is<br>
>> > a<br>
>> > semicolon, then push them into the label's attribute list; otherwise,<br>
>> > ParseStatementOrDeclarationAfterAttributes.<br>
>><br>
>> Ah, thanks!<br>
>><br>
>> > What does GCC do if there are #pragmas between the case label and the<br>
>> > attribute, and/or between the attribute and the semicolon?<br>
>><br>
>> void func(void) {<br>
>> label: __attribute__((unused))<br>
>> #pragma message "stuff"<br>
>> ;<br>
>> }<br>
>><br>
>> Prints the message, no warning about the label or the attribute.<br>
>><br>
>> void func(void) {<br>
>> label:<br>
>> #pragma message "stuff"<br>
>> __attribute__((unused))<br>
>> ;<br>
>> }<br>
>><br>
>> Prints the message, then prints an error about expecting an expression<br>
>> before the attribute, and a warning for the label being unused.<br>
>><br>
>> ~Aaron<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>