+2004-08-30 Richard Henderson <rth@redhat.com>
+
+ * class.c (build_base_path): Use build_address directly.
+ * typeck.c (build_unary_op): Don't lower &a.b to pointer
+ arithmetic directly.
+ * typeck2.c (store_init_value): Don't assume !TREE_CONSTANT
+ means !initializer_constant_valid_p.
+
2004-08-30 Richard Henderson <rth@redhat.com>
* class.c (fixed_type_or_null): Use get_base_address before
expr = build_indirect_ref (expr, NULL);
expr = build_simple_base_path (expr, binfo);
if (want_pointer)
- expr = build_unary_op (ADDR_EXPR, expr, 0);
+ expr = build_address (expr);
target_type = TREE_TYPE (expr);
goto out;
}
return arg;
}
- /* For &x[y], return x+y. But, in a template, ARG may be an
- ARRAY_REF representing a non-dependent expression. In that
- case, there may be an overloaded "operator []" that will be
- chosen at instantiation time; we must not try to optimize
- here. */
- if (TREE_CODE (arg) == ARRAY_REF && !processing_template_decl)
- {
- if (!cxx_mark_addressable (TREE_OPERAND (arg, 0)))
- return error_mark_node;
- return cp_build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
- TREE_OPERAND (arg, 1));
- }
-
/* Uninstantiated types are all functions. Taking the
address of a function is a no-op, so just return the
argument. */
}
else
{
- /* Unfortunately we cannot just build an address
- expression here, because we would not handle
- address-constant-expressions or offsetof correctly. */
tree field = TREE_OPERAND (arg, 1);
tree rval = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0);
tree binfo = lookup_base (TREE_TYPE (TREE_TYPE (rval)),
ba_check, NULL);
rval = build_base_path (PLUS_EXPR, rval, binfo, 1);
- rval = build_nop (argtype, rval);
- addr = fold (build2 (PLUS_EXPR, argtype, rval,
- cp_convert (argtype,
- byte_position (field))));
+
+ TREE_OPERAND (arg, 0) = build_indirect_ref (rval, NULL);
+ addr = build_address (arg);
}
if (TREE_CODE (argtype) == POINTER_TYPE
else if (TYPE_NEEDS_CONSTRUCTING (type))
return build2 (INIT_EXPR, type, decl, value);
else if (TREE_STATIC (decl)
- && (! TREE_CONSTANT (value)
+ && (TREE_SIDE_EFFECTS (value)
|| ! initializer_constant_valid_p (value, TREE_TYPE (value))))
return split_nonconstant_init (decl, value);