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.
5 { dg-require-iconv "IBM1047" }
6 { dg-options "-O -Wall -fexec-charset=IBM1047 -fdump-tree-gimple -fdump-tree-optimized" } */
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)
27 A (b
[1] == (signed char)'b');
30 A (c
[1] == (unsigned char)'c');
33 void test_lengths (void)
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" } } */