aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-09-17 23:33:41 +0100
committerPedro Alves <pedro@palves.net>2020-09-18 00:05:57 +0100
commitc3e5138dccad66deda24fadb831f27881fa64b2d (patch)
tree2c9f58ddd552e5ef582c4ae55bd322f02aab87bc
parent151fdbad7a4df43fb7e5b1ef2f84622aaaa2ddb5 (diff)
downloadgdb-c3e5138dccad66deda24fadb831f27881fa64b2d.zip
gdb-c3e5138dccad66deda24fadb831f27881fa64b2d.tar.gz
gdb-c3e5138dccad66deda24fadb831f27881fa64b2d.tar.bz2
gdb.base/charset.{c,exp} C++ify
Adjust gdb.base/charset.{c,exp} so that the testcase works when compiled as a C++ program. wchar_t is built-in in C++, so don't make a phony typedef. The "print /d" is so that we also get "1" instead of "true" in C++ mode. gdb/testsuite/ChangeLog: * gdb.base/charset.c [__cplusplus] (wchar_t, char16_t, char32_t): Don't define. (utf_32_string): Compile for both C and C++. * gdb.base/charset.exp: Use "print /d".
-rw-r--r--gdb/testsuite/ChangeLog7
-rw-r--r--gdb/testsuite/gdb.base/charset.c7
-rw-r--r--gdb/testsuite/gdb.base/charset.exp12
3 files changed, 19 insertions, 7 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6ff6092..a7caa79 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
2020-09-17 Pedro Alves <pedro@palves.net>
+ * gdb.base/charset.c [__cplusplus] (wchar_t, char16_t, char32_t):
+ Don't define.
+ (utf_32_string): Compile for both C and C++.
+ * gdb.base/charset.exp: Use "print /d".
+
+2020-09-17 Pedro Alves <pedro@palves.net>
+
* gdb.base/watchpoint.c (buf): Make it 31 bytes.
(nullptr): Rename to ...
(null_ptr): ... this.
diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
index 20d548b..b1e6d3a 100644
--- a/gdb/testsuite/gdb.base/charset.c
+++ b/gdb/testsuite/gdb.base/charset.c
@@ -49,11 +49,12 @@ char iso_8859_1_string[NUM_CHARS];
char ebcdic_us_string[NUM_CHARS];
char ibm1047_string[NUM_CHARS];
+#ifndef __cplusplus
+
/* We make a phony wchar_t and then pretend that this platform uses
UTF-32 (or UTF-16, depending on the size -- same difference for the
purposes of this test). */
typedef unsigned int wchar_t;
-wchar_t utf_32_string[NUM_CHARS];
/* We also define a couple phony types for testing the u'' and U''
support. It is ok if these have the wrong size on some platforms
@@ -61,6 +62,10 @@ wchar_t utf_32_string[NUM_CHARS];
typedef unsigned short char16_t;
typedef unsigned int char32_t;
+#endif
+
+wchar_t utf_32_string[NUM_CHARS];
+
/* Make sure to use the typedefs. */
char16_t uvar;
char32_t Uvar;
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index a4345fa..1a04f1d 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -409,7 +409,7 @@ foreach target_charset $charset_subset {
"parse character literal in ${target_charset}"
# Check that the character literal was encoded correctly.
- gdb_test "print $L'A' == $var_name\[7\]" \
+ gdb_test "print /d $L'A' == $var_name\[7\]" \
" = 1" \
"check value of parsed character literal in ${target_charset}"
@@ -419,7 +419,7 @@ foreach target_charset $charset_subset {
"parse string literal in ${target_charset}"
# Check that the string literal was encoded correctly.
- gdb_test "print $L\"q\"\[0\] == $var_name\[49\]" \
+ gdb_test "print /d $L\"q\"\[0\] == $var_name\[49\]" \
" = 1" \
"check value of parsed string literal in ${target_charset}"
@@ -470,12 +470,12 @@ foreach target_charset $charset_subset {
if {$have_escape} {
# Try parsing a backslash escape in a character literal.
- gdb_test "print $L'\\${escape}' == $var_name\[$i\]" \
+ gdb_test "print /d $L'\\${escape}' == $var_name\[$i\]" \
" = 1" \
"check value of '\\${escape}' in ${target_charset}"
# Try parsing a backslash escape in a string literal.
- gdb_test "print $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
+ gdb_test "print /d $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
" = 1" \
"check value of \"\\${escape}\" in ${target_charset}"
}
@@ -485,7 +485,7 @@ foreach target_charset $charset_subset {
# get the unescaped character, in the target character set.
gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \
"print escape that doesn't exist in $target_charset"
- gdb_test "print $L'\\q' == $var_name\[49\]" " = 1" \
+ gdb_test "print /d $L'\\q' == $var_name\[49\]" " = 1" \
"check value of escape that doesn't exist in $target_charset"
}
@@ -585,7 +585,7 @@ if {$ucs2_ok} {
}
# Regression test for a cleanup bug in the charset code.
-gdb_test "print 'a' == 'a' || 'b' == 'b'" \
+gdb_test "print /d 'a' == 'a' || 'b' == 'b'" \
".* = 1" \
"EVAL_SKIP cleanup handling regression test"