* testsuite/libgomp.fortran/vla7.f90: Add -w to options.
[official-gcc.git] / gcc / testsuite / gcc.dg / duff-4.c
blob7032285af5e61fb9d41a15364335b6311f7ea3a6
1 /* Duff's device is legal C; test to make sure the compiler
2 doesn't complain about it.
4 Roger Sayle <roger@eyesopen.com>
5 Derived from duff-2.c. */
7 /* { dg-do run } */
8 /* { dg-options "-O2" } */
10 extern void abort (void);
11 extern void exit (int);
13 #if __INT_MAX__ >= 2147483647
14 /* At least 32-bit integers. */
15 typedef int type32;
16 #else
17 typedef long type32;
18 #endif
20 type32
21 cksum (const unsigned char *src, unsigned long size)
23 type32 ck = 0;
25 switch (size & 3)
29 case 0:
30 ck ^= (type32)*src++ << 24;
31 --size;
32 case 3:
33 ck ^= (type32)*src++ << 16;
34 --size;
35 case 2:
36 ck ^= (type32)*src++ << 8;
37 --size;
38 case 1:
39 ck ^= (type32)*src++;
40 --size;
42 while (size > 0);
45 return ck;
48 const char testpat[] = "The quick brown fox jumped over the lazy dog.";
50 int
51 main()
53 type32 ck;
55 ck = cksum ((const unsigned char *) testpat, sizeof (testpat));
56 if (ck != 925902908)
57 abort ();
59 exit (0);