From: Abramo Bagnara Date: Sun, 9 Sep 2012 10:13:32 +0000 (+0000) Subject: Fixed support for disabled wchar_t and added an appropriate test. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e75bb61f1b876afaa6b2f4a2b860c2889ea1d050;p=clang 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 --- 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"); +}