From: Pedro Alves Date: Thu, 17 Sep 2020 22:33:41 +0000 (+0100) Subject: gdb.base/charset.{c,exp} C++ify X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c3e5138dccad66deda24fadb831f27881fa64b2d;p=binutils-gdb.git 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". --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6ff609276c1..a7caa79a4a2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2020-09-17 Pedro Alves + + * 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 * gdb.base/watchpoint.c (buf): Make it 31 bytes. 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"