[PATCH] Fix crash parsing pragma after a case or a default

Richard Smith richard at metafoo.co.uk
Mon Sep 16 11:43:00 PDT 2013


On Sun, Sep 15, 2013 at 12:23 PM, Olivier Goffart <ogoffart at kde.org> wrote:

> Hi,
>
> The attached patch fix a crash when there are pragma in case statement.
> (Seen while parsing glibc source code)
>
> void __td_ta_lookup_th_unique()
> {
>     int t = 0;
>     switch (t)
>     {
>         case 1:
> #pragma weak t
>           ;
>     }
> }
>

Thanks for looking into this.

I don't particularly like adding a NullStmt here -- there was no null
statement in the source code, so this is not a faithful AST representation
of the source.

This approach seems like it will also accept this:

switch (t) {
  case 1:
#pragma weak t
}

We should probably reject this, because there is no statement after the
case label. (That said, GCC accepts the above code, and fully treats these
pragmas as being statement-like entities, so your patch would be
bug-compatible with them.)

Does the same issue exist for goto labels?


> http://llvm.org/bugs/show_bug.cgi?id=16705
>
> Regards
> --
> Olivier
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130916/5001eddf/attachment.html>


More information about the cfe-commits mailing list