Unified · Split
| @@ -1506,6 +1506,20 @@ static int expr_preprocess(TCCState *s1) · 1505 unmodified lines | |||
| 1506 | tokc.i = c; | 1506 | tokc.i = c; |
| 1507 | } else { | 1507 | } else { |
| 1508 | /* if undefined macro, replace with zero */ | 1508 | /* if undefined macro, replace with zero */ |
| 1509 | next_nomacro(); | ||
| 1510 | // If the undefined macro is followed by parens, just skip them. | ||
| 1511 | if (tok == '(') { | ||
| 1512 | int bracket_depth = 1; | ||
| 1513 | while (bracket_depth > 0) { | ||
| 1514 | next(); | ||
| 1515 | if (tok == '(') | ||
| 1516 | bracket_depth++; | ||
| 1517 | else if (tok == ')') | ||
| 1518 | bracket_depth--; | ||
| 1519 | } | ||
| 1520 | } else { | ||
| 1521 | unget_tok(tok); // Is this actually the function I want? | ||
| 1522 | } | ||
| 1509 | tok = TOK_CINT; | 1523 | tok = TOK_CINT; |
| 1510 | tokc.i = 0; | 1524 | tokc.i = 0; |
| 1511 | } | 1525 | } |
| @@ -0,0 +1,13 @@ | |||
| 1 | int main () { | ||
| 2 | // This used to evaluate to 0 (0), which is invalid. | ||
| 3 | // Now it should evaluate to 0. | ||
| 4 | #if WUMBOED(WUMBO) | ||
| 5 | #endif | ||
| 6 | |||
| 7 | // Just trying a more complicated test case. | ||
| 8 | #if WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY | ||
| 9 | return 0; | ||
| 10 | #elif WUMBO && defined(WUMBOLOGY) || WUMBOED(WUMBO) && !WUMBOLOGY | ||
| 11 | return 1; | ||
| 12 | #endif | ||
| 13 | } | ||