1 /* 2 20020402-1.c from the execute part of the gcc torture suite. 3 */ 4 5 #include <testfwk.h> 6 7 #ifdef __SDCC 8 #pragma std_c99 9 #endif 10 11 /* derived from PR c/2100 */ 12 13 #define SMALL_N 2 14 #define NUM_ELEM 4 15 testTortureExecute(void)16void testTortureExecute(void) 17 { 18 int listElem[NUM_ELEM]={30,2,10,5}; 19 int listSmall[SMALL_N]; 20 int i, j; 21 int posGreatest=-1, greatest=-1; 22 23 for (i=0; i<SMALL_N; i++) { 24 listSmall[i] = listElem[i]; 25 if (listElem[i] > greatest) { 26 posGreatest = i; 27 greatest = listElem[i]; 28 } 29 } 30 31 for (i=SMALL_N; i<NUM_ELEM; i++) { 32 if (listElem[i] < greatest) { 33 listSmall[posGreatest] = listElem[i]; 34 posGreatest = 0; 35 greatest = listSmall[0]; 36 for (j=1; j<SMALL_N; j++) 37 if (listSmall[j] > greatest) { 38 posGreatest = j; 39 greatest = listSmall[j]; 40 } 41 } 42 } 43 44 if (listSmall[0] != 5 || listSmall[1] != 2) 45 ASSERT (0); 46 return; 47 } 48 49