aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-11-22 21:34:27 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-11-22 16:34:27 -0500
commit094fe153c47e21f0c332ad277babde2858600ab4 (patch)
treeafde2aba1f0d1acfbc460eaa557cb7a2935d2841 /gcc
parent8190f0737fd9a7b86b505c342c7cd894397ede35 (diff)
downloadgcc-094fe153c47e21f0c332ad277babde2858600ab4.zip
gcc-094fe153c47e21f0c332ad277babde2858600ab4.tar.gz
gcc-094fe153c47e21f0c332ad277babde2858600ab4.tar.bz2
decl.c (tag_name): New fn.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog14
-rw-r--r--gcc/cp/class.c2
-rw-r--r--gcc/cp/decl.c32
-rw-r--r--gcc/cp/init.c14
-rw-r--r--gcc/cp/tree.c8
5 files changed, 61 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 15b37aa..91d64dd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,17 @@
+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.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 6e89ce5..9ade201 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -3143,7 +3143,7 @@ finish_struct_anon (t)
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);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d50c5ea..b28b82c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10299,7 +10299,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
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);
@@ -10781,7 +10781,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
}
/* 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);
@@ -11703,6 +11703,27 @@ grok_op_properties (decl, virtualp, friendp)
}
}
+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.
@@ -11817,7 +11838,12 @@ xref_tag (code_type_node, name, globalize)
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);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 76271b7..fd52814 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2798,6 +2798,8 @@ expand_vec_init (decl, base, maxindex, init, from_array)
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);
@@ -2853,10 +2855,14 @@ expand_vec_init (decl, base, maxindex, init, from_array)
/* 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. */
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 8be0f98..2140189 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1294,9 +1294,15 @@ is_overloaded_fn (x)
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);