blob: 23cb4355eb8c672829b33a37e9cfb682d44dcde4 [file] [log] [blame]
Nico Weberb2348f42016-01-19 15:15:31 +00001// RUN: %clang_cc1 %s -E -CC -verify
2// RUN: %clang_cc1 %s -E -CC -DPEDANTIC -pedantic -verify
Eli Friedmanb3bfd842011-08-03 00:04:13 +00003
4#define FOO && 1
5#if defined FOO FOO
6#endif
Nico Weberb2348f42016-01-19 15:15:31 +00007
8#define A
9#define B defined(A)
10#if B // expected-warning{{macro expansion producing 'defined' has undefined behavior}}
11#endif
12
13#define m_foo
14#define TEST(a) (defined(m_##a) && a)
15
16#if defined(PEDANTIC)
17// expected-warning@+4{{macro expansion producing 'defined' has undefined behavior}}
18#endif
19
20// This shouldn't warn by default, only with pedantic:
21#if TEST(foo)
22#endif
23
24
25// Only one diagnostic for this case:
26#define INVALID defined(
27#if INVALID // expected-error{{macro name missing}}
28#endif