1void abort(void); 2void exit(int); 3 4void 5test1(void) 6{ 7 int x = 3, y = 2; 8 9 if ((x < y ? x++ : y++) != 2) 10 abort (); 11 12 if (x != 3) 13 abort (); 14 15 if (y != 3) 16 abort (); 17} 18 19void 20test2(void) 21{ 22 int x = 3, y = 2, z; 23 24 z = (x < y) ? x++ : y++; 25 if (z != 2) 26 abort (); 27 28 if (x != 3) 29 abort (); 30 31 if (y != 3) 32 abort (); 33} 34 35void 36test3(void) 37{ 38 int x = 3, y = 2; 39 int xx = 3, yy = 2; 40 41 if ((xx < yy ? x++ : y++) != 2) 42 abort (); 43 44 if (x != 3) 45 abort (); 46 47 if (y != 3) 48 abort (); 49} 50 51int x, y; 52 53static void 54init_xy(void) 55{ 56 x = 3; 57 y = 2; 58} 59 60void 61test4(void) 62{ 63 init_xy(); 64 if ((x < y ? x++ : y++) != 2) 65 abort (); 66 67 if (x != 3) 68 abort (); 69 70 if (y != 3) 71 abort (); 72} 73 74void 75test5(void) 76{ 77 int z; 78 79 init_xy(); 80 z = (x < y) ? x++ : y++; 81 if (z != 2) 82 abort (); 83 84 if (x != 3) 85 abort (); 86 87 if (y != 3) 88 abort (); 89} 90 91void 92test6(void) 93{ 94 int xx = 3, yy = 2; 95 int z; 96 97 init_xy(); 98 z = (xx < y) ? x++ : y++; 99 if (z != 2) 100 abort (); 101 102 if (x != 3) 103 abort (); 104 105 if (y != 3) 106 abort (); 107} 108 109int 110main(){ 111 test1 (); 112 test2 (); 113 test3 (); 114 test4 (); 115 test5 (); 116 test6 (); 117 exit (0); 118} 119