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

Olivier Goffart ogoffart at kde.org
Wed Sep 18 01:09:34 PDT 2013


On Monday 16 September 2013 11:43:00 Richard Smith wrote:
> 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?

The problem was the same for goto.

I attached a new patch that reject invalid code.

-- 
Olivier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-crash-when-there-is-a-pragma-right-after-a-case-.patch
Type: text/x-patch
Size: 4870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130918/f1eeb41b/attachment.bin>


More information about the cfe-commits mailing list