diff options
author | Alp Toker <alp@nuanti.com> | 2014-05-31 03:38:17 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-05-31 03:38:17 +0000 |
commit | c5d194fcd3ea30bf3162bdea61e6d0ca67da8cb8 (patch) | |
tree | 0e7dcad4ec35e7da3bec0501bcce43631512c775 /clang/test/Preprocessor/cxx_oper_keyword.cpp | |
parent | f33619cb51c7b1a77f2063f5bb6be8dda81bf7c5 (diff) | |
download | bcm5719-llvm-c5d194fcd3ea30bf3162bdea61e6d0ca67da8cb8.tar.gz bcm5719-llvm-c5d194fcd3ea30bf3162bdea61e6d0ca67da8cb8.zip |
Preprocessor: recover gracefully when C++ operator names are used as macro identifiers
This failure mode shows up occasionally when users try to include C headers in
C++ projects or when porting from Windows. We might as well recover in the way
the user expected, thus avoiding confusing diagnostic messages at point of use.
llvm-svn: 209963
Diffstat (limited to 'clang/test/Preprocessor/cxx_oper_keyword.cpp')
-rw-r--r-- | clang/test/Preprocessor/cxx_oper_keyword.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/test/Preprocessor/cxx_oper_keyword.cpp b/clang/test/Preprocessor/cxx_oper_keyword.cpp index 03e2a661b97..89a094d073c 100644 --- a/clang/test/Preprocessor/cxx_oper_keyword.cpp +++ b/clang/test/Preprocessor/cxx_oper_keyword.cpp @@ -11,12 +11,21 @@ // Not valid in C++ unless -fno-operator-names is passed: #ifdef OPERATOR_NAMES -//expected-error@+2 {{C++ operator 'and' (aka '&&') cannot be used as a macro name}} +//expected-error@+2 {{C++ operator 'and' (aka '&&') used as a macro name}} #endif #define and foo #ifdef OPERATOR_NAMES -//expected-error@+2 {{C++ operator 'xor' (aka '^') cannot be used as a macro name}} +//expected-error@+2 {{C++ operator 'xor' (aka '^') used as a macro name}} #endif #if defined xor #endif + +// 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 |