tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] nocode_wanted does not work


From: Edmund Grimley Evans
Subject: Re: [Tinycc-devel] nocode_wanted does not work
Date: Sun, 3 Apr 2016 20:39:48 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Michael:

> Of course, because the whole parsing of the ({block}) still
> generates code.  The nocode_wanted hack currently doesn't work for
> statement expressions, and as Edmund says deserves a little thought
> if it's applied at the right level currently (well I think it's
> clear that it isn't, but the question what the right level is
> remains).

Yes.

I've just been thinking about whether there might be any viable
alternatives to making nocode_wanted work properly, and perhaps there
are, but they're not nice...

For example, when you encounter a statement expression you could
distinguish three cases:

1. If you're in a place where it's impossible to generate code, such
as inside the declaration of a global variable, then stop with an
error. This might imply the limitation (which I think people could
live with) of not being able to handle a global declaration such as:

    int a[sizeof(({ for (;;) ; }), 1)];

(On the other hand, are there any places where it's totally impossible
to generate code? Would it matter if you generated unreachable garbage
code between two functions?)

2. If you're somethere where it's possible to generate code, but you
didn't want there to be any code, then generate an unconditional
branch forwards so it doesn't matter if any garbage code gets
generated while the statement expression is being parsed.

3. If you're inside case 2, or anywhere else where you know that
you're generating unreachable code, then just carry on: if any garbage
code gets generated it won't do any harm.

Like I said, it's not nice. Making nocode_wanted work seems
preferable. But if it turns out to be too difficult then there are
perhaps alternatives.

Edmund



reply via email to

[Prev in Thread] Current Thread [Next in Thread]