aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-04-07 17:47:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-04-07 17:47:17 -0400
commit351ccf209e1e4495534044e3cd77ee03f32bdda2 (patch)
tree1082ced58f08d7332de2d310c6d76893c8dee5c6 /gcc/cp/init.c
parent2b8497cd7aef2697b00b7e57ae3ea787f7cbe251 (diff)
downloadgcc-351ccf209e1e4495534044e3cd77ee03f32bdda2.zip
gcc-351ccf209e1e4495534044e3cd77ee03f32bdda2.tar.gz
gcc-351ccf209e1e4495534044e3cd77ee03f32bdda2.tar.bz2
init.c (build_value_init_noctor): Handle REFERENCE_TYPE at top level.
* init.c (build_value_init_noctor): Handle REFERENCE_TYPE at top level. (perform_member_init): Not here. * typeck2.c (build_functional_cast): Limit REFERENCE_TYPE special case to templates. (abstract_virtuals_error_sfinae): Remove RESULT_DECL special case. From-SVN: r172142
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 2e9eb680..005f8d6 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -388,14 +388,6 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
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
@@ -408,6 +400,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
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);
}
@@ -450,6 +445,9 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
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);
@@ -464,6 +462,12 @@ build_value_init_noctor (tree type, tsubst_flags_t complain)
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);
}
@@ -504,16 +508,9 @@ perform_member_init (tree member, tree init)
}
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