* gdb.base/exprs.exp: Test casts to a pointer including over and
authorAndrew Cagney <cagney@redhat.com>
Mon, 17 Jul 2000 02:56:12 +0000 (02:56 +0000)
committerAndrew Cagney <cagney@redhat.com>
Mon, 17 Jul 2000 02:56:12 +0000 (02:56 +0000)
underflow.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/exprs.exp

index 585da04b198a4f13131877211cd91e00799d804e..5179eaa872da4e29fb633e2cfaa98b0e4df9f8fa 100644 (file)
@@ -1,3 +1,8 @@
+Wed Jul 12 18:14:29 2000  Andrew Cagney  <cagney@b1.cygnus.com>
+
+       * gdb.base/exprs.exp: Test casts to a pointer including over and
+       underflow.
+
 Thu Jul 13 11:52:53 2000  Andrew Cagney  <cagney@b1.cygnus.com>
 
        * gdb.base/sizeof.exp, gdb.base/sizeof.c: New files.  Compare GDB
index f31407c458499321920e8d157f336bba68f3bc83..925a90231f8b9fb90b007eef70f9fee1b3def30d 100644 (file)
@@ -1,4 +1,5 @@
-#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+#   Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997, 2000 Free
+#   Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -215,3 +216,44 @@ test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long == 0" "\\$\[0
 test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long != 0" "\\$\[0-9\]* = $true"  "print v_unsigned_long != (unsigned long)~0" "\\$\[0-9\]* = $false"  "print unsigned long != (~0)"
 test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long < 0" "\\$\[0-9\]* = $false"  "print v_unsigned_long < 0x7FFF" "\\$\[0-9\]* = $false"  "print unsigned long < (~0)"
 test_expr "set variable v_unsigned_long=~0" "print v_unsigned_long > 0" "\\$\[0-9\]* = $true"  "print v_unsigned_long > 0x7FFF" "\\$\[0-9\]* = $true"  "print unsigned long > (~0)"
+#
+# Test expressions with casts to a pointer.
+# NB: Some architectures convert a ``NULL'' pointer into
+#     something else. Don't simply test for 0.
+#
+test_expr "set variable v_signed_char = 0" "print (void*)v_signed_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_char"
+test_expr "set variable v_signed_short = 0" "print (void*)v_signed_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_short"
+test_expr "set variable v_signed_int = 0" "print (void*)v_signed_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_int"
+test_expr "set variable v_signed_long = 0" "print (void*)v_signed_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_signed_long"
+test_expr "set variable v_unsigned_char = 0" "print (void*)v_unsigned_char" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_char"
+test_expr "set variable v_unsigned_short = 0" "print (void*)v_unsigned_short" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_short"
+test_expr "set variable v_unsigned_int = 0" "print (void*)v_unsigned_int" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_int"
+test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$\[0-9\]* = .void \\*. $hex" "print (void*)v_unsigned_long"
+#
+# Test expressions with pointers out of range
+#
+# NB: For some architectures, all of sizeof(long),
+#     sizeof(long long) and sizeof(void*) are
+#     the same size so this test can not work.
+#
+send_gdb "print sizeof (long long) > sizeof (long)\n"
+gdb_expect {
+    -re "\\$\[0-9\]* = $true" {
+       set ok 1
+       pass "sizeof (long long) > sizeof (long) (true)"
+    }
+    -re "\\$\[0-9\]* = $false" {
+       set ok 0
+       pass "sizeof (long long) > sizeof (long) (false)"
+    }
+    timeout {
+       set ok 0
+       fail "sizeof (long long) > sizeof (long) (timeout)"
+    }
+}
+if [expr ! $ok] { setup_xfail "*-*-*" }
+gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
+       "warning: value truncated.*" "truncate (void*) 0x00000000ffffffff + 1"
+if [expr ! $ok] { setup_xfail "*-*-*" }
+gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
+       "warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1"
This page took 0.036944 seconds and 4 git commands to generate.