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