[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: [PATCH] Fix crash parsing pragma after a case or a default
From:       Richard Smith <richard () metafoo ! co ! uk>
Date:       2013-10-28 22:08:34
Message-ID: CAOfiQqmQ8VfrVyU995k8oWjvwU5-zjFPoHpkFY_+zOrvaQLQmA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sat, Oct 26, 2013 at 8:30 AM, Olivier Goffart <ogoffart@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@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@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

[Attachment #5 (text/html)]

<div dir="ltr">On Sat, Oct 26, 2013 at 8:30 AM, Olivier Goffart <span \
dir="ltr">&lt;<a href="mailto:ogoffart@kde.org" \
target="_blank">ogoffart@kde.org</a>&gt;</span> wrote:<br><div \
class="gmail_extra"><div class="gmail_quote"> <blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div \
class="im">On Sunday 22 September 2013 23:15:18 Olivier Goffart wrote:<br>

&gt; On Saturday 21 September 2013 15:25:41 Richard Smith wrote:<br>
&gt; &gt; Thanks, LGTM. Do you need someone to commit this for you?<br>
&gt;<br>
&gt; Yes, I don&#39;t have commit access.<br>
<br>
</div>Hi Richard,<br>
<br>
That patch has still AFAIK not been \
commited.</blockquote><div><br></div><div>Committed in r193545. Thanks for the patch \
(and the ping), and sorry for the delay!</div><div><div class=""><div class="h5"><br> \
&gt; &gt; On Fri, Sep 20, 2013 at 4:40 AM, Olivier Goffart &lt;<a \
href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>&gt; wrote:<br> &gt; &gt; &gt; I \
made the loop at a lower level.<br> &gt; &gt; &gt; Notice that the diagnostic is \
slightly different when there is a #pragma<br> &gt; &gt; &gt; after<br>
&gt; &gt; &gt; a case: and no statements.  But I think it does not matter.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; On Wednesday 18 September 2013 14:40:40 Richard Smith wrote:<br>
&gt; &gt; &gt; &gt; I think the loop should be at a lower level. This also crashes \
today<br> &gt; &gt; &gt;<br>
&gt; &gt; &gt; (while<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; diagnosing an empty loop body):<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; int f() {<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;   if (false)<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; #pragma weak f<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;     return 0;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;   return 1;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; }<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; ... and if we didn&#39;t have that diagnostic, we&#39;d generate \
wrong code<br> &gt; &gt; &gt;<br>
&gt; &gt; &gt; instead.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; On Wed, Sep 18, 2013 at 1:09 AM, Olivier Goffart &lt;<a \
href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>&gt;<br> &gt; &gt; &gt;<br>
&gt; &gt; &gt; wrote:<br>
&gt; &gt; &gt; &gt; &gt; On Monday 16 September 2013 11:43:00 Richard Smith \
wrote:<br> &gt; &gt; &gt; &gt; &gt; &gt; I don&#39;t particularly like adding a \
NullStmt here -- there was no<br> &gt; &gt; &gt; &gt; &gt; &gt; null<br>
&gt; &gt; &gt; &gt; &gt; &gt; statement in the source code, so this is not a faithful \
AST<br> &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; representation<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; of the source.<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; This approach seems like it will also accept this:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; switch (t) {<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;   case 1:<br>
&gt; &gt; &gt; &gt; &gt; &gt; #pragma weak t<br>
&gt; &gt; &gt; &gt; &gt; &gt; }<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; We should probably reject this, because there is no \
statement<br> &gt; &gt; &gt; &gt; &gt; &gt; after<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; the<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; case label. (That said, GCC accepts the above code, and \
fully<br> &gt; &gt; &gt; &gt; &gt; &gt; treats<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; these<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; pragmas as being statement-like entities, so your patch \
would be<br> &gt; &gt; &gt; &gt; &gt; &gt; bug-compatible with them.)<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Does the same issue exist for goto labels?<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; The problem was the same for goto.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; I attached a new patch that reject invalid code.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt; &gt; Olivier<br>
<br>
</div></div></div></div><br></div></div>



_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic