cvt.c (cp_convert_to_pointer): Fix base conversion of pm's.
authorJason Merrill <jason@yorick.cygnus.com>
Mon, 15 Dec 1997 07:24:29 +0000 (07:24 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 15 Dec 1997 07:24:29 +0000 (02:24 -0500)
* cvt.c (cp_convert_to_pointer): Fix base conversion of pm's.

* pt.c (type_unification_real): Change __null to type void* with
a warning.

From-SVN: r17098

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/cp/pt.c

index ef5907892f0c985b71b8514d133f0e67aa5e3485..0a628dacddaf9830368b8415453d2343303a5db5 100644 (file)
@@ -1,3 +1,10 @@
+Sun Dec 14 22:34:20 1997  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * cvt.c (cp_convert_to_pointer): Fix base conversion of pm's.
+
+       * pt.c (type_unification_real): Change __null to type void* with 
+       a warning.
+
 Sun Dec 14 20:38:35 1997  Mark Mitchell  <mmitchell@usa.net>
 
        * call.c (implicit_conversion): Don't call
index 299649280055997126d30ac20f4af55ace03b0fd..fdfdb7f27906b0048cfdb07e2a604b53a06f5e0b 100644 (file)
@@ -258,11 +258,19 @@ cp_convert_to_pointer (type, expr)
        {
          tree b1 = TYPE_OFFSET_BASETYPE (TREE_TYPE (type));
          tree b2 = TYPE_OFFSET_BASETYPE (TREE_TYPE (intype));
-         tree binfo = get_binfo (b1, b2, 1);
+         tree binfo = get_binfo (b2, b1, 1);
+         enum tree_code code = PLUS_EXPR;
+
          if (binfo == NULL_TREE)
-           binfo = get_binfo (b2, b1, 1);
+           {
+             binfo = get_binfo (b1, b2, 1);
+             code = MINUS_EXPR;
+           }
+
          if (binfo == error_mark_node)
            return error_mark_node;
+         if (binfo && ! TREE_VIA_VIRTUAL (binfo))
+           expr = size_binop (code, expr, BINFO_OFFSET (binfo));
        }
 
       if (TREE_CODE (TREE_TYPE (intype)) == METHOD_TYPE
index e3bfb34356b6f9f3b6eeae8a442a7cd59c525f66..8dff4c1a01bf3c8cb0701c6a2974f3b822058fe6 100644 (file)
@@ -3722,6 +3722,12 @@ type_unification_real (tparms, targs, parms, args, nsubsts, subr,
          arg = TREE_TYPE (arg);
        }
 #endif
+      if (! flag_ansi && arg == TREE_TYPE (null_node))
+       {
+         warning ("using type void* for NULL");
+         arg = ptr_type_node;
+       }
+
       if (! subr && TREE_CODE (arg) == REFERENCE_TYPE)
        arg = TREE_TYPE (arg);