This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compiler tweak offered


On Fri, Aug 30, 2002 at 10:06:43AM +0200, der Mouse wrote:
> 
> >> Unfortunately it does cause a reinterpretation of certain very
> >> unusual legal C code, namely, any do-loop whose body is a
> >> non-brace-bracketed statement beginning with a string literal...
> > In addition, this is a major strike against your proposal.
> 
> This is surely fixable.  For example, if a C/ObjC statement cannot
> begin with < (which I think is the case but I'm not quite sure), then
> names could be specified as <"string"> rather than just "string" and
> the ambiguity would vanish.  (Maybe even make them identifiers rather
> than string literals then.)

Plain old identifiers would certainly be preferable to strings; I'm
pretty sure that avoids changing the meaning of any currently valid C
program.

> >   outer: for (elt=root; elt; elt=elt->link)
> > 		 if (...) continue outer;
> 
> Better in that respect.  It would lose in two of the respects I
> mentioned above, though: (1) it means you can't have a given loop name
> more than once in a given function and (2) it would open up that target
> to gotos as well as continues and breaks.

(2) I don't see as being a problem; it is unambiguous what 'goto
outer' means.

You explained elsewhere why you wanted to give more than one block in
the same function the same name, but I have to say I find it only a
source of confusion.  I would much rather be forced to give each named
block a unique name, than have to work out at length just which
"outer" loop is meant in a messy routine I didn't write.

As for implementation, hmm, yeah, that does look messy right now; we
don't have a convenient way to get from a LABEL_DECL, which is what
you would have when trying to generate the AST for 'continue outer',
to the block STMT labelled by that label.  This is a deficiency in our
AST representation -- go talk to the ast-optimizer-branch people about
it.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]