+2001-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ * method.c (do_build_assign_ref): Don't use build_modify_expr for
+ anonymous aggregates, since they don't have assignment operator
+ method.
+ * decl.c (fixup_anonymous_aggr): Disallow ctors, dtors and copy
+ assignment operators for anonymous structure fields.
+
2001-03-21 Jason Merrill <jason@redhat.com>
* pt.c (instantiate_decl): Abort if we see a member constant
/* ISO C++ 9.5.3. Anonymous unions may not have function members. */
if (TYPE_METHODS (t))
cp_error_at ("an anonymous union cannot have function members", t);
+
+ /* Anonymous aggregates cannot have fields with ctors, dtors or complex
+ assignment operators (because they cannot have these methods themselves).
+ For anonymous unions this is already checked because they are not allowed
+ in any union, otherwise we have to check it. */
+ if (TREE_CODE (t) != UNION_TYPE)
+ {
+ tree field, type;
+
+ for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+ if (TREE_CODE (field) == FIELD_DECL)
+ {
+ type = TREE_TYPE (field);
+ if (CLASS_TYPE_P (type))
+ {
+ if (TYPE_NEEDS_CONSTRUCTING (type))
+ cp_error_at ("member %#D' with constructor not allowed in anonymous aggregate",
+ field);
+ if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
+ cp_error_at ("member %#D' with destructor not allowed in anonymous aggregate",
+ field);
+ if (TYPE_HAS_COMPLEX_ASSIGN_REF (type))
+ cp_error_at ("member %#D' with copy assignment operator not allowed in anonymous aggregate",
+ field);
+ }
+ }
+ }
}
/* Make sure that a declaration with no declarator is well-formed, i.e.
build_qualified_type (TREE_TYPE (field), cvquals),
init, field);
- finish_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
+ if (DECL_NAME (field))
+ finish_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
+ else
+ finish_expr_stmt (build (MODIFY_EXPR, TREE_TYPE (comp), comp,
+ init));
}
}
finish_return_stmt (current_class_ref);
+2001-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ * g++.old-deja/g++.other/anon8.C: New test.
+
2001-03-20 Philip Blundell <philb@gnu.org>
* gcc.c-torture/compile/20010320-1.c: New test.