* valops.c (value_cast): Allow cast from INT, ENUM or RANGE to
authorAndrew Cagney <cagney@redhat.com>
Wed, 12 Jul 2000 08:31:49 +0000 (08:31 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 12 Jul 2000 08:31:49 +0000 (08:31 +0000)
POINTER.

gdb/ChangeLog
gdb/valops.c

index 59ec071e38e185624d3b80ab2209d626887a824e..c23d07c697b259b23f8a839f91f6e5dea255f703 100644 (file)
@@ -1,3 +1,8 @@
+Tue Jul 11 19:45:42 2000  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * valops.c (value_cast): Allow cast from INT, ENUM or RANGE to
+       POINTER.
+
 2000-07-11  Scott Bambrough <scottb@netwinder.org>
 
        * command.c (do_setshow_command): Fix typo in var_auto_boolean
index 114a0356c6ecea0f3839e4b4debcdb1a730bcfe4..a32db08c9e2ebca9d61f70017daaf917788f76c7 100644 (file)
@@ -290,6 +290,20 @@ value_cast (type, arg2)
       return value_from_longest (type, convert_to_boolean ? 
                                 (LONGEST) (longest ? 1 : 0) : longest);
     }
+  else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT  || 
+                                    code2 == TYPE_CODE_ENUM ||
+                                    code2 == TYPE_CODE_RANGE))
+    {
+      int ptr_bit = HOST_CHAR_BIT * TYPE_LENGTH (type);
+      LONGEST longest = value_as_long (arg2);
+      if (ptr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
+       {
+         if (longest >= ((LONGEST) 1 << ptr_bit)
+             || longest <= -((LONGEST) 1 << ptr_bit))
+           warning ("value truncated");
+       }
+      return value_from_longest (type, longest);
+    }
   else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2))
     {
       if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)