* decl.c (tag_name): New fn.
(xref_tag): Complain about using typedef-name after class-key.
Fixes Sec7/1_3/C07351.cm.
* init.c (expand_vec_init): Also keep going if from_array.
Fixes g++.other/copy1.C.
* tree.c (is_overloaded_fn): Also handle the output of
build_offset_ref.
Fixes Sec5/3_3/S05162.C.
* decl.c (grokdeclarator): Use constructor_name when comparing
field name against enclosing class.
* class.c (finish_struct_anon): Likewise.
Fixes Sec9/2/C09268.cm.
From-SVN: r23758
+1998-11-22 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (tag_name): New fn.
+ (xref_tag): Complain about using typedef-name after class-key.
+
+ * init.c (expand_vec_init): Also keep going if from_array.
+
+ * tree.c (is_overloaded_fn): Also handle the output of
+ build_offset_ref.
+
+ * decl.c (grokdeclarator): Use constructor_name when comparing
+ field name against enclosing class.
+ * class.c (finish_struct_anon): Likewise.
+
1998-11-22 Mark Mitchell <mark@markmitchell.com>
* decl.c (poplevel): Remove code to handle KEEP == 2.
if (DECL_ARTIFICIAL (*uelt))
continue;
- if (DECL_NAME (*uelt) == TYPE_IDENTIFIER (t))
+ if (DECL_NAME (*uelt) == constructor_name (t))
cp_pedwarn_at ("ANSI C++ forbids member `%D' with same name as enclosing class",
*uelt);
if (decl_context == FIELD)
{
- if (declarator == current_class_name)
+ if (declarator == constructor_name (current_class_type))
cp_pedwarn ("ANSI C++ forbids nested type `%D' with same name as enclosing class",
declarator);
decl = build_lang_decl (TYPE_DECL, declarator, type);
}
/* 9.2p13 [class.mem] */
- if (declarator == current_class_name)
+ if (declarator == constructor_name (current_class_type))
cp_pedwarn ("ANSI C++ forbids data member `%D' with same name as enclosing class",
declarator);
}
}
\f
+static char *
+tag_name (code)
+ enum tag_types code;
+{
+ switch (code)
+ {
+ case record_type:
+ return "struct";
+ case class_type:
+ return "class";
+ case union_type:
+ return "union ";
+ case enum_type:
+ return "enum";
+ case signature_type:
+ return "signature";
+ default:
+ my_friendly_abort (981122);
+ }
+}
+
/* Get the struct, enum or union (CODE says which) with tag NAME.
Define the tag as a forward-reference if it is not defined.
else
{
if (t)
- ref = t;
+ {
+ if (t != TYPE_MAIN_VARIANT (t))
+ cp_pedwarn ("using typedef-name `%D' after `%s'",
+ TYPE_NAME (t), tag_name (tag_code));
+ ref = t;
+ }
else
ref = lookup_tag (code, name, b, 0);
tree elts;
tree baseref = build1 (INDIRECT_REF, type, base);
+ from_array = 0;
+
for (elts = CONSTRUCTOR_ELTS (init); elts; elts = TREE_CHAIN (elts))
{
tree elt = TREE_VALUE (elts);
/* Now, default-initialize any remaining elements. We don't need to
do that if a) the type does not need constructing, or b) we've
- already initialized all the elements. */
- if (TYPE_NEEDS_CONSTRUCTING (type)
- && !(TREE_CODE (maxindex) == INTEGER_CST
- && num_initialized_elts == TREE_INT_CST_LOW (maxindex) + 1))
+ already initialized all the elements.
+
+ We do need to keep going if we're copying an array. */
+
+ if (from_array
+ || (TYPE_NEEDS_CONSTRUCTING (type)
+ && !(TREE_CODE (maxindex) == INTEGER_CST
+ && num_initialized_elts == TREE_INT_CST_LOW (maxindex) + 1)))
{
/* If the ITERATOR is equal to -1, then we don't have to loop;
we've already initialized all the elements. */
tree x;
{
/* XXX A baselink is also considered an overloaded function.
- As is a placeholder from push_class_decls. */
+ As is a placeholder from push_class_decls.
+ As is an expression like X::f. */
if (TREE_CODE (x) == TREE_LIST)
{
+ if (TREE_PURPOSE (x) == error_mark_node)
+ {
+ x = TREE_VALUE (x);
+ my_friendly_assert (TREE_CODE (x) == TREE_LIST, 981121);
+ }
my_friendly_assert (TREE_CODE (TREE_PURPOSE (x)) == TREE_VEC
|| TREE_CODE (TREE_PURPOSE (x)) == IDENTIFIER_NODE,
388);