aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-05-03 09:10:16 +0000
committerHans Wennborg <hans@hanshq.net>2013-05-03 09:10:16 +0000
commit6f464bb8d316b95bf60efcdb2d21803659d3aa1b (patch)
treee4d554844ad553b9d747996604c909adc6666eea /test
parentf5ebf9bf1df10ac15ba32a4b24dfe171b7848c58 (diff)
Support __wchar_t in -fms-extensions and -fms-compatibility modes.
MSVC provides __wchar_t, either as an alias for the built-in wchar_t type, or as a separate type depending on language (C vs C++) and flags (-fno-wchar). In -fms-extensions, Clang will simply accept __wchar_t as an alias for whatever type is used for wide character literals. In -fms-compatibility, we try to mimic MSVC's behavior by always making __wchar_t a builtin type. This fixes PR15815. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Lexer/ms-compatibility-wchar.c12
-rw-r--r--test/Lexer/ms-extensions-wchar.c12
2 files changed, 24 insertions, 0 deletions
diff --git a/test/Lexer/ms-compatibility-wchar.c b/test/Lexer/ms-compatibility-wchar.c
new file mode 100644
index 0000000000..966292eeb1
--- /dev/null
+++ b/test/Lexer/ms-compatibility-wchar.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple i386-pc-win32 %s
+
+// C++ mode with -fno-wchar works the same as C mode for wchar_t.
+// RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-compatibility -triple i386-pc-win32 %s
+
+wchar_t f(); // expected-error{{unknown type name 'wchar_t'}}
+
+// __wchar_t is available as an MS extension.
+__wchar_t g; // expected-note {{previous}}
+
+// __wchar_t is a distinct type, separate from the target's integer type for wide chars.
+unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}}
diff --git a/test/Lexer/ms-extensions-wchar.c b/test/Lexer/ms-extensions-wchar.c
new file mode 100644
index 0000000000..9321c3a914
--- /dev/null
+++ b/test/Lexer/ms-extensions-wchar.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
+
+// C++ mode with -fno-wchar works the same as C mode for wchar_t.
+// RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
+
+wchar_t f(); // expected-error{{unknown type name 'wchar_t'}}
+
+// __wchar_t is available as an MS extension.
+__wchar_t g(); // No error.
+
+// __wchar_t is the same as the target's integer type for wide chars.
+unsigned short g(); // No error.