[committed] Handle targets with 2 byte wchar_t better in strlenopt-58.c

Jeff Law law@redhat.com
Tue Dec 4 23:23:00 GMT 2018


This is another minor testsuite patch.   strlenopt-58.c assumes 4 byte
wchar_t.  On targets with a smaller wchar_t it will get an error/warning.

This patch adds a dg-warning on the appropriate lines for targets that
do not have 4byte wchar_t.

It's been tested on h8 to verify the bogus warnings/errors are gone. We
don't optimize it fully yet, but I'm not really focused on that kind of
error right now.

It's also been tested on x86_64 to verify that it didn't break anything
on targets with a 4 byte wchar_t.


Installing on the trunk.


Jeff
-------------- next part --------------
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 18ef9edb7ad..7aad09dae78 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-12-04  Jeff Law  <law@redhat.com>
+
+	* gcc.dg/strlenopt-58.c: Handle targets with 2 byte wchar_t.
+
 2018-12-04  Martin Sebor  <msebor@redhat.com>
 
 	* gcc.target/i386/attr-aligned-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/strlenopt-58.c b/gcc/testsuite/gcc.dg/strlenopt-58.c
index e0e80680936..034961cd810 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-58.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-58.c
@@ -34,8 +34,8 @@ extern void* memchr (const void*, int, size_t);
 
 static const wchar_t wc = L'1';
 static const wchar_t ws1[] = L"1";
-static const wchar_t wsx[] = L"\x12345678";
-static const wchar_t ws4[] = L"\x00123456\x12005678\x12340078\x12345600";
+static const wchar_t wsx[] = L"\x12345678";		/* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */
+static const wchar_t ws4[] = L"\x00123456\x12005678\x12340078\x12345600";		/* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */
 
 void test_wide (void)
 {
@@ -47,7 +47,7 @@ void test_wide (void)
 
   ELIM (memchr (L"" + 1, 0, 0) == 0);
   ELIM (memchr (&wc + 1, 0, 0) == 0);
-  ELIM (memchr (L"\x12345678", 0, sizeof (wchar_t)) == 0);
+  ELIM (memchr (L"\x12345678", 0, sizeof (wchar_t)) == 0);		/* { dg-warning "hex escape" "" { target { ! 4byte_wchar_t } } } */
 
   const size_t nb = sizeof ws4;
   const size_t nwb = sizeof (wchar_t);


More information about the Gcc-patches mailing list