[cfe-commits] [PATCH] Multiple pragmas at the start of a compound statement.

Lang Hames lhames at gmail.com
Sat Nov 3 15:30:33 PDT 2012


Thanks John,

Committed, with support for other pragma annotation tokens as well, in
r167363.

Cheers,
Lang.


On Thu, Nov 1, 2012 at 12:51 PM, John McCall <rjmccall at apple.com> wrote:

> On Oct 25, 2012, at 1:39 PM, Lang Hames wrote:
>
> Tim Northover pointed out that there's a flaw in my recent FP_CONTRACT
> patch (r166383). That patch restricted FP_CONTRACT (or rather
> tok::annot_pragma_fp_contract) to appearing as the first token in a
> compound statement. The problem with my patch is that it prohibits things
> like:
>
> void foo() {
>   #pragma MS_STRUCT ON
>   #pragma STDC FP_CONTRACT ON
>   // ...
> }
>
> Which isn't prohibited by the C99 spec, and I think seems reasonable.
>
> A simple solution to the problem is to loop at the start of a compound
> statement parsing tokens that can reasonably appear there (FP_CONTRACT,
> MS_STRUCT, maybe others?), then break out of that look when an unhandled
> token encountered. Attached is a patch that implements this approach,
> processing FP_CONTRACT and MS_STRUCT pragmas at the start of compound
> statements before falling through.
>
> Not being a language lawyer, is what else should be handled in this loop?
>
>
> Other pragmas, maybe.  You could potentially check for all the pragma
> annotation tokens.
>
> Does this seem like a reasonable approach?
>
>
> It seems fine.
>
> John.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121103/e48d21ef/attachment.html>


More information about the cfe-commits mailing list