[RFC,08/18] gdb.base/charset.exp C++ify

Message ID 20200914001437.31157-9-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.
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/gdb.base/charset.c   |  7 ++++++-
 gdb/testsuite/gdb.base/charset.exp | 12 ++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

-- 
2.14.5

Patch

diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
index 20d548b1928..b1e6d3add08 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 a4345faf056..1a04f1daacd 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"