[RFC,04/18] gdb.base/nested-addr.exp C++ify

Message ID 20200914001437.31157-5-pedro@palves.net
State New
Headers show
Series
  • Allow building (more) C tests with a C++ compiler
Related show

Commit Message

Pedro Alves Sept. 14, 2020, 12:14 a.m.
Adjust gdb.base/nested-addr.exp to let the testcase build and run as a
C++ program.  "print /d" is used so we get "= 1" instead of "= true"
in C++ mode.
---
 gdb/testsuite/gdb.base/nested-addr.c   | 2 +-
 gdb/testsuite/gdb.base/nested-addr.exp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.14.5

Patch

diff --git a/gdb/testsuite/gdb.base/nested-addr.c b/gdb/testsuite/gdb.base/nested-addr.c
index 4725753382d..3d1cfd45376 100644
--- a/gdb/testsuite/gdb.base/nested-addr.c
+++ b/gdb/testsuite/gdb.base/nested-addr.c
@@ -28,7 +28,7 @@  static foo *foo_array = NULL;
 int
 main (void)
 {
-  foo_array = calloc (3, sizeof (*foo_array));
+  foo_array = (foo *) calloc (3, sizeof (*foo_array));
   foo_array[1].a = 10;
   foo_array[2].b = 20;
   return 0; /* BREAK */
diff --git a/gdb/testsuite/gdb.base/nested-addr.exp b/gdb/testsuite/gdb.base/nested-addr.exp
index 7ed0d65d327..15071cac9c7 100644
--- a/gdb/testsuite/gdb.base/nested-addr.exp
+++ b/gdb/testsuite/gdb.base/nested-addr.exp
@@ -31,4 +31,4 @@  gdb_test "print &foo_array\[1\].a" "= \\(int \\*\\) $hex.*"
 
 # A bug in EVAL_AVOID_SIDE_EFFECTS mode used to yield the following error:
 #    Attempt to take address of value not located in memory.
-gdb_test "print 1 && &foo_array\[1\].a" "= 1"
+gdb_test "print /d 1 && &foo_array\[1\].a" "= 1"