summaryrefslogtreecommitdiffstats
path: root/test/Headers
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-06-09 16:29:35 +0000
committerErich Keane <erich.keane@intel.com>2017-06-09 16:29:35 +0000
commit3148514e3baca9b32f9da60915df952cc8b227b9 (patch)
treed059827c61b344c5b4d349d9d98509268834b08c /test/Headers
parent52709f3610567494b4a764660f01d29053fc37d8 (diff)
support operator keywords used in Windows SDK
to support operator keywords used in Windows SDK, alter token type when seen in system headers Hello, I submitted D33505 to address this problem, but the proposal was rejected as too big a hammer. This change will allow clang to parse the WindowsSDK header <query.h> which uses the operator name "or" as a field name. Treat cpp operator keywords as ordinary identifiers inside the Microsoft headers, but treat them as usual in the user's program. Original Submitter: Melanie Blower (mibintc) Differential Revision: https://reviews.llvm.org/D33782 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305087 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Headers')
-rw-r--r--test/Headers/ms-cppoperkey.cpp16
-rw-r--r--test/Headers/ms-cppoperkey1.cpp27
-rw-r--r--test/Headers/ms-cppoperkey2.cpp11
3 files changed, 54 insertions, 0 deletions
diff --git a/test/Headers/ms-cppoperkey.cpp b/test/Headers/ms-cppoperkey.cpp
new file mode 100644
index 0000000000..ca56ee17bc
--- /dev/null
+++ b/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/test/Headers/ms-cppoperkey1.cpp b/test/Headers/ms-cppoperkey1.cpp
new file mode 100644
index 0000000000..c03efc9dac
--- /dev/null
+++ b/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/test/Headers/ms-cppoperkey2.cpp b/test/Headers/ms-cppoperkey2.cpp
new file mode 100644
index 0000000000..2afed36b74
--- /dev/null
+++ b/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;
+}