[RFC,07/18] gdb.base/watchpoint.{c,exp}

Message ID 20200914001437.31157-8-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/watchpoint.c so that it can be built as a C++ program.

Fixes:
gdb compile failed, src/gdb/testsuite/gdb.base/watchpoint.c:33:16: error: initializer-string for array of chars is too long [-fpermissive]
   33 | char buf[30] = "testtesttesttesttesttesttestte";
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/gdb/testsuite/gdb.base/watchpoint.c:62:14: error: expected unqualified-id before 'nullptr'
   62 | struct foo5 *nullptr;
      |              ^~~~~~~
---
 gdb/testsuite/gdb.base/watchpoint.c   | 4 ++--
 gdb/testsuite/gdb.base/watchpoint.exp | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.14.5

Patch

diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c
index 60f60d6c02c..3d6e36ff081 100644
--- a/gdb/testsuite/gdb.base/watchpoint.c
+++ b/gdb/testsuite/gdb.base/watchpoint.c
@@ -30,7 +30,7 @@  int ival2 = -1;
 int ival3 = -1;
 int ival4 = -1;
 int ival5 = -1;
-char buf[30] = "testtesttesttesttesttesttestte";
+char buf[31] = "testtesttesttesttesttesttestte";
 struct foo
 {
   int val;
@@ -59,7 +59,7 @@  struct foo5
   struct { int x; } *p;
 };
 
-struct foo5 *nullptr;
+struct foo5 *null_ptr;
 
 void marker1 ()
 {
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 1ed73e8b491..fc84f98534b 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -604,9 +604,9 @@  proc test_watch_location {} {
     gdb_continue_to_breakpoint "func5 breakpoint here"
 
     # Check first if a null pointer can be dereferenced on the target.
-    gdb_test_multiple "p *nullptr" "" {
+    gdb_test_multiple "p *null_ptr" "" {
 	-re "Cannot access memory at address 0x0.*$gdb_prompt $" {
-	    gdb_test "watch -location nullptr->p->x" \
+	    gdb_test "watch -location null_ptr->p->x" \
 		"Cannot access memory at address 0x0"
 	}
 	-re ".*$gdb_prompt $" {