]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.cp/misc.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / misc.exp
index bd2353a266e6b0cbe9cadfadf1237ecaa4c57db2..8a8844459621e443a415dbc55165af17b42cd854 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright 1992-2022 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
@@ -19,7 +19,7 @@ if { [skip_cplus_tests] } { continue }
 
 standard_testfile .cc
 
-if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
     return -1
 }
 
@@ -49,17 +49,13 @@ proc test_expr { args } {
     if { [llength $args] % 2 } {
        warning "an even # of arguments should be passed to test_expr"
     }
-    set last_ent [expr [llength $args] - 1];
-    set testname [lindex $args $last_ent];
-    if [gdb_test_no_output [lindex $args 0] "$testname (setup)"] {
-       gdb_suppress_tests;
-    }
+    set last_ent [expr [llength $args] - 1]
+    set testname [lindex $args $last_ent]
+    gdb_test_no_output [lindex $args 0] "$testname (setup)"
+
     for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
-       if [gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"] {
-           gdb_suppress_tests;
-       }
+       gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"
     }
-    gdb_stop_suppressing_tests;
 }
 
 proc do_tests {} {
@@ -93,8 +89,8 @@ test_expr "set variable v_bool_array\[1\] = true" \
     "set a bool array elem"
 
 # bool constants
-gdb_test "print true" "\\$\[0-9\]* = true" "print true"
-gdb_test "print false" "\\$\[0-9\]* = false" "print false"
+gdb_test "print true" "\\$\[0-9\]* = true"
+gdb_test "print false" "\\$\[0-9\]* = false"
 
 # arithmetic conversions
 gdb_test "print 1 + true" "\\$\[0-9\]* = 2" "1 + true"
@@ -110,3 +106,11 @@ gdb_test "print (int)false" "\\$\[0-9\]* = 0" "(int)false"
 
 gdb_test "print 'misc.cc'::v_bool" " = true" \
     "expression using block qualifier"
+
+# pointer arithmetic
+gdb_test "print *(v_bool_array + number_ref)" "\\$\[0-9\]* = false" \
+    "pointer addition with integer reference"
+gdb_test "print *(number_ref + v_bool_array)" "\\$\[0-9\]* = false" \
+    "integer reference addition with pointer"
+gdb_test "print *(v_bool_array - number_ref)" "\\$\[0-9\]* = false" \
+    "pointer subtraction with integer reference"