aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorGary Benson <gbenson@redhat.com>2020-06-26 14:53:28 +0100
committerGary Benson <gbenson@redhat.com>2020-06-26 14:53:28 +0100
commitf53b3eeb677aace413d45b4b3c9d23d57d7167fc (patch)
treec603ca7a67446c6ba38b29e3dec3a10c9a5cdb12 /gdb
parentedf92af0fbc064243069578353ff569462c3df5b (diff)
downloadgdb-f53b3eeb677aace413d45b4b3c9d23d57d7167fc.zip
gdb-f53b3eeb677aace413d45b4b3c9d23d57d7167fc.tar.gz
gdb-f53b3eeb677aace413d45b4b3c9d23d57d7167fc.tar.bz2
Fix -Wstring-compare testcase build failure
Clang fails to compile the file gdb/testsuite/gdb.cp/try_catch.cc with the following error: warning: result of comparison against a string literal is unspecified (use strncmp instead) [-Wstring-compare] This commit fixes the error, replacing the pointer comparison with a call to strcmp. This commit also adds a final check: the test program is run to the final return statement, and the value of "test" is checked to ensure it is still "true" at that point. gdb/testsuite/ChangeLog: * gdb.cp/try_catch.cc: Include string.h. (main): Replace comparison against string literal with strcmp, avoiding build failure with -Wstring-compare. Add "marker test-complete". * gdb.cp/try_catch.exp: Run the test to the above marker, then verify that the value of "test" is still true.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.cp/try_catch.cc5
-rw-r--r--gdb/testsuite/gdb.cp/try_catch.exp4
3 files changed, 16 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8ad2448..a01a065 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2020-06-26 Gary Benson <gbenson@redhat.com>
+
+ * gdb.cp/try_catch.cc: Include string.h.
+ (main): Replace comparison against string literal with
+ strcmp, avoiding build failure with -Wstring-compare.
+ Add "marker test-complete".
+ * gdb.cp/try_catch.exp: Run the test to the above marker,
+ then verify that the value of "test" is still true.
+
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.arch/riscv-tdesc-regs.exp: New test cases.
diff --git a/gdb/testsuite/gdb.cp/try_catch.cc b/gdb/testsuite/gdb.cp/try_catch.cc
index 4c4add2..5f454f4 100644
--- a/gdb/testsuite/gdb.cp/try_catch.cc
+++ b/gdb/testsuite/gdb.cp/try_catch.cc
@@ -18,6 +18,7 @@
#include <exception>
#include <stdexcept>
#include <string>
+#include <string.h>
enum region { oriental, egyptian, greek, etruscan, roman };
@@ -129,8 +130,8 @@ int main()
}
catch (exception& obj)
{
- if (obj.what() != "gdb.1") // marker 3-catch
+ if (strcmp (obj.what(), "gdb.1") != 0) // marker 3-catch
test &= false;
}
- return 0;
+ return 0; // marker test-complete
}
diff --git a/gdb/testsuite/gdb.cp/try_catch.exp b/gdb/testsuite/gdb.cp/try_catch.exp
index fb53294..b52e1a0 100644
--- a/gdb/testsuite/gdb.cp/try_catch.exp
+++ b/gdb/testsuite/gdb.cp/try_catch.exp
@@ -63,5 +63,9 @@ gdb_continue_to_breakpoint "marker 3-throw"
gdb_breakpoint [gdb_get_line_number "marker 3-catch"]
gdb_continue_to_breakpoint "marker 3-catch"
+gdb_breakpoint [gdb_get_line_number "marker test-complete"]
+gdb_continue_to_breakpoint "marker test-complete"
+gdb_test "p test" "= true"
+
gdb_exit
return 0