[tree-ssa] Computed gotos

law@redhat.com law@redhat.com
Mon Jun 16 17:38:00 GMT 2003


In message <200306151759.45301.paul@nowt.org>, Paul Brook writes:
 >What is the proper method for handling computed gotos? In fortran we have 
 >code which is equivalent to the following. I've not idea if this is 
 >actually legal C, but it shows what I'm trying to achieve.
 >
 >void test(int i)
 >{
 >  static void *ptr[2] = {&label0, &label1}
 >  goto ptr[i];
 >label0:
 > //do something
 >label1:
 > //do something else
 >}
[ ... ]
 >How do I annotate the labels to mark them as the destination of a computed 
 >goto statement? TREE_ADDRESSABLE doesn't have any noticable effect. I'd say 
 >this would be the most obvious way of specifying that the label is the 
 >target of an unknown goto.
 >Setting TREE_SIDE_EFFECTS seems to work but I'm not sure if this is 
 >reliable. If I don't set TREE_SIDE_EFFECTS the optimizer decides neither of 
 >the labels are used and removes them.
Well, what do the tree nodes which use these addresses look like?

ie, at some point have either have to load the target's address into an
object.  That's where we're set up to identify these things.  We should
be able to catch the address of a label used in a static initializer or
just about anywhere else I can think of.

jeff



More information about the Gcc mailing list