[2/3] gdb/testsuite: fix gdb.mi/mi-var-cp.exp with clang

Message ID 20240723201238.1155083-4-blarsen@redhat.com
State New
Headers
Series fix gdb.mi testsuite folder, when using clang |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Guinevere Larsen July 23, 2024, 8:12 p.m. UTC
  The inline tests in gdb.mi/mi-var-cp.cc were failing when using clang to
run the test. This happened because inline tests want to step past the C
statements and then run the TCL tests, but in mi-var-cp.cc the statement
to be stepped past is "return s2.i;". Since clang links the epilogue
information to the return statement, not the closing brace,
single-stepping past return had us exiting the function - which made the
expressions invalid.

This commit fixes this by making the function have 2 C statements, and
the return one be after all inline tests, so we know GDB won't leave the
function before running the create_varobj tests.
---
 gdb/testsuite/gdb.mi/mi-var-cp.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.cc b/gdb/testsuite/gdb.mi/mi-var-cp.cc
index 4befab95d3d..d30894e6dfd 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.cc
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.cc
@@ -42,7 +42,7 @@  struct S2 : S {};
 int base_in_reference_test (S2& s2)
 {
   /*: BEGIN: base_in_reference :*/
-  return s2.i;
+  int x = s2.i + s2.j;
   /*: 
     mi_create_varobj "S2" "s2" "create varobj for s2"
     mi_list_varobj_children "S2" {
@@ -62,6 +62,7 @@  int base_in_reference_test (S2& s2)
     
   :*/
   /*: END: base_in_reference :*/
+  return x;
 }
         
 void base_in_reference_test_main ()