Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / strlenopt-79.c
blob362cbfbe27485bc410c7f7e86a169ecb1b75f9e7
1 /* PR tree-optimization/91914 - Invalid strlen folding for offset into struct
2 { dg-do run }
3 { dg-options "-O2 -Wall" } */
5 #define assert(expr) \
6 ((expr) \
7 ? (void)0 \
8 : (__builtin_printf ("%s:%i: assertion failed: %s\n", \
9 __FILE__, __LINE__, #expr), \
10 __builtin_abort ()))
12 extern __SIZE_TYPE__ strlen (const char*);
14 struct stringpool_t
16 char s1[sizeof ("1")];
17 char s2[sizeof ("12")];
18 char s3[sizeof ("123")];
19 char s4[sizeof ("1234")];
20 char s5[sizeof ("12345")];
23 static const struct stringpool_t stringpool_contents =
25 "1", "12", "123", "1234", "12345"
28 #define stringpool ((const char *) &stringpool_contents)
30 volatile int i0 = 0, i2 = 2, i5 = 5, i9 = 9, i14 = 14;
32 int main (void)
34 /* These shouldn't trigger warnings. */
35 assert (strlen (stringpool) == 1);
36 assert (strlen (stringpool + 2) == 2);
37 assert (strlen (stringpool + 5) == 3);
38 assert (strlen (stringpool + 9) == 4);
39 assert (strlen (stringpool + 14) == 5);
41 assert (strlen (stringpool + i0) == 1);
42 assert (strlen (stringpool + i2) == 2);
43 assert (strlen (stringpool + i5) == 3);
44 assert (strlen (stringpool + i9) == 4);
45 assert (strlen (stringpool + i14) == 5);