[C++ PATCH] Fix implicit assignment operators with anonymous aggregates
Jason Merrill
jason@redhat.com
Wed Mar 21 08:10:00 GMT 2001
>>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:
> + if (TREE_CODE (field) == FIELD_DECL)
> + {
> + type = TREE_TYPE (field);
> + if (CLASS_TYPE_P (type) && TYPE_HAS_COMPLEX_ASSIGN_REF (type))
> + cp_error_at ("member %#D' with copy assignment operator not allowed in anonymous aggregate", field);
> + }
Let's also check for copy ctor and destructor, while we're at it.
> /* Make sure that a declaration with no declarator is well-formed, i.e.
> --- gcc/cp/typeck.c.jj Mon Mar 12 11:45:35 2001
> +++ gcc/cp/typeck.c Wed Mar 21 11:41:50 2001
> @@ -5596,6 +5596,11 @@ build_modify_expr (lhs, modifycode, rhs)
> }
> else if (modifycode == NOP_EXPR)
> {
> + /* Anonymous aggregates don't have any methods, so avoid calling
> + them. */
> + if (ANON_AGGR_TYPE_P (lhstype))
> + return build (MODIFY_EXPR, lhstype, lhs, rhs);
> +
> /* `operator=' is not an inheritable operator. */
> if (! IS_AGGR_TYPE (lhstype))
> /* Do the default thing */;
Is there a reason we shouldn't "Do the default thing" for anonymous
aggregates? If so, maybe this logic belongs in do_build_assign_ref after
all.
Jason
More information about the Gcc-patches
mailing list