Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-56.c
blobffd02f1b6cfde89c683e8a2c1865641c5cc07d18
1 /* PR tree-optimization/71625 - conversion of braced initializers to strings
2 Verify that array elements have the expected values regardless of sign
3 and non-ASCII execution character set.
4 { dg-do compile }
5 { dg-require-iconv "IBM1047" }
6 { dg-options "-O -Wall -fexec-charset=IBM1047 -fdump-tree-gimple -fdump-tree-optimized" } */
8 #include "strlenopt.h"
10 const char a[] = { 'a', 129, 0 };
11 const signed char b[] = { 'b', 130, 0 };
12 const unsigned char c[] = { 'c', 131, 0 };
14 const char s[] = "a\201";
15 const signed char ss[] = "b\202";
16 const unsigned char us[] = "c\203";
19 #define A(expr) ((expr) ? (void)0 : __builtin_abort ())
21 void test_values (void)
23 A (a[0] == a[1]);
24 A (a[1] == 'a');
26 A (b[0] == b[1]);
27 A (b[1] == (signed char)'b');
29 A (c[0] == c[1]);
30 A (c[1] == (unsigned char)'c');
33 void test_lengths (void)
35 A (2 == strlen (a));
36 A (2 == strlen ((const char*)b));
37 A (2 == strlen ((const char*)c));
40 void test_contents (void)
42 A (0 == strcmp (a, s));
43 A (0 == strcmp ((const char*)b, (const char*)ss));
44 A (0 == strcmp ((const char*)c, (const char*)us));
48 /* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } }
49 { dg-final { scan-tree-dump-times "strcmp" 0 "gimple" } }
50 { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */