PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / 20121108-1.c
blob5ec889e602cb4971436ed11e0b53ddb1e3771475
1 char temp[] = "192.168.190.160";
2 unsigned result = (((((192u<<8)|168u)<<8)|190u)<<8)|160u;
4 int strtoul1(const char *a, char **b, int c) __attribute__((noinline, noclone));
5 int strtoul1(const char *a, char **b, int c)
7 *b = a+3;
8 if (a == temp)
9 return 192;
10 else if (a == temp+4)
11 return 168;
12 else if (a == temp+8)
13 return 190;
14 else if (a == temp+12)
15 return 160;
16 __builtin_abort();
19 int string_to_ip(const char *s) __attribute__((noinline,noclone));
20 int string_to_ip(const char *s)
22 int addr;
23 char *e;
24 int i;
26 if (s == 0)
27 return(0);
29 for (addr=0, i=0; i<4; ++i) {
30 int val = s ? strtoul1(s, &e, 10) : 0;
31 addr <<= 8;
32 addr |= (val & 0xFF);
33 if (s) {
34 s = (*e) ? e+1 : e;
38 return addr;
41 int main(void)
43 int t = string_to_ip (temp);
44 printf ("%x\n", t);
45 printf ("%x\n", result);
46 if (t != result)
47 __builtin_abort ();
48 printf ("WORKS.\n");
49 return 0;