[v2,17/37] GDB: testsuite: C++: Don't return value from top-level (manual)

Message ID 20260429230432.60487-18-thiago.bauermann@linaro.org
State New
Headers
Series GDB: testsuite: Fix top-level returns |

Commit Message

Thiago Jung Bauermann April 29, 2026, 11:04 p.m. UTC
  This patch manually changes "return -1" and "return 0" statements that
weren't caught by the sed command.

These return statements fall into one of these criteria:

- misaligned line, which is then fixed by this patch;
- return at top level but inside block such as save_vars,
  with_test_prefix, foreach, gdb_test_multiple.

Some weren't changed because they didn't meet the criteria above, or
weren't trivial to check.
---
 gdb/testsuite/gdb.cp/anon-struct.exp         |  2 +-
 gdb/testsuite/gdb.cp/converts.exp            |  2 +-
 gdb/testsuite/gdb.cp/cp-relocate.exp         |  8 ++++----
 gdb/testsuite/gdb.cp/cpsizeof.exp            |  2 +-
 gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp |  4 ++--
 gdb/testsuite/gdb.cp/fpointer.exp            |  2 +-
 gdb/testsuite/gdb.cp/koenig.exp              |  2 +-
 gdb/testsuite/gdb.cp/method2.exp             |  2 +-
 gdb/testsuite/gdb.cp/nsnested.exp            |  2 +-
 gdb/testsuite/gdb.cp/nsnoimports.exp         |  2 +-
 gdb/testsuite/gdb.cp/oranking.exp            |  2 +-
 gdb/testsuite/gdb.cp/pr10728.exp             | 12 ++++++------
 gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp   |  2 +-
 gdb/testsuite/gdb.cp/save-bp-qualified.exp   |  4 ++--
 gdb/testsuite/gdb.cp/smartp.exp              |  2 +-
 gdb/testsuite/gdb.cp/static-print-quit.exp   |  2 +-
 16 files changed, 26 insertions(+), 26 deletions(-)
  

Patch

diff --git a/gdb/testsuite/gdb.cp/anon-struct.exp b/gdb/testsuite/gdb.cp/anon-struct.exp
index e420d75207fd..10b7ce6c7766 100644
--- a/gdb/testsuite/gdb.cp/anon-struct.exp
+++ b/gdb/testsuite/gdb.cp/anon-struct.exp
@@ -18,11 +18,11 @@ 
 # for types and functions within anonymous structures.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 # Clang doesn't add any names for functions within anonymous structures,
 # so there is no way to try and refer to them inside GDB.
 if {[test_compiler_info clang-*-* c++]} {
diff --git a/gdb/testsuite/gdb.cp/converts.exp b/gdb/testsuite/gdb.cp/converts.exp
index 7d26db9f3022..60a732f87ee0 100644
--- a/gdb/testsuite/gdb.cp/converts.exp
+++ b/gdb/testsuite/gdb.cp/converts.exp
@@ -14,11 +14,11 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 ############################################
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index c42c67a95e75..67a9f21b9646 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -19,12 +19,12 @@  standard_testfile .cc
 append binfile .o
 
 require allow_cplus_tests
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {c++ debug}] != "" } {
-     untested "failed to compile"
-     return -1
+    untested "failed to compile"
+    return
 }
 
 proc get_func_address { func } {
     global gdb_prompt hex
 
@@ -65,11 +65,11 @@  gdb_test_multiple "info functions func<.>" "info functions" {
     -re "$gdb_prompt $" {
 	if { ${func1_name} != "" && ${func2_name} != "" } {
 	    pass "info functions"
 	} else {
 	    fail "info functions"
-	    return -1
+	    return
 	}
     }
 }
 
 # Check that all the functions have different addresses.
@@ -103,11 +103,11 @@  gdb_test_multiple "info file" "info file" {
     -re "$gdb_prompt $" {
 	if { ${func1_sec} != "" && ${func2_sec} != "" } {
 	    pass "info file"
 	} else {
 	    fail "info file"
-	    return -1
+	    return
 	}
     }
 }
 
 if { $func1_sec == $func2_sec } {
diff --git a/gdb/testsuite/gdb.cp/cpsizeof.exp b/gdb/testsuite/gdb.cp/cpsizeof.exp
index a43ae6431acf..239811855791 100644
--- a/gdb/testsuite/gdb.cp/cpsizeof.exp
+++ b/gdb/testsuite/gdb.cp/cpsizeof.exp
@@ -17,11 +17,11 @@ 
 standard_testfile .cc
 
 require allow_cplus_tests
 
 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}] } {
-     return -1
+    return
 }
 
 if {![runto_main]} {
     perror "could not run to main"
     return
diff --git a/gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp b/gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp
index 110970c89b8b..e0d34c86a11d 100644
--- a/gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp
+++ b/gdb/testsuite/gdb.cp/expand-psymtabs-cxx.exp
@@ -17,12 +17,12 @@ 
 
 standard_testfile .cc
 set executable ${testfile}
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug c++} ] != "" } {
-     untested "failed to compile"
-     return -1
+    untested "failed to compile"
+    return
 }
 
 clean_restart ${executable}
 
 gdb_test_no_output "set language c++"
diff --git a/gdb/testsuite/gdb.cp/fpointer.exp b/gdb/testsuite/gdb.cp/fpointer.exp
index a97eef7e55b6..f4f69a0532d6 100644
--- a/gdb/testsuite/gdb.cp/fpointer.exp
+++ b/gdb/testsuite/gdb.cp/fpointer.exp
@@ -17,11 +17,11 @@ 
 # complex expressions.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 if {![runto_main]} {
     return
 }
diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp
index 474c4a95b41e..4fd755ad7b7c 100644
--- a/gdb/testsuite/gdb.cp/koenig.exp
+++ b/gdb/testsuite/gdb.cp/koenig.exp
@@ -20,11 +20,11 @@  lappend opts debug
 lappend opts c++
 lappend opts additional_flags=-Wno-unused-comparison
 lappend opts additional_flags=-std=c++11
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
-     return -1
+    return
 }
 
 ############################################
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.cp/method2.exp b/gdb/testsuite/gdb.cp/method2.exp
index 4eed2197c36c..e64853ab7ae8 100644
--- a/gdb/testsuite/gdb.cp/method2.exp
+++ b/gdb/testsuite/gdb.cp/method2.exp
@@ -21,11 +21,11 @@ 
 require allow_cplus_tests
 
 standard_testfile .cc
 
 if  {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
-     return -1
+    return
 }
 
 if {![runto_main]} {
     return
 }
diff --git a/gdb/testsuite/gdb.cp/nsnested.exp b/gdb/testsuite/gdb.cp/nsnested.exp
index 8c1cef585a8d..11b326fa9b9c 100644
--- a/gdb/testsuite/gdb.cp/nsnested.exp
+++ b/gdb/testsuite/gdb.cp/nsnested.exp
@@ -14,11 +14,11 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 ############################################
 if {![runto_main]} {
     return
diff --git a/gdb/testsuite/gdb.cp/nsnoimports.exp b/gdb/testsuite/gdb.cp/nsnoimports.exp
index 3077e447c285..7c9e70ac3bf1 100644
--- a/gdb/testsuite/gdb.cp/nsnoimports.exp
+++ b/gdb/testsuite/gdb.cp/nsnoimports.exp
@@ -14,11 +14,11 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 ############################################
 if {![runto_main]} {
     return
diff --git a/gdb/testsuite/gdb.cp/oranking.exp b/gdb/testsuite/gdb.cp/oranking.exp
index f7a2f4636227..1f418a96a7db 100644
--- a/gdb/testsuite/gdb.cp/oranking.exp
+++ b/gdb/testsuite/gdb.cp/oranking.exp
@@ -14,11 +14,11 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 ############################################
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.cp/pr10728.exp b/gdb/testsuite/gdb.cp/pr10728.exp
index 0625d243bd8f..2560325ae727 100644
--- a/gdb/testsuite/gdb.cp/pr10728.exp
+++ b/gdb/testsuite/gdb.cp/pr10728.exp
@@ -26,22 +26,22 @@  include_file pr10728-x.h
 
 set tfx [standard_output_file pr10728-x.o]
 set tfy [standard_output_file pr10728-y.o]
 
 if  { [gdb_compile "${srcdir}/${subdir}/$srcfile2" "${tfy}.o" object {c++}] != "" } {
-     untested "failed to compile second object file"
-     return -1
+    untested "failed to compile second object file"
+    return
 }
 
 if  { [gdb_compile "${srcdir}/${subdir}/$srcfile" "${tfx}.o" object {debug c++}] != "" } {
-     untested "failed to compile first object file"
-     return -1
+    untested "failed to compile first object file"
+    return
 }
 
 if  { [gdb_compile "${tfx}.o ${tfy}.o" ${binfile} executable {debug c++}] != "" } {
-     untested "failed to compile"
-     return -1
+    untested "failed to compile"
+    return
 }
 
 clean_restart $::testfile
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
index a21485e215cb..ed15018b37ff 100644
--- a/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-sizeof.exp
@@ -20,11 +20,11 @@  standard_testfile .cc
 
 require allow_cplus_tests
 
 if {[prepare_for_testing ${testfile}.exp $testfile $srcfile \
     {debug c++ additional_flags="-std=gnu++11"}] } {
-     return -1
+    return
 }
 
 if {![runto_main]} {
     perror "could not run to main"
     return
diff --git a/gdb/testsuite/gdb.cp/save-bp-qualified.exp b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
index a6851ba96623..345290276628 100644
--- a/gdb/testsuite/gdb.cp/save-bp-qualified.exp
+++ b/gdb/testsuite/gdb.cp/save-bp-qualified.exp
@@ -36,11 +36,11 @@  proc restart {} {
     return 1
 }
 
 with_test_prefix "save" {
     if {![restart]} {
-	return -1
+	return
     }
 
     gdb_breakpoint "function" qualified
     gdb_breakpoint "function"
 
@@ -54,11 +54,11 @@  with_test_prefix "save" {
     gdb_test "save breakpoint $bps" "" "save breakpoint bps"
 }
 
 with_test_prefix "restore" {
     if {![restart]} {
-	return -1
+	return
     }
 
     # Restore the breakpoints.
     gdb_test "source $bps" "" "source bps"
 
diff --git a/gdb/testsuite/gdb.cp/smartp.exp b/gdb/testsuite/gdb.cp/smartp.exp
index 8a79f4385a9c..4c04a465e475 100644
--- a/gdb/testsuite/gdb.cp/smartp.exp
+++ b/gdb/testsuite/gdb.cp/smartp.exp
@@ -14,11 +14,11 @@ 
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 standard_testfile .cc
 
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}] } {
-     return -1
+    return
 }
 
 ############################################
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp
index 19756f64732e..58f4f5283b30 100644
--- a/gdb/testsuite/gdb.cp/static-print-quit.exp
+++ b/gdb/testsuite/gdb.cp/static-print-quit.exp
@@ -32,11 +32,11 @@  gdb_test_multiple "print c" "" {
 	pass $gdb_test_name
     }
     -re "\r\n$pagination_prompt$" {
 	# gdb-7.1 did not crash with this testcase but it had the same bug.
 	untested "bug does not reproduce"
-	return 0
+	return
     }
 }
 
 gdb_test "q" ".*"