modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr20601-1.c (about) 1 /* PR tree-optimization/20601 */ 2 /* { dg-xfail-if "ptxas crashes" { nvptx-*-* } { "-O1" } { "" } } */ 3 extern void abort (void); 4 extern void exit (int); 5 6 struct T 7 { 8 char *t1; 9 char t2[4096]; 10 char **t3; 11 }; 12 13 int a[5]; 14 int b; 15 char **c; 16 int d; 17 char **e; 18 struct T t; 19 char *f[16]; 20 char *g[] = { "a", "-u", "b", "c" }; 21 22 __attribute__ ((__noreturn__)) void 23 foo (void) 24 { 25 while (1); 26 } 27 28 __attribute__ ((noinline)) char * 29 bar (char *x, unsigned int y) 30 { 31 return 0; 32 } 33 34 static inline char * 35 baz (char *x, unsigned int y) 36 { 37 if (sizeof (t.t2) != (unsigned int) -1 && y > sizeof (t.t2)) 38 foo (); 39 return bar (x, y); 40 } 41 42 static inline int 43 setup1 (int x) 44 { 45 char *p; 46 int rval; 47 48 if (!baz (t.t2, sizeof (t.t2))) 49 baz (t.t2, sizeof (t.t2)); 50 51 if (x & 0x200) 52 { 53 char **h, **i = e; 54 55 ++d; 56 e = f; 57 if (t.t1 && *t.t1) 58 e[0] = t.t1; 59 else 60 abort (); 61 62 for (h = e + 1; (*h = *i); ++i, ++h) 63 ; 64 } 65 return 1; 66 } 67 68 static inline int 69 setup2 (void) 70 { 71 int j = 1; 72 73 e = c + 1; 74 d = b - 1; 75 while (d > 0 && e[0][0] == '-') 76 { 77 if (e[0][1] != '\0' && e[0][2] != '\0') 78 abort (); 79 80 switch (e[0][1]) 81 { 82 case 'u': 83 if (!e[1]) 84 abort (); 85 86 t.t3 = &e[1]; 87 d--; 88 e++; 89 break; 90 case 'P': 91 j |= 0x1000; 92 break; 93 case '-': 94 d--; 95 e++; 96 if (j == 1) 97 j |= 0x600; 98 return j; 99 } 100 d--; 101 e++; 102 } 103 104 if (d > 0 && !(j & 1)) 105 abort (); 106 107 return j; 108 } 109 110 int 111 main (void) 112 { 113 int x; 114 c = g; 115 b = 4; 116 x = setup2 (); 117 t.t1 = "/bin/sh"; 118 setup1 (x); 119 /* PRE shouldn't transform x into the constant 0x601 here, it's not legal. */ 120 if ((x & 0x400) && !a[4]) 121 abort (); 122 exit (0); 123 }