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

Richard Smith richard at metafoo.co.uk
Mon Oct 28 15:08:34 PDT 2013


On Sat, Oct 26, 2013 at 8:30 AM, Olivier Goffart <ogoffart at kde.org> wrote:

> On Sunday 22 September 2013 23:15:18 Olivier Goffart wrote:
> > On Saturday 21 September 2013 15:25:41 Richard Smith wrote:
> > > Thanks, LGTM. Do you need someone to commit this for you?
> >
> > Yes, I don't have commit access.
>
> Hi Richard,
>
> That patch has still AFAIK not been commited.


Committed in r193545. Thanks for the patch (and the ping), and sorry for
the delay!

> > On Fri, Sep 20, 2013 at 4:40 AM, Olivier Goffart <ogoffart at kde.org>
wrote:
> > > I made the loop at a lower level.
> > > Notice that the diagnostic is slightly different when there is a
#pragma
> > > after
> > > a case: and no statements.  But I think it does not matter.
> > >
> > > On Wednesday 18 September 2013 14:40:40 Richard Smith wrote:
> > > > I think the loop should be at a lower level. This also crashes today
> > >
> > > (while
> > >
> > > > diagnosing an empty loop body):
> > > >
> > > > int f() {
> > > >
> > > >   if (false)
> > > >
> > > > #pragma weak f
> > > >
> > > >     return 0;
> > > >
> > > >   return 1;
> > > >
> > > > }
> > > >
> > > > ... and if we didn't have that diagnostic, we'd generate wrong code
> > >
> > > instead.
> > >
> > > > On Wed, Sep 18, 2013 at 1:09 AM, Olivier Goffart <ogoffart at kde.org>
> > >
> > > wrote:
> > > > > 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131028/8477f750/attachment.html>


More information about the cfe-commits mailing list