ftype = TREE_TYPE (field);
- if (TREE_CODE (ftype) == REFERENCE_TYPE)
- {
- if (complain & tf_error)
- error ("value-initialization of reference");
- else
- return error_mark_node;
- }
-
/* We could skip vfields and fields of types with
user-defined constructors, but I think that won't improve
performance at all; it should be simpler in general just
all of the subobjects. */
value = build_value_init (ftype, complain);
+ if (value == error_mark_node)
+ return error_mark_node;
+
if (value)
CONSTRUCTOR_APPEND_ELT(v, field, value);
}
ce->value = build_value_init (TREE_TYPE (type), complain);
+ if (ce->value == error_mark_node)
+ return error_mark_node;
+
/* The gimplifier can't deal with a RANGE_EXPR of TARGET_EXPRs. */
gcc_assert (TREE_CODE (ce->value) != TARGET_EXPR
&& TREE_CODE (ce->value) != AGGR_INIT_EXPR);
error ("value-initialization of function type %qT", type);
return error_mark_node;
}
+ else if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ if (complain & tf_error)
+ error ("value-initialization of reference type %qT", type);
+ return error_mark_node;
+ }
return build_zero_init (type, NULL_TREE, /*static_storage_p=*/false);
}
}
else
{
- if (TREE_CODE (type) == REFERENCE_TYPE)
- permerror (DECL_SOURCE_LOCATION (current_function_decl),
- "value-initialization of %q#D, which has reference type",
- member);
- else
- {
- init = build2 (INIT_EXPR, type, decl,
- build_value_init (type, tf_warning_or_error));
- finish_expr_stmt (init);
- }
+ init = build2 (INIT_EXPR, type, decl,
+ build_value_init (type, tf_warning_or_error));
+ finish_expr_stmt (init);
}
}
/* Deal with this here, as we will get confused if we try to call the
if (!pure)
return 0;
- if (decl && TREE_CODE (decl) == RESULT_DECL)
- return 0;
-
if (!(complain & tf_error))
return 1;
else
type = exp;
- if (TREE_CODE (type) == REFERENCE_TYPE && !parms)
- {
- if (complain & tf_error)
- error ("invalid value-initialization of reference type");
- return error_mark_node;
- }
-
if (processing_template_decl)
{
- tree t = build_min (CAST_EXPR, type, parms);
+ tree t;
+
+ /* Diagnose this even in a template. We could also try harder
+ to give all the usual errors when the type and args are
+ non-dependent... */
+ if (TREE_CODE (type) == REFERENCE_TYPE && !parms)
+ {
+ if (complain & tf_error)
+ error ("invalid value-initialization of reference type");
+ return error_mark_node;
+ }
+
+ t = build_min (CAST_EXPR, type, parms);
/* We don't know if it will or will not have side effects. */
TREE_SIDE_EFFECTS (t) = 1;
return t;