[PATCH] Attribute parsing following labels

Aaron Ballman aaron at aaronballman.com
Tue Oct 1 05:26:31 PDT 2013

On Mon, Sep 30, 2013 at 6:03 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> It should be possible to handle this case without tentative parsing or
> lookahead. Consume the attributes onto a new list; if the next token is a
> semicolon, then push them into the label's attribute list; otherwise,
> ParseStatementOrDeclarationAfterAttributes.

Ah, thanks!

> What does GCC do if there are #pragmas between the case label and the
> attribute, and/or between the attribute and the semicolon?

void func(void) {
label: __attribute__((unused))
#pragma message "stuff"

Prints the message, no warning about the label or the attribute.

void func(void) {
#pragma message "stuff"

Prints the message, then prints an error about expecting an expression
before the attribute, and a warning for the label being unused.


More information about the cfe-commits mailing list