cxx_oper_keyword.cpp 909 B

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