> So this isn't about global
>
> void *x[] = { &((struct Y *)0x12)->foo }
>
> but for a local one where supposedly variable indexing is valid (don't
> we gimplify that)?
Yes, it's local (it's OK if global because we do a full RTL expansion).
Everything is valid, constant and passes initializer_constant_valid_p.
> And
>
> + case INDIRECT_REF:
> + /* This deals with absolute addresses. */
> + offset += tree_to_shwi (TREE_OPERAND (target, 0));
> + x = gen_rtx_MEM (QImode,
> + gen_rtx_SYMBOL_REF (Pmode, "origin of addresses"));
>
> simply translates 0x12 to &*<origin> + 0x12 (where origin == 0 somehow?).
>
> I suppose returing directly here and sth like
>
> value->base = gen_rtx_SYMBOL_REF (Pmode, "origin of addresses");
> value->offset = offset + tree_to_shwi (...);
> return;
>
> would be clearer.
That's a matter of consistency, the LABEL_DECL case does something equivalent:
x = gen_rtx_MEM (FUNCTION_MODE,
gen_rtx_LABEL_REF (Pmode, force_label_rtx (target)));
> Or even
>
> value->base = tree-to-rtx (TREE_OPERAND (target, 0));
> value->offset = offset;
The callers expect the base to be SYMBOL_REF or LABEL_REF though.
--
Eric Botcazou