aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@bugseng.com>2012-09-09 10:13:32 +0000
committerAbramo Bagnara <abramo.bagnara@bugseng.com>2012-09-09 10:13:32 +0000
commite75bb61f1b876afaa6b2f4a2b860c2889ea1d050 (patch)
tree05d2b31c098b085960ba77824e3f0c7b618b0828
parenteb3546eb1d9f43c9b5ed79bbc43d1ee6ebdddc5f (diff)
Fixed support for disabled wchar_t and added an appropriate test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163476 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTContext.cpp4
-rw-r--r--test/SemaCXX/no-wchar.cpp9
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index df1273cb1e..7942e10bbb 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -761,12 +761,12 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) {
InitBuiltinType(Int128Ty, BuiltinType::Int128);
InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128);
- if (LangOpts.CPlusPlus) { // C++ 3.9.1p5
+ if (LangOpts.CPlusPlus && LangOpts.WChar) { // C++ 3.9.1p5
if (TargetInfo::isTypeSigned(Target.getWCharType()))
InitBuiltinType(WCharTy, BuiltinType::WChar_S);
else // -fshort-wchar makes wchar_t be unsigned.
InitBuiltinType(WCharTy, BuiltinType::WChar_U);
- } else // C99
+ } else // C99 (or C++ using -fno-wchar)
WCharTy = getFromTargetType(Target.getWCharType());
WIntTy = getFromTargetType(Target.getWIntType());
diff --git a/test/SemaCXX/no-wchar.cpp b/test/SemaCXX/no-wchar.cpp
index b4ec2ed9a8..291b657f51 100644
--- a/test/SemaCXX/no-wchar.cpp
+++ b/test/SemaCXX/no-wchar.cpp
@@ -1,2 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -fno-wchar -verify %s
+// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s
wchar_t x; // expected-error {{unknown type name 'wchar_t'}}
+
+typedef unsigned short wchar_t;
+void foo(const wchar_t* x);
+
+void bar() {
+ foo(L"wide string literal");
+}