]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
call.c (build_scoped_method_call): Use convert_to_void.
authorMark Mitchell <mark@codesourcery.com>
Thu, 3 Jul 2003 18:13:44 +0000 (18:13 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 3 Jul 2003 18:13:44 +0000 (18:13 +0000)
* call.c (build_scoped_method_call): Use convert_to_void.
(build_method_call): Likewise.
* class.c (check_field_decls): Remove dead code.
* cvt.c (convert_from_reference): Remove OFFSET_TYPE handling.
* decl2.c (grok_array_decl): Remove dead code.
(arg_assoc_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
as pointer-to-member representation.
* init.c (build_offset_ref): Tidy.
(build_vec_delete_1): Use convert_to_void.
* mangle.c (write_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
as pointer-to-member representation.

From-SVN: r68895

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cvt.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/mangle.c

index f75b8ac4a4f4d1c72f6df09c9607d419f72aeb64..1e75a34f95cfdd9de44093b62fd86ca4ad199060 100644 (file)
@@ -1,3 +1,17 @@
+2003-07-03  Mark Mitchell  <mark@codesourcery.com>
+
+       * call.c (build_scoped_method_call): Use convert_to_void.
+       (build_method_call): Likewise.
+       * class.c (check_field_decls): Remove dead code.
+       * cvt.c (convert_from_reference): Remove OFFSET_TYPE handling.
+       * decl2.c (grok_array_decl): Remove dead code.
+       (arg_assoc_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
+       as pointer-to-member representation.
+       * init.c (build_offset_ref): Tidy.
+       (build_vec_delete_1): Use convert_to_void.
+       * mangle.c (write_type): Avoid relying on POINTER_TYPE over OFFSET_TYPE
+       as pointer-to-member representation.
+       
 2003-07-03  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/9162
index 6e5bc8f5d4943c654d0457af6464d3af229b26d9..bc1179b6cb0037daa1125576b853dd4704a4d326 100644 (file)
@@ -263,7 +263,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms)
            error ("type of `%E' does not match destructor type `%T' (type was `%T')",
                      exp, basetype, type);
 
-         return cp_convert (void_type_node, exp);
+         return convert_to_void (exp, /*implicit=*/NULL);
        }
     }
 
@@ -290,7 +290,7 @@ build_scoped_method_call (tree exp, tree basetype, tree name, tree parms)
       if (TREE_CODE (name) == BIT_NOT_EXPR)
        {
          if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (decl)))
