Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | /* RUN: %clang_cc1 -E %s -DNO_ERRORS -Werror -Wundef |
| 2 | RUN: not %clang_cc1 -E %s |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #ifdef NO_ERRORS |
| 6 | /* None of these divisions by zero are in live parts of the expression, do not |
| 7 | emit any diagnostics. */ |
| 8 | |
| 9 | #define MACRO_0 0 |
| 10 | #define MACRO_1 1 |
| 11 | |
| 12 | #if MACRO_0 && 10 / MACRO_0 |
| 13 | foo |
| 14 | #endif |
| 15 | |
| 16 | #if MACRO_1 || 10 / MACRO_0 |
| 17 | bar |
| 18 | #endif |
| 19 | |
| 20 | #if 0 ? 124/0 : 42 |
| 21 | #endif |
| 22 | |
Chris Lattner | 3b69115 | 2008-05-04 07:15:21 +0000 | [diff] [blame] | 23 | // PR2279 |
| 24 | #if 0 ? 1/0: 2 |
| 25 | #else |
| 26 | #error |
| 27 | #endif |
| 28 | |
Chris Lattner | 9e66ba6 | 2008-05-05 04:10:51 +0000 | [diff] [blame] | 29 | // PR2279 |
| 30 | #if 1 ? 2 ? 3 : 4 : 5 |
| 31 | #endif |
Chris Lattner | 3b69115 | 2008-05-04 07:15:21 +0000 | [diff] [blame] | 32 | |
Chris Lattner | 98ed49f | 2008-05-05 20:07:41 +0000 | [diff] [blame] | 33 | // PR2284 |
| 34 | #if 1 ? 0: 1 ? 1/0: 1/0 |
| 35 | #endif |
| 36 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 37 | #else |
| 38 | |
| 39 | |
| 40 | /* The 1/0 is live, it should error out. */ |
| 41 | #if 0 && 1 ? 4 : 1 / 0 |
| 42 | baz |
| 43 | #endif |
| 44 | |
| 45 | |
| 46 | #endif |
Chris Lattner | 4d2d04e | 2009-01-18 21:18:58 +0000 | [diff] [blame] | 47 | |
| 48 | // rdar://6505352 |
| 49 | // -Wundef should not warn about use of undefined identifier if not live. |
| 50 | #if (!defined(XXX) || XXX > 42) |
| 51 | #endif |
| 52 | |