Home | History | Annotate | Download | only in Preprocessor
      1 // RUN: %clang_cc1 %s -E -CC -verify
      2 // RUN: %clang_cc1 %s -E -CC -DPEDANTIC -pedantic -verify
      3 
      4 #define FOO && 1
      5 #if defined FOO FOO
      6 #endif
      7 
      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
     29