2014-05-21 14:13:51 +08:00
|
|
|
// RUN: %clang_cc1 %s -E -verify -DOPERATOR_NAMES
|
|
|
|
// RUN: %clang_cc1 %s -E -verify -fno-operator-names
|
2006-11-22 01:31:32 +08:00
|
|
|
|
2014-05-21 14:13:51 +08:00
|
|
|
#ifndef OPERATOR_NAMES
|
|
|
|
//expected-error@+3 {{token is not a valid binary operator in a preprocessor subexpression}}
|
|
|
|
#endif
|
|
|
|
// Valid because 'and' is a spelling of '&&'
|
|
|
|
#if defined foo and bar
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Not valid in C++ unless -fno-operator-names is passed:
|
2006-11-22 01:31:32 +08:00
|
|
|
|
2014-05-21 14:13:51 +08:00
|
|
|
#ifdef OPERATOR_NAMES
|
2014-05-31 11:38:17 +08:00
|
|
|
//expected-error@+2 {{C++ operator 'and' (aka '&&') used as a macro name}}
|
2014-05-21 14:13:51 +08:00
|
|
|
#endif
|
|
|
|
#define and foo
|
2006-11-22 01:31:32 +08:00
|
|
|
|
2014-05-21 14:13:51 +08:00
|
|
|
#ifdef OPERATOR_NAMES
|
2014-05-31 11:38:17 +08:00
|
|
|
//expected-error@+2 {{C++ operator 'xor' (aka '^') used as a macro name}}
|
2014-05-21 14:13:51 +08:00
|
|
|
#endif
|
2014-05-22 05:23:39 +08:00
|
|
|
#if defined xor
|
2014-05-21 14:13:51 +08:00
|
|
|
#endif
|
2014-05-31 11:38:17 +08:00
|
|
|
|
|
|
|
// For error recovery we continue as though the identifier was a macro name regardless of -fno-operator-names.
|
|
|
|
#ifdef OPERATOR_NAMES
|
|
|
|
//expected-error@+3 {{C++ operator 'and' (aka '&&') used as a macro name}}
|
|
|
|
#endif
|
|
|
|
//expected-warning@+2 {{and is defined}}
|
|
|
|
#ifdef and
|
|
|
|
#warning and is defined
|
|
|
|
#endif
|
2017-07-14 17:23:40 +08:00
|
|
|
|
|
|
|
#ifdef OPERATOR_NAMES
|
|
|
|
//expected-error@+2 {{invalid token at start of a preprocessor expression}}
|
|
|
|
#endif
|
|
|
|
#if or
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPERATOR_NAMES
|
|
|
|
//expected-error@+2 {{invalid token at start of a preprocessor expression}}
|
|
|
|
#endif
|
|
|
|
#if and_eq
|
|
|
|
#endif
|