diff options
Diffstat (limited to 'clang/test/Headers')
| -rw-r--r-- | clang/test/Headers/ms-cppoperkey.cpp | 16 | ||||
| -rw-r--r-- | clang/test/Headers/ms-cppoperkey1.cpp | 27 | ||||
| -rw-r--r-- | clang/test/Headers/ms-cppoperkey2.cpp | 11 |
3 files changed, 54 insertions, 0 deletions
diff --git a/clang/test/Headers/ms-cppoperkey.cpp b/clang/test/Headers/ms-cppoperkey.cpp new file mode 100644 index 00000000000..ca56ee17bcb --- /dev/null +++ b/clang/test/Headers/ms-cppoperkey.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 \ +// RUN: -fms-compatibility -x c++-cpp-output \ +// RUN: -ffreestanding -fsyntax-only -Werror \ +// RUN: %s -verify +// expected-no-diagnostics +# 1 "t.cpp" +# 1 "query.h" 1 3 +// MS header <query.h> uses operator keyword as field name. +// Compile without syntax errors. +struct tagRESTRICTION + { + union _URes + { + int or; // Note use of cpp operator token + } res; + }; diff --git a/clang/test/Headers/ms-cppoperkey1.cpp b/clang/test/Headers/ms-cppoperkey1.cpp new file mode 100644 index 00000000000..c03efc9dacd --- /dev/null +++ b/clang/test/Headers/ms-cppoperkey1.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 \ +// RUN: -fms-compatibility -x c++-cpp-output \ +// RUN: -ffreestanding -fsyntax-only -Werror \ +// RUN: %s -verify + + +# 1 "t.cpp" +# 1 "query.h" 1 3 4 +// MS header <query.h> uses operator keyword as field name. +// Compile without syntax errors. +struct tagRESTRICTION + { + union _URes + { + int or; // Note use of cpp operator token + } res; + }; + ; + +int aa ( int x) +{ + // In system header code, treat operator keyword as identifier. + if ( // expected-note{{to match this '('}} + x>1 or x<0) return 1; // expected-error{{expected ')'}} + else return 0; +} + diff --git a/clang/test/Headers/ms-cppoperkey2.cpp b/clang/test/Headers/ms-cppoperkey2.cpp new file mode 100644 index 00000000000..2afed36b744 --- /dev/null +++ b/clang/test/Headers/ms-cppoperkey2.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-pc-win32 -fms-compatibility \ +// RUN: -ffreestanding -fsyntax-only -Werror %s -verify +// RUN: %clang_cc1 \ +// RUN: -ffreestanding -fsyntax-only -Werror %s -verify +// expected-no-diagnostics +int bb ( int x) +{ + // In user code, treat operator keyword as operator keyword. + if ( x>1 or x<0) return 1; + else return 0; +} |

