blob: c3b64210bb498913a6d9861a4a626acce5b3f271 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001/* RUN: %clang_cc1 -E %s -DNO_ERRORS -Werror -Wundef
2 RUN: not %clang_cc1 -E %s
Reid Spencer5f016e22007-07-11 17:01:13 +00003 */
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
13foo
14#endif
15
16#if MACRO_1 || 10 / MACRO_0
17bar
18#endif
19
20#if 0 ? 124/0 : 42
21#endif
22
Chris Lattner3b691152008-05-04 07:15:21 +000023// PR2279
24#if 0 ? 1/0: 2
25#else
26#error
27#endif
28
Chris Lattner9e66ba62008-05-05 04:10:51 +000029// PR2279
30#if 1 ? 2 ? 3 : 4 : 5
31#endif
Chris Lattner3b691152008-05-04 07:15:21 +000032
Chris Lattner98ed49f2008-05-05 20:07:41 +000033// PR2284
34#if 1 ? 0: 1 ? 1/0: 1/0
35#endif
36
Reid Spencer5f016e22007-07-11 17:01:13 +000037#else
38
39
40/* The 1/0 is live, it should error out. */
41#if 0 && 1 ? 4 : 1 / 0
42baz
43#endif
44
45
46#endif
Chris Lattner4d2d04e2009-01-18 21:18:58 +000047
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