Home | History | Annotate | Download | only in Preprocessor
      1 // RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
      2 // RUN: %clang_cc1 %s -E -verify -fno-operator-names
      3 
      4 #ifndef OPERATOR_NAMES
      5 //expected-error@+3 {{token is not a valid binary operator in a preprocessor subexpression}}
      6 #endif
      7 // Valid because 'and' is a spelling of '&&'
      8 #if defined foo and bar
      9 #endif
     10 
     11 // Not valid in C++ unless -fno-operator-names is passed:
     12 
     13 #ifdef OPERATOR_NAMES
     14 //expected-error@+2 {{C++ operator 'and' (aka '&&') used as a macro name}}
     15 #endif
     16 #define and foo
     17 
     18 #ifdef OPERATOR_NAMES
     19 //expected-error@+2 {{C++ operator 'xor' (aka '^') used as a macro name}}
     20 #endif
     21 #if defined xor
     22 #endif
     23 
     24 // For error recovery we continue as though the identifier was a macro name regardless of -fno-operator-names.
     25 #ifdef OPERATOR_NAMES
     26 //expected-error@+3 {{C++ operator 'and' (aka '&&') used as a macro name}}
     27 #endif
     28 //expected-warning@+2 {{and is defined}}
     29 #ifdef and
     30 #warning and is defined
     31 #endif
     32