-           return cp_convert (void_type_node, exp);
+           return convert_to_void (exp, /*implicit=*/NULL);
          
          return build_delete (TREE_TYPE (decl), decl, 
                               sfk_complete_destructor,
@@ -496,7 +496,7 @@ build_method_call (tree instance, tree name, tree parms,
           TREE_OPERAND (name, 0), object_type);
 
       if (! TYPE_HAS_DESTRUCTOR (complete_type (object_type)))
-       return cp_convert (void_type_node, instance);
+       return convert_to_void (instance, /*implicit=*/NULL);
       instance = default_conversion (instance);
       instance_ptr = build_unary_op (ADDR_EXPR, instance, 0);
       return build_delete (build_pointer_type (object_type),
index 09688b68a037fddc3ed90cbc6e3dffd600c897a9..978e8447b749e50282999c0f5e664257fbc503eb 100644 (file)
@@ -3091,12 +3091,6 @@ check_field_decls (tree t, tree *access_decls,
          type = build_pointer_type (type);
          TREE_TYPE (x) = type;
        }
-      else if (TREE_CODE (type) == OFFSET_TYPE)
-       {
-         cp_error_at ("field `%D' invalidly declared offset type", x);
-         type = build_pointer_type (type);
-         TREE_TYPE (x) = type;
-       }
 
       if (type == error_mark_node)
        continue;
index 2078a67b0160477bb12307f40dce2cf350c9d824..29f02226af05fcd9a58e52321845f6e1afd0d848 100644 (file)
@@ -552,11 +552,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
 tree
 convert_from_reference (tree val)
 {
-  tree type = TREE_TYPE (val);
-
-  if (TREE_CODE (type) == OFFSET_TYPE)
-    type = TREE_TYPE (type);
-  if (TREE_CODE (type) == REFERENCE_TYPE)
+  if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
     return build_indirect_ref (val, NULL);
   return val;
 }
index ab29aeed45d1dd275189e067105e6344c348d483..f70103788976f90dda20d93959959f648374a359 100644 (file)
@@ -407,16 +407,9 @@ grok_array_decl (tree array_expr, tree index_exp)
     return build_min (ARRAY_REF, type ? TREE_TYPE (type) : NULL_TREE,
                      array_expr, index_exp);
 
-  if (type == NULL_TREE)
-    {
-      /* Something has gone very wrong.  Assume we are mistakenly reducing
-        an expression instead of a declaration.  */
-      error ("parser may be lost: is there a '{' missing somewhere?");
-      return NULL_TREE;
-    }
+  my_friendly_assert (type, 20030626);
 
-  if (TREE_CODE (type) == OFFSET_TYPE
-      || TREE_CODE (type) == REFERENCE_TYPE)
+  if (TREE_CODE (type) == REFERENCE_TYPE)
     type = TREE_TYPE (type);
 
   /* If they have an `operator[]', use that.  */
@@ -4069,8 +4062,15 @@ arg_assoc_type (struct arg_lookup *k, tree type)
      right, we can end up with such things without a type.  */
   if (!type)
     return false;
-  
-  switch (TREE_CODE (type))
+
+  if (TYPE_PTRMEM_P (type))
+    {
+      /* Pointer to member: associate class type and value type.  */
+      if (arg_assoc_type (k, TYPE_PTRMEM_CLASS_TYPE (type)))
+       return true;
+      return arg_assoc_type (k, TYPE_PTRMEM_POINTED_TO_TYPE (type));
+    }
+  else switch (TREE_CODE (type))
     {
     case ERROR_MARK:
       return false;
@@ -4093,11 +4093,6 @@ arg_assoc_type (struct arg_lookup *k, tree type)
     case UNION_TYPE:
     case ENUMERAL_TYPE:
       return arg_assoc_namespace (k, decl_namespace (TYPE_MAIN_DECL (type)));
-    case OFFSET_TYPE:
-      /* Pointer to member: associate class type and value type.  */
-      if (arg_assoc_type (k, TYPE_OFFSET_BASETYPE (type)))
-       return true;
-      return arg_assoc_type (k, TREE_TYPE (type));
     case METHOD_TYPE:
       /* The basetype is referenced in the first arg type, so just
         fall through.  */
index 710f61744131367a15a7f628b55b86b99f98f2c4..b88f1f24243db7ca4dee254655d39d45f6c18b17 100644 (file)
@@ -1501,7 +1501,7 @@ build_member_call (tree type, tree name, tree parmlist)
 tree
 build_offset_ref (tree type, tree name)
 {
-  tree decl, t = error_mark_node;
+  tree decl;
   tree member;
   tree basebinfo = NULL_TREE;
   tree orig_name = name;
@@ -1546,7 +1546,7 @@ build_offset_ref (tree type, tree name)
   /* Handle namespace names fully here.  */
   if (TREE_CODE (type) == NAMESPACE_DECL)
     {
-      t = lookup_namespace_name (type, name);
+      tree t = lookup_namespace_name (type, name);
       if (t == error_mark_node)
         return t;
       if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
@@ -1597,7 +1597,7 @@ build_offset_ref (tree type, tree name)
     {
       /* Go from the TREE_BASELINK to the member function info.  */
       tree fnfields = member;
-      t = BASELINK_FUNCTIONS (fnfields);
+      tree t = BASELINK_FUNCTIONS (fnfields);
 
       if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
        {
@@ -1644,44 +1644,43 @@ build_offset_ref (tree type, tree name)
       return t;
     }
 
-  t = member;
-
-  if (t == NULL_TREE)
+  if (member == NULL_TREE)
     {
       error ("`%D' is not a member of type `%T'", name, type);
       return error_mark_node;
     }
 
-  if (TREE_CODE (t) == TYPE_DECL)
+  if (TREE_CODE (member) == TYPE_DECL)
     {
-      TREE_USED (t) = 1;
-      return t;
+      TREE_USED (member) = 1;
+      return member;
     }
   /* static class members and class-specific enum
      values can be returned without further ado.  */
-  if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == CONST_DECL)
+  if (TREE_CODE (member) == VAR_DECL || TREE_CODE (member) == CONST_DECL)
     {
-      mark_used (t);
-      return convert_from_reference (t);
+      mark_used (member);
+      return convert_from_reference (member);
     }
 
-  if (TREE_CODE (t) == FIELD_DECL && DECL_C_BIT_FIELD (t))
+  if (TREE_CODE (member) == FIELD_DECL && DECL_C_BIT_FIELD (member))
     {
-      error ("invalid pointer to bit-field `%D'", t);
+      error ("invalid pointer to bit-field `%D'", member);
       return error_mark_node;
     }
 
   /* static class functions too.  */
-  if (TREE_CODE (t) == FUNCTION_DECL
-      && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
+  if (TREE_CODE (member) == FUNCTION_DECL
+      && TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE)
     abort ();
 
   /* In member functions, the form `type::name' is no longer
      equivalent to `this->type::name', at least not until
      resolve_offset_ref.  */
-  t = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (t)), decl, t);
-  PTRMEM_OK_P (t) = 1;
-  return t;
+  member = build (OFFSET_REF, build_offset_type (type, TREE_TYPE (member)), 
+                 decl, member);
+  PTRMEM_OK_P (member) = 1;
+  return member;
 }
 
 /* If a OFFSET_REF made it through to here, then it did
@@ -2625,7 +2624,7 @@ build_vec_delete_1 (tree base, tree maxindex, tree type,
     /* Pre-evaluate the SAVE_EXPR outside of the BIND_EXPR.  */
     body = build (COMPOUND_EXPR, void_type_node, base, body);
 
-  return cp_convert (void_type_node, body);
+  return convert_to_void (body, /*implicit=*/NULL);
 }
 
 /* Create an unnamed variable of the indicated TYPE.  */ 
index 833220cb3e2dc170a1c493fc7327a0e620759249..27f5c7faae30c79666cf03a1c2e57cc16fd55853 100644 (file)
@@ -1441,7 +1441,9 @@ write_type (tree type)
       /* See through any typedefs.  */
       type = TYPE_MAIN_VARIANT (type);
 
-      switch (TREE_CODE (type))
+      if (TYPE_PTRMEM_P (type))
+       write_pointer_to_member_type (type);
+      else switch (TREE_CODE (type))
        {
        case VOID_TYPE:
        case BOOLEAN_TYPE:
@@ -1483,15 +1485,8 @@ write_type (tree type)
          break;
 
        case POINTER_TYPE:
-         /* A pointer-to-member variable is represented by a POINTER_TYPE
-            to an OFFSET_TYPE, so check for this first.  */
-         if (TYPE_PTRMEM_P (type))
-           write_pointer_to_member_type (type);
-         else
-           {
-             write_char ('P');
-             write_type (TREE_TYPE (type));
-           }
+         write_char ('P');
+         write_type (TREE_TYPE (type));
          break;
 
        case REFERENCE_TYPE:
@@ -1514,10 +1509,6 @@ write_type (tree type)
            (TI_ARGS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (type)));
          break;
 
-       case OFFSET_TYPE:
-         write_pointer_to_member_type (build_pointer_type (type));
-         break;
-
        case VECTOR_TYPE:
          write_string ("U8__vector");
          write_type (TREE_TYPE (type));