<p dir="ltr"><br>
On 8 Oct 2013 14:22, "Aaron Ballman" <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br>
><br>
> On Mon, Oct 7, 2013 at 4:41 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> > On Mon, Oct 7, 2013 at 1:21 PM, Aaron Ballman <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>><br>
> > wrote:<br>
> >><br>
> >> On Mon, Oct 7, 2013 at 4:16 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
> >> wrote:<br>
> >> > +  // Read label attributes, if present. TempAttrs will contain both<br>
> >> > C++11<br>
> >> > and<br>
> >> > +  // GNU attributes (if present) after this point.<br>
> >> ><br>
> >> > This isn't true: we're only parsing GNU attributes here.<br>
> >><br>
> >> Sorry, that's a holdover from the existing comment.  I'll correct it.<br>
> >> ><br>
> >> > +    } else {<br>
> >> > +      StmtVector Stmts;<br>
> >> > +      SubStmt = ParseStatementOrDeclarationAfterAttributes(Stmts, true,<br>
> >> > 0,<br>
> >> > +                                                           TempAttrs);<br>
> >> ><br>
> >> > This doesn't look like it'll correctly handle the case where<br>
> >> > ParseStatementOrDeclarationAfterAttributes returns null (because we<br>
> >> > parsed a<br>
> >> > pragma or the like). If you're relying on this being impossible (because<br>
> >> > an<br>
> >> > attribute can't apply to a #pragma), please insert an assert here (that<br>
> >> > SubStmt is invalid or usable).<br>
> >><br>
> >> Doesn't that get handled slightly further down?<br>
> >><br>
> >>   // Broken substmt shouldn't prevent the label from being added to the<br>
> >> AST.<br>
> >>   if (SubStmt.isInvalid())<br>
> >>     SubStmt = Actions.ActOnNullStmt(ColonLoc);<br>
> ><br>
> ><br>
> > This does not handle the case where SubStmt is valid but null.<br>
> > ParseStatementOrDeclarationAfterAttributes returns such a value if it hits a<br>
> > #pragma.<br>
><br>
> What I am finding in practice is that ConsumeToken for the colon is<br>
> also consuming the #pragma in this test case:<br>
><br>
> void f() {<br>
> // Invalid<br>
> D: // expected-warning {{unused label 'D'}}<br>
> #pragma message "stuff"  // expected-warning {{stuff}}<br>
> __attribute__((unused))  // expected-error {{expected expression}}<br>
> ;<br>
> }<br>
><br>
> So ParseStatementOrDeclarationAfterAttributes does not return a null<br>
> statement because it never sees the #pragma.  I'm not certain of the<br>
> proper way to proceed as there appears to be no way to tell<br>
> ConsumeToken to not consume the pragma.</p>
<p dir="ltr">There are two very different kinds of pragmas: those that take effect when we lex them (these are handled in the lexer and never reach the token stream) and those that take effect when we parse them (these can only appear where a declaration can appear, and get translated into tokens). You got unlucky and picked a pragma of the first kind. Try #pragma weak instead.</p>