Re: 2.2.18 signal.h

From: Anuradha Ratnaweera (anuradha@gnu.org)
Date: Sat Dec 16 2000 - 02:53:50 EST


On Fri, 15 Dec 2000, Andrea Arcangeli wrote:

> On Fri, Dec 15, 2000 at 11:18:35AM -0800, Ulrich Drepper wrote:
> > Andrea Arcangeli <andrea@suse.de> writes:
> >
> > > x()
> > > {
> > >
> > > switch (1) {
> > > case 0:
> > > case 1:
> > > case 2:
> > > case 3:
> > > ;
> > > }
> > > }
> > >
> > > Why am I required to put a `;' only in the last case and not in all
> > > the previous ones? Or maybe gcc-latest is forgetting to complain about
> > > the previous ones ;)
> >
> > Your C language knowledge seems to have holes. It must be possible to
> > have more than one label for a statement. Look through the kernel
> > sources, there are definitely cases where this is needed.
>
> I don't understand what you're talking about. Who ever talked about
> "more than one label"?

In simple terms all four `case'es form a single entity and therefore a
statement is necessary AFTER them and not in the MIDDLE. That is why gcc
doesn't complain about the `previous' ones.
 
> The only issue here is having 1 random label at the end of a compound
> statement. Nothing else.

That is NOT the issue. It has nothing to do with the compound statement.
There should be a statement after ONE OR MORE "case"s, but here

case 0: case 1: case 2: case 3:

is NOT followed by a statement.

> And yes I can see that the whole point of the change is that they want
> to also forbids this:
>
> x()
> {
> goto out;
> out:
> }

Again this is a similar case. But if you write

x()
{
  goto out1;
  goto out2;

out1:
out2:
}

GCC will complain the absence of a statement after `out1:out2:`, but not
two complains for `out1' and `out2', because they form a single entity.

Anuradha

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Dec 23 2000 - 21:00:15 EST