1 2 ////////////////////////////// 3 // control flow analysis 4 ////////////////////////////// 5 6 int buf[2]; 7 in_if(int a)8void in_if(int a) { 9 if (a==100) 10 buf[a] = 0; // BUG 11 } 12 before_if(int a)13void before_if(int a) { 14 buf[a] = 0; // WARNING 15 if (a==100) {} 16 } 17 after_if(int a)18void after_if(int a) { 19 if (a==100) {} 20 buf[a] = 0; // WARNING 21 } 22 in_for(void)23void in_for(void) { 24 int x; 25 for (x = 0; x<100; x++) { 26 buf[x] = 0; // BUG 27 } 28 } 29 after_for(void)30void after_for(void) { 31 int x; 32 for (x = 0; x<100; x++) {} 33 buf[x] = 0; // BUG 34 } 35 in_switch(int x)36void in_switch(int x) { 37 switch (x) { 38 case 100: 39 buf[x] = 0; // BUG 40 break; 41 } 42 } 43 before_switch(int x)44void before_switch(int x) { 45 buf[x] = 0; // WARNING 46 switch (x) { 47 case 100: 48 break; 49 } 50 } 51 after_switch(int x)52void after_switch(int x) { 53 switch (x) { 54 case 100: 55 break; 56 } 57 buf[x] = 0; // WARNING 58 } 59 in_while(void)60void in_while(void) { 61 int x = 0; 62 while (x<100) { 63 buf[x] = 0; // BUG 64 x++; 65 } 66 } 67 after_while(void)68void after_while(void) { 69 int x = 0; 70 while (x<100) 71 x++; 72 buf[x] = 0; // BUG 73 } 74