PR tree-optimization/81384 - built-in form of strnlen missing
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / pr84478.c
blob6172b1acb0663e81008b07a1f4b303648ce0baa2
1 /* PR tree-optimization/84478 */
3 long poolptr;
4 unsigned char *strpool;
5 static const char *poolfilearr[] = {
6 "mu",
7 "",
8 #define A "x",
9 #define B A "xx", A A "xxx", A A A A A
10 #define C B B B B B B B B B B
11 #define D C C C C C C C C C C
12 D C C C C C C C B B B
13 ((void *)0)
16 __attribute__((noipa)) long
17 makestring (void)
19 return 1;
22 __attribute__((noipa)) long
23 loadpoolstrings (long spare_size)
25 const char *s;
26 long g = 0;
27 int i = 0, j = 0;
28 while ((s = poolfilearr[j++]))
30 int l = __builtin_strlen (s);
31 i += l;
32 if (i >= spare_size) return 0;
33 while (l-- > 0) strpool[poolptr++] = *s++;
34 g = makestring ();
36 return g;
39 int
40 main ()
42 strpool = __builtin_malloc (4000);
43 if (!strpool)
44 return 0;
45 asm volatile ("" : : : "memory");
46 volatile int r = loadpoolstrings (4000);
47 __builtin_free (strpool);
48 return 0;