Fix gdb.base/charset.exp with Clang
authorPedro Alves <palves@redhat.com>
Thu, 2 Jul 2020 14:54:36 +0000 (15:54 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 3 Jul 2020 14:00:08 +0000 (15:00 +0100)
gdb.base/charset.exp fails to run with Clang, because of:

 gdb compile failed, /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:144:20: warning:
       implicit conversion from 'int' to 'char' changes value from 162 to -94
       [-Wconstant-conversion]
11, 162, 17);
    ^~~
 /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:151:16: warning:
       implicit conversion from 'int' to 'char' changes value from 167 to -89
       [-Wconstant-conversion]
167,
^~~
 /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/charset.c:168:16: warning:
       implicit conversion from 'int' to 'char' changes value from 167 to -89
       [-Wconstant-conversion]
167,
^~~
 3 warnings generated.

 === gdb Summary ===

 # of untested testcases         1

Fix it by changing init_string to take unsigned char parameters.

gdb/testsuite/ChangeLog:

* gdb.base/charset.c (init_string): Change all char parameters to
unsigned char parameters.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/charset.c

index 47e4d7c509a1c458df46a72d2168034ac41d0836..79c1208bd50a97e3d77fd6cf934fe5dc599b3f75 100644 (file)
@@ -1,3 +1,8 @@
+2020-07-03  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/charset.c (init_string): Change all char parameters to
+       unsigned char parameters.
+
 2020-07-03  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/call-sc.exp (start_scalars_test): Use
index ec4927da5152550e7f7f3547cbe7ba8429d7f2bf..20d548b1928789b5ef9271781b98a725452875bd 100644 (file)
@@ -77,12 +77,21 @@ short short_array[3];
 int int_array[3];
 long long_array[3];
 
+/* These are unsigned char so we can pass down characters >127 without
+   explicit casts or warnings.  */
+
 void
 init_string (char string[],
-             char x,
-             char alert, char backspace, char form_feed,
-             char line_feed, char carriage_return, char horizontal_tab,
-             char vertical_tab, char cent, char misc_ctrl)
+            unsigned char x,
+            unsigned char alert,
+            unsigned char backspace,
+            unsigned char form_feed,
+            unsigned char line_feed,
+            unsigned char carriage_return,
+            unsigned char horizontal_tab,
+            unsigned char vertical_tab,
+            unsigned char cent,
+            unsigned char misc_ctrl)
 {
   int i;