aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/typeck2.c')
-rw-r--r--gcc/cp/typeck2.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index c62949ef405..b2a63c7efd1 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -814,12 +814,18 @@ process_init_constructor (type, init, elts)
next1 = build_functional_cast (TREE_TYPE (field),
NULL_TREE);
else
- next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE,
- NULL_TREE);
+ {
+ next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE,
+ NULL_TREE);
+ if (init)
+ TREE_HAS_CONSTRUCTOR (next1)
+ = TREE_HAS_CONSTRUCTOR (init);
+ }
next1 = digest_init (TREE_TYPE (field), next1, 0);
/* Warn when some struct elements are implicitly initialized. */
- if (extra_warnings)
+ if (extra_warnings
+ && (!init || TREE_HAS_CONSTRUCTOR (init)))
cp_warning ("missing initializer for member `%D'", field);
}
else
@@ -835,7 +841,8 @@ process_init_constructor (type, init, elts)
/* Warn when some struct elements are implicitly initialized
to zero. */
- if (extra_warnings)
+ if (extra_warnings
+ && (!init || TREE_HAS_CONSTRUCTOR (init)))
cp_warning ("missing initializer for member `%D'", field);
/* The default zero-initialization is fine for us; don't
@@ -1086,6 +1093,9 @@ build_m_component_ref (datum, component)
return build_min_nt (DOTSTAR_EXPR, datum, component);
datum = decay_conversion (datum);
+ if (datum == error_mark_node || component == error_mark_node)
+ return error_mark_node;
+
objtype = TYPE_MAIN_VARIANT (TREE_TYPE (datum));
if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
@@ -1093,18 +1103,18 @@ build_m_component_ref (datum, component)
type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
field_type = type;
}
- else
+ else if (TYPE_PTRMEM_P (TREE_TYPE (component)))
{
type = TREE_TYPE (TREE_TYPE (component));
field_type = TREE_TYPE (type);
}
-
- if (datum == error_mark_node || component == error_mark_node)
- return error_mark_node;
+ else
+ type = error_mark_node;
if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
{
- cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
+ cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'",
+ component, TREE_TYPE (component));
return error_mark_node;
}