modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/20041218-1.c (about) 1 /* PR rtl-optimization/16968 */ 2 /* Testcase by Jakub Jelinek <jakub@redhat.com> */ 3 4 struct T 5 { 6 unsigned int b, c, *d; 7 unsigned char e; 8 }; 9 struct S 10 { 11 unsigned int a; 12 struct T f; 13 }; 14 struct U 15 { 16 struct S g, h; 17 }; 18 struct V 19 { 20 unsigned int i; 21 struct U j; 22 }; 23 24 extern void exit (int); 25 extern void abort (void); 26 27 void * 28 dummy1 (void *x) 29 { 30 return ""; 31 } 32 33 void * 34 dummy2 (void *x, void *y) 35 { 36 exit (0); 37 } 38 39 struct V * 40 baz (unsigned int x) 41 { 42 static struct V v; 43 __builtin_memset (&v, 0x55, sizeof (v)); 44 return &v; 45 } 46 47 int 48 check (void *x, struct S *y) 49 { 50 if (y->a || y->f.b || y->f.c || y->f.d || y->f.e) 51 abort (); 52 return 1; 53 } 54 55 static struct V * 56 bar (unsigned int x, void *y) 57 { 58 const struct T t = { 0, 0, (void *) 0, 0 }; 59 struct V *u; 60 void *v; 61 v = dummy1 (y); 62 if (!v) 63 return (void *) 0; 64 65 u = baz (sizeof (struct V)); 66 u->i = x; 67 u->j.g.a = 0; 68 u->j.g.f = t; 69 u->j.h.a = 0; 70 u->j.h.f = t; 71 72 if (!check (v, &u->j.g) || !check (v, &u->j.h)) 73 return (void *) 0; 74 return u; 75 } 76 77 int 78 foo (unsigned int *x, unsigned int y, void **z) 79 { 80 void *v; 81 unsigned int i, j; 82 83 *z = v = (void *) 0; 84 85 for (i = 0; i < y; i++) 86 { 87 struct V *c; 88 89 j = *x; 90 91 switch (j) 92 { 93 case 1: 94 c = bar (j, x); 95 break; 96 default: 97 c = 0; 98 break; 99 } 100 if (c) 101 v = dummy2 (v, c); 102 else 103 return 1; 104 } 105 106 *z = v; 107 return 0; 108 } 109 110 int 111 main (void) 112 { 113 unsigned int one = 1; 114 void *p; 115 foo (&one, 1, &p); 116 abort (); 117 }