decl.c (tag_name): New fn.
authorJason Merrill <jason@yorick.cygnus.com>
Sun, 22 Nov 1998 21:34:27 +0000 (21:34 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 22 Nov 1998 21:34:27 +0000 (16:34 -0500)
* 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

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/init.c
gcc/cp/tree.c

index 15b37aaba8f33169312405273d5467ed4d7a31e4..91d64dd098bce11f3f416cb94927a7ca0888bcd8 100644 (file)
@@ -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.
index 6e89ce538c9d6221508f035ca1d3358ad619a29a..9ade20159fbbd2c8015281472fa42419976d1504 100644 (file)
@@ -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);
 
index d50c5eaa39367958003e6889b01e5cc6a82f1b0a..b28b82c067d297087fff8943c4a1f008d79bdcb7 100644 (file)
@@ -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)
     }
 }
 \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.
 
@@ -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);
          
index 76271b77271d5af06102ec18da19a7d307656de6..fd528141d07269a4839982a5fe680f368ba6c032 100644 (file)
@@ -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.  */
index 8be0f987aca7db5bd688f4534ecff85a11ad2abe..21401898da9cdc2771420ec7de0e9a42526c4787 100644 (file)
@@ -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);