This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [google]: initialize language field for clone function struct
On Tue, 3 May 2011, Eric Botcazou wrote:
> > C returns -1 from global_bindings_p, as does Ada. That the languages that
> > probably care most about variable-size types find aspects of the generic
> > function need overriding like that should be a good indication that it
> > isn't really that generic - as I said above, semantics for variable sizes
> > are very front-end-specific.
>
> I think that a large chunk of the non-generic code can be removed because it
> is either useless (the error) or obsolete (pending_size) in the 4.x series.
Well - the errors in variable_size aren't used by C any more (since 4.5),
but I don't know whether any other languages use them. And pending sizes
are used to a limited extent for C (to handle side effects in sizes of
array parameters, as described in the comment
/* ??? Insert the contents of the pending sizes list into the function
to be evaluated. The only reason left to have this is
void foo(int n, int array[n++])
because we throw away the array type in favor of a pointer type, and
thus won't naturally see the SAVE_EXPR containing the increment. All
other pending sizes would be handled by gimplify_parameters. */
) although it would now be better to make use of the "expr" parameter to
grokdeclarator to replace this residual use of the pending sizes global
list.
The most suspect case for using generic variable-size code would be C++,
which has some limited, poorly-defined VLA support as a GNU extension. I
don't know if Fortran, Java or Go use variable-size types at all.
> After that, if you prefer to make this particular function FE-specific, fine
> with me, but they will all essentially look alike.
Actually, it will probably be possible the eliminate the function
completely for C; there's no good reason to do more than calling save_expr
directly.
if (TREE_CONSTANT (size))
return size;
Redundant, save_expr checks for constants.
size = save_expr (size);
The only necessary bit of c_variable_size once pending sizes are replaced
by a better scheme.
save = skip_simple_arithmetic (size);
Premature optimization.
if (cfun && cfun->dont_save_pending_sizes_p)
return size;
if (!global_bindings_p ())
put_pending_size (save);
No longer needed once pending sizes are replaced.
return size;
So this just becomes equivalent to save_expr.
--
Joseph S. Myers
joseph@codesourcery.com