Index: include/clang/Basic/DiagnosticFrontendKinds.td =================================================================== --- include/clang/Basic/DiagnosticFrontendKinds.td +++ include/clang/Basic/DiagnosticFrontendKinds.td @@ -116,6 +116,8 @@ "action %0 not compiled in">; def err_fe_invalid_alignment : Error< "invalid value '%1' in '%0'; alignment must be a power of 2">; +def err_fe_invalid_wchar_type + : Error<"invalid wchar_t type '%0'; must be one of 'char', 'short', 'int'">; def warn_fe_serialized_diag_merge_failure : Warning< "unable to merge a subprocess's serialized diagnostics">, Index: include/clang/Basic/LangOptions.def =================================================================== --- include/clang/Basic/LangOptions.def +++ include/clang/Basic/LangOptions.def @@ -175,7 +175,8 @@ BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control") LANGOPT(CharIsSigned , 1, 1, "signed char") -LANGOPT(ShortWChar , 1, 0, "unsigned short wchar_t") +LANGOPT(WCharSize , 4, 0, "width of wchar_t") +LANGOPT(WCharIsSigned , 1, 0, "signed or unsigned wchar_t") ENUM_LANGOPT(MSPointerToMemberRepresentationMethod, PragmaMSPointersToMembersKind, 2, PPTMK_BestCase, "member-pointer representation method") ENUM_LANGOPT(DefaultCallingConv, DefaultCallingConvention, 3, DCC_None, "default calling convention") Index: include/clang/Driver/CC1Options.td =================================================================== --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -703,6 +703,12 @@ HelpText<"Include the default header file for OpenCL">; def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, HelpText<"Preserve 3-component vector type">; +def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, + HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">; +def fsigned_wchar : Flag<["-"], "fsigned-wchar">, + HelpText<"Use a signed type for wchar_t">; +def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">, + HelpText<"Use an unsigned type for wchar_t">; // FIXME: Remove these entirely once functionality/tests have been excised. def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group, Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1377,9 +1377,9 @@ def : Flag<["-"], "fsched-interblock">, Group; def fshort_enums : Flag<["-"], "fshort-enums">, Group, Flags<[CC1Option]>, HelpText<"Allocate to an enum type only as many bytes as it needs for the declared range of possible values">; -def fshort_wchar : Flag<["-"], "fshort-wchar">, Group, Flags<[CC1Option]>, +def fshort_wchar : Flag<["-"], "fshort-wchar">, Group, HelpText<"Force wchar_t to be a short unsigned int">; -def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group, Flags<[CC1Option]>, +def fno_short_wchar : Flag<["-"], "fno-short-wchar">, Group, HelpText<"Force wchar_t to be an unsigned int">; def fshow_overloads_EQ : Joined<["-"], "fshow-overloads=">, Group, Flags<[CC1Option]>, HelpText<"Which overload candidates to show when overload resolution fails: " Index: lib/Basic/TargetInfo.cpp =================================================================== --- lib/Basic/TargetInfo.cpp +++ lib/Basic/TargetInfo.cpp @@ -290,8 +290,15 @@ void TargetInfo::adjust(LangOptions &Opts) { if (Opts.NoBitFieldTypeAlign) UseBitFieldTypeAlignment = false; - if (Opts.ShortWChar) - WCharType = UnsignedShort; + + switch (Opts.WCharSize) { + default: llvm_unreachable("invalid wchar_t width"); + case 0: break; + case 1: WCharType = Opts.WCharIsSigned ? SignedChar : UnsignedChar; break; + case 2: WCharType = Opts.WCharIsSigned ? SignedShort : UnsignedShort; break; + case 4: WCharType = Opts.WCharIsSigned ? SignedInt : UnsignedInt; break; + } + if (Opts.AlignDouble) { DoubleAlign = LongLongAlign = 64; LongDoubleAlign = 64; Index: lib/Basic/Targets/AArch64.cpp =================================================================== --- lib/Basic/Targets/AArch64.cpp +++ lib/Basic/Targets/AArch64.cpp @@ -15,6 +15,7 @@ #include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringExtras.h" using namespace clang; using namespace clang::targets; @@ -34,14 +35,11 @@ : TargetInfo(Triple), ABI("aapcs") { if (getTriple().getOS() == llvm::Triple::NetBSD || getTriple().getOS() == llvm::Triple::OpenBSD) { - WCharType = SignedInt; - // NetBSD apparently prefers consistency across ARM targets to // consistency across 64-bit targets. Int64Type = SignedLongLong; IntMaxType = SignedLongLong; } else { - WCharType = UnsignedInt; Int64Type = SignedLong; IntMaxType = SignedLong; } @@ -154,7 +152,8 @@ if (Opts.UnsafeFPMath) Builder.defineMacro("__ARM_FP_FAST", "1"); - Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Opts.ShortWChar ? "2" : "4"); + Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", + llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4)); Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : "4"); @@ -420,7 +419,6 @@ // This is an LLP64 platform. // int:4, long:4, long long:8, long double:8. - WCharType = UnsignedShort; IntWidth = IntAlign = 32; LongWidth = LongAlign = 32; DoubleAlign = LongLongAlign = 64; @@ -500,7 +498,6 @@ const TargetOptions &Opts) : DarwinTargetInfo(Triple, Opts) { Int64Type = SignedLongLong; - WCharType = SignedInt; UseSignedCharForObjCBool = false; LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64; Index: lib/Basic/Targets/ARM.cpp =================================================================== --- lib/Basic/Targets/ARM.cpp +++ lib/Basic/Targets/ARM.cpp @@ -36,21 +36,6 @@ else SizeType = UnsignedInt; - switch (T.getOS()) { - case llvm::Triple::NetBSD: - case llvm::Triple::OpenBSD: - WCharType = SignedInt; - break; - case llvm::Triple::Win32: - WCharType = UnsignedShort; - break; - case llvm::Triple::Linux: - default: - // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int. - WCharType = UnsignedInt; - break; - } - UseBitFieldTypeAlignment = true; ZeroLengthBitfieldBoundary = 0; @@ -99,9 +84,6 @@ else SizeType = UnsignedLong; - // Revert to using SignedInt on apcs-gnu to comply with existing behaviour. - WCharType = SignedInt; - // Do not respect the alignment of bit-field types when laying out // structures. This corresponds to PCC_BITFIELD_TYPE_MATTERS in gcc. UseBitFieldTypeAlignment = false; @@ -689,7 +671,8 @@ "0x" + llvm::utohexstr(HW_FP & ~HW_FP_DP)); } - Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", Opts.ShortWChar ? "2" : "4"); + Builder.defineMacro("__ARM_SIZEOF_WCHAR_T", + llvm::utostr(Opts.WCharSize ? Opts.WCharSize : 4)); Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : "4"); @@ -932,7 +915,6 @@ WindowsARMTargetInfo::WindowsARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts), Triple(Triple) { - WCharType = UnsignedShort; SizeType = UnsignedInt; } @@ -1024,7 +1006,6 @@ const TargetOptions &Opts) : ARMleTargetInfo(Triple, Opts) { TLSSupported = false; - WCharType = UnsignedShort; DoubleAlign = LongLongAlign = 64; resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"); } Index: lib/Basic/Targets/AVR.h =================================================================== --- lib/Basic/Targets/AVR.h +++ lib/Basic/Targets/AVR.h @@ -52,7 +52,6 @@ PtrDiffType = SignedInt; IntPtrType = SignedInt; Char16Type = UnsignedInt; - WCharType = SignedInt; WIntType = SignedInt; Char32Type = UnsignedLong; SigAtomicType = SignedChar; Index: lib/Basic/Targets/OSTargets.h =================================================================== --- lib/Basic/Targets/OSTargets.h +++ lib/Basic/Targets/OSTargets.h @@ -477,8 +477,6 @@ public: PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo(Triple, Opts) { - this->WCharType = this->UnsignedShort; - // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits). this->MaxTLSAlign = 256; @@ -561,7 +559,6 @@ public: SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo(Triple, Opts) { - this->WCharType = this->SignedInt; // FIXME: WIntType should be SignedLong } }; Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -659,7 +659,6 @@ public: WindowsX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts) { - WCharType = UnsignedShort; DoubleAlign = LongLongAlign = 64; bool IsWinCOFF = getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF(); @@ -720,7 +719,6 @@ public: CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86_32TargetInfo(Triple, Opts) { - WCharType = UnsignedShort; DoubleAlign = LongLongAlign = 64; resetDataLayout("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); } @@ -901,7 +899,6 @@ public: WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts) { - WCharType = UnsignedShort; LongWidth = LongAlign = 32; DoubleAlign = LongLongAlign = 64; IntMaxType = SignedLongLong; @@ -993,7 +990,6 @@ CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86_64TargetInfo(Triple, Opts) { TLSSupported = false; - WCharType = UnsignedShort; } void getTargetDefines(const LangOptions &Opts, Index: lib/Basic/Targets/XCore.h =================================================================== --- lib/Basic/Targets/XCore.h +++ lib/Basic/Targets/XCore.h @@ -35,7 +35,6 @@ SizeType = UnsignedInt; PtrDiffType = SignedInt; IntPtrType = SignedInt; - WCharType = UnsignedChar; WIntType = UnsignedInt; UseZeroLengthBitfieldAlignment = true; resetDataLayout("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32" Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -474,10 +474,6 @@ // Width of wchar_t in bytes uint64_t WCharWidth = Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity(); - assert((LangOpts.ShortWChar || - llvm::TargetLibraryInfoImpl::getTargetWCharSize(Target.getTriple()) == - Target.getWCharWidth() / 8) && - "LLVM wchar_t size out of sync"); // We need to record the widths of enums and wchar_t, so that we can generate // the correct build attributes in the ARM backend. wchar_size is also used by Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2616,6 +2616,77 @@ Args.AddLastArg(CmdArgs, options::OPT_fmodules_disable_diagnostic_validation); } +static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T, + ArgStringList &CmdArgs) { + // -fsigned-char is default. + if (const Arg *A = Args.getLastArg(options::OPT_fsigned_char, + options::OPT_fno_signed_char, + options::OPT_funsigned_char, + options::OPT_fno_unsigned_char)) { + if (A->getOption().matches(options::OPT_funsigned_char) || + A->getOption().matches(options::OPT_fno_signed_char)) { + CmdArgs.push_back("-fno-signed-char"); + } + } else if (!isSignedCharDefault(T)) { + CmdArgs.push_back("-fno-signed-char"); + } + + const llvm::Triple::ArchType Arch = T.getArch(); + const llvm::Triple::OSType OS = T.getOS(); + + const bool IsARM = T.isARM() || T.isThumb(); + const bool IsAArch64 = + Arch == llvm::Triple::aarch64 || Arch == llvm::Triple::aarch64_be; + + const bool IsDarwin = T.isOSDarwin(); + const bool IsWindows = T.isOSWindows(); + const bool IsNetBSD = OS == llvm::Triple::NetBSD; + const bool IsOpenBSD = OS == llvm::Triple::OpenBSD; + const bool IsUnknownOS = OS == llvm::Triple::UnknownOS; + + const bool IsEABIEnvironment = T.getEnvironment() == llvm::Triple::EABI; + const bool IsGNUEnvironment= T.getEnvironment() == llvm::Triple::GNU; + + const bool IsMachO = T.isOSBinFormatMachO(); + + bool IsAPCSABI = false; + if (IsARM) { + llvm::ARM::ProfileKind ARMProfile = llvm::ARM::ProfileKind::INVALID; + + auto ARMArch = llvm::ARM::parseArch(T.getArchName()); + auto ARMSubArch = llvm::ARM::getSubArch(ARMArch); + ARMProfile = llvm::ARM::parseArchProfile(ARMSubArch); + + if (IsGNUEnvironment) + IsAPCSABI = true; + else if (IsNetBSD) + IsAPCSABI = true; + else if (T.isWatchABI()) + IsAPCSABI = true; + else if (IsMachO) + IsAPCSABI = !(IsEABIEnvironment || IsUnknownOS || + ARMProfile == llvm::ARM::ProfileKind::M); + } + + if (Arch == llvm::Triple::xcore) { + CmdArgs.push_back("-fwchar-type=char"); + CmdArgs.push_back("-fno-signed-wchar"); + } else if (Args.hasFlag(options::OPT_fshort_wchar, + options::OPT_fno_short_wchar, + IsWindows || OS == llvm::Triple::PS4)) { + CmdArgs.push_back("-fwchar-type=short"); + CmdArgs.push_back("-fno-signed-wchar"); + } else { + CmdArgs.push_back("-fwchar-type=int"); + // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int. + if ((IsARM && !IsNetBSD && !(IsWindows || IsOpenBSD || IsAPCSABI)) || + (IsAArch64 && !IsDarwin && (IsNetBSD || IsOpenBSD))) + CmdArgs.push_back("-fno-signed-wchar"); + else + CmdArgs.push_back("-fsigned-wchar"); + } +} + static void RenderObjCOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T, const ArgList &Args, ObjCRuntime &Runtime, bool InferCovariantReturns, @@ -2997,6 +3068,9 @@ Inputs.size() == 1) && "Unable to handle multiple inputs."); + const llvm::Triple *AuxTriple = + IsCuda ? getToolChain().getAuxTriple() : nullptr; + bool IsWindowsGNU = RawTriple.isWindowsGNUEnvironment(); bool IsWindowsCygnus = RawTriple.isWindowsCygwinEnvironment(); bool IsWindowsMSVC = RawTriple.isWindowsMSVCEnvironment(); @@ -3006,7 +3080,6 @@ // mode (i.e., getToolchain().getTriple() is NVPTX, not Windows), we need to // pass Windows-specific flags to cc1. if (IsCuda) { - const llvm::Triple *AuxTriple = getToolChain().getAuxTriple(); IsWindowsMSVC |= AuxTriple && AuxTriple->isWindowsMSVCEnvironment(); IsWindowsGNU |= AuxTriple && AuxTriple->isWindowsGNUEnvironment(); IsWindowsCygnus |= AuxTriple && AuxTriple->isWindowsCygwinEnvironment(); @@ -4009,17 +4082,7 @@ getToolChain().getArch() == llvm::Triple::hexagon)) CmdArgs.push_back("-fshort-enums"); - // -fsigned-char is default. - if (Arg *A = Args.getLastArg( - options::OPT_fsigned_char, options::OPT_fno_signed_char, - options::OPT_funsigned_char, options::OPT_fno_unsigned_char)) { - if (A->getOption().matches(options::OPT_funsigned_char) || - A->getOption().matches(options::OPT_fno_signed_char)) { - CmdArgs.push_back("-fno-signed-char"); - } - } else if (!isSignedCharDefault(RawTriple)) { - CmdArgs.push_back("-fno-signed-char"); - } + RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs); // -fuse-cxa-atexit is default. if (!Args.hasFlag( @@ -4188,12 +4251,6 @@ options::OPT_mno_constant_cfstrings)) CmdArgs.push_back("-fno-constant-cfstrings"); - // -fshort-wchar default varies depending on platform; only - // pass if specified. - if (Arg *A = Args.getLastArg(options::OPT_fshort_wchar, - options::OPT_fno_short_wchar)) - A->render(Args, CmdArgs); - // -fno-pascal-strings is default, only pass non-default. if (Args.hasFlag(options::OPT_fpascal_strings, options::OPT_fno_pascal_strings, false)) Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -386,6 +386,7 @@ Invocation->getPreprocessorOptsPtr(), getDiagnostics(), getLangOpts(), getSourceManager(), getPCMCache(), *HeaderInfo, *this, PTHMgr, /*OwnsHeaderSearch=*/true, TUKind); + getTarget().adjust(getLangOpts()); PP->Initialize(getTarget(), getAuxTarget()); // Note that this is different then passing PTHMgr to Preprocessor's ctor. Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2151,7 +2151,16 @@ Opts.ImplicitModules = !Args.hasArg(OPT_fno_implicit_modules); Opts.CharIsSigned = Opts.OpenCL || !Args.hasArg(OPT_fno_signed_char); Opts.WChar = Opts.CPlusPlus && !Args.hasArg(OPT_fno_wchar); - Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false); + if (const Arg *A = Args.getLastArg(OPT_fwchar_type_EQ)) { + Opts.WCharSize = llvm::StringSwitch(A->getValue()) + .Case("char", 1) + .Case("short", 2) + .Case("int", 4) + .Default(0); + if (Opts.WCharSize == 0) + Diags.Report(diag::err_fe_invalid_wchar_type) << A->getValue(); + } + Opts.WCharIsSigned = Args.hasFlag(OPT_fsigned_wchar, OPT_fno_signed_wchar, true); Opts.ShortEnums = Args.hasArg(OPT_fshort_enums); Opts.Freestanding = Args.hasArg(OPT_ffreestanding); Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding; Index: test/CXX/conv/conv.prom/p2.cpp =================================================================== --- test/CXX/conv/conv.prom/p2.cpp +++ test/CXX/conv/conv.prom/p2.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding -fshort-wchar %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding -fwchar-type=short -fno-signed-wchar %s // expected-no-diagnostics #include Index: test/CodeGen/aarch64-type-sizes.c =================================================================== --- test/CodeGen/aarch64-type-sizes.c +++ test/CodeGen/aarch64-type-sizes.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -emit-llvm -w -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -fwchar-type=int -fno-signed-wchar -emit-llvm -w -o - %s | FileCheck %s // char by definition has size 1 // CHECK: target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" Index: test/CodeGen/arm-metadata.c =================================================================== --- test/CodeGen/arm-metadata.c +++ test/CodeGen/arm-metadata.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s | FileCheck -check-prefix=DEFAULT %s // RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s -fshort-enums | FileCheck -check-prefix=SHORT-ENUM %s -// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s -fshort-wchar | FileCheck -check-prefix=SHORT-WCHAR %s +// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s -fwchar-type=short -fno-signed-wchar | FileCheck -check-prefix=SHORT-WCHAR %s // DEFAULT: !{{[0-9]+}} = !{i32 1, !"wchar_size", i32 4} // DEFAULT: !{{[0-9]+}} = !{i32 1, !"min_enum_size", i32 4} Index: test/CodeGen/coff-aarch64-type-sizes.c =================================================================== --- test/CodeGen/coff-aarch64-type-sizes.c +++ test/CodeGen/coff-aarch64-type-sizes.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -w -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-windows -emit-llvm -fwchar-type=short -fno-signed-wchar -w -o - %s | FileCheck %s // CHECK: target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128" // CHECK: target triple = "aarch64--windows-msvc" Index: test/CodeGen/ms-annotation.c =================================================================== --- test/CodeGen/ms-annotation.c +++ test/CodeGen/ms-annotation.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i686-windows %s -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple i686-windows %s -fwchar-type=short -fno-signed-wchar -fms-extensions -emit-llvm -o - | FileCheck %s // // Test that LLVM optimizations leave these intrinsics alone, for the most part. -// RUN: %clang_cc1 -O2 -triple i686-windows %s -fms-extensions -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -O2 -triple i686-windows %s -fwchar-type=short -fno-signed-wchar -fms-extensions -emit-llvm -o - | FileCheck %s void test1(void) { __annotation(L"a1"); Index: test/CodeGen/pascal-wchar-string.c =================================================================== --- test/CodeGen/pascal-wchar-string.c +++ test/CodeGen/pascal-wchar-string.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s -fpascal-strings -fshort-wchar | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - %s -fpascal-strings -fwchar-type=short -fno-signed-wchar | FileCheck %s // rdar://8020384 #include Index: test/CodeGen/string-literal-short-wstring.c =================================================================== --- test/CodeGen/string-literal-short-wstring.c +++ test/CodeGen/string-literal-short-wstring.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fshort-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM -// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fshort-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI +// RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM +// RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fwchar-type=short -fno-signed-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI // Runs in c++ mode so that wchar_t is available. // XFAIL: hexagon Index: test/CodeGen/string-literal-unicode-conversion.c =================================================================== --- test/CodeGen/string-literal-unicode-conversion.c +++ test/CodeGen/string-literal-unicode-conversion.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s // RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-CPP0X %s -// RUN: %clang_cc1 -x c++ -std=c++0x -fshort-wchar -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-SHORTWCHAR %s +// RUN: %clang_cc1 -x c++ -std=c++0x -fwchar-type=short -fno-signed-wchar -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-SHORTWCHAR %s // This file contains a mix of ISO-8859-1 and UTF-8 encoded data. // the literal assigned to 'aa' should be the ISO-8859-1 encoding for the code Index: test/CodeGen/wchar-const.c =================================================================== --- test/CodeGen/wchar-const.c +++ test/CodeGen/wchar-const.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-win32 | FileCheck %s --check-prefix=CHECK-WIN +// RUN: %clang_cc1 -emit-llvm %s -o - -triple i386-pc-win32 -fwchar-type=short -fno-signed-wchar | FileCheck %s --check-prefix=CHECK-WIN // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-apple-darwin | FileCheck %s --check-prefix=CHECK-DAR // This should pass for any endianness combination of host and target. Index: test/CodeGen/wchar-size.c =================================================================== --- test/CodeGen/wchar-size.c +++ test/CodeGen/wchar-size.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=LONG-WCHAR -// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -emit-llvm -o - %s | FileCheck %s -check-prefix=SHORT-WCHAR -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - -fshort-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR +// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -emit-llvm -o - %s | FileCheck %s -check-prefix=SHORT-WCHAR +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - -fwchar-type=short -fno-signed-wchar %s | FileCheck %s -check-prefix=SHORT-WCHAR // Note: -fno-short-wchar implies the target default is used; so there is no // need to test this separately here. Index: test/CodeGenCXX/mangle-ms-string-literals.cpp =================================================================== --- test/CodeGenCXX/mangle-ms-string-literals.cpp +++ test/CodeGenCXX/mangle-ms-string-literals.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -x c++ -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s -// RUN: %clang_cc1 -x c++ -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck %s +// RUN: %clang_cc1 -x c++ -std=c++11 -emit-llvm %s -o - -triple=i386-pc-win32 -fwchar-type=short -fno-signed-wchar | FileCheck %s +// RUN: %clang_cc1 -x c++ -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-win32 -fwchar-type=short -fno-signed-wchar | FileCheck %s const char *l255 = "\xff"; const char *l254 = "\xfe"; Index: test/CodeGenCXX/ms_wide_predefined_expr.cpp =================================================================== --- test/CodeGenCXX/ms_wide_predefined_expr.cpp +++ test/CodeGenCXX/ms_wide_predefined_expr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fms-extensions -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -fms-extensions -fwchar-type=short -fno-signed-wchar -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s // CHECK: @"\01??_C@_19DPFBEKIN@?$AAf?$AAu?$AAn?$AAc?$AA?$AA@" = linkonce_odr unnamed_addr constant [5 x i16] [i16 102, i16 117, i16 110, i16 99, i16 0], comdat, align 2 Index: test/Driver/clang_f_opts.c =================================================================== --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -12,7 +12,8 @@ // CHECK-OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fshort-enums -// CHECK-OPTIONS2: -fshort-wchar +// CHECK-OPTIONS2: -fwchar-type=short +// CHECK-OPTIONS2: -fno-signed-wchar // CHECK-OPTIONS2: -fno-common // CHECK-OPTIONS2: -fno-show-source-location @@ -471,10 +472,10 @@ // Make sure we don't match the -NOT lines with the linker invocation. // Delimiters match the start of the cc1 and the start of the linker lines // DELIMITERS: {{^ *"}} -// CHECK-WCHAR1: -fno-short-wchar -// CHECK-WCHAR1-NOT: -fshort-wchar -// CHECK-WCHAR2: -fshort-wchar -// CHECK-WCHAR2-NOT: -fno-short-wchar +// CHECK-WCHAR1: -fwchar-type=int +// CHECK-WCHAR1-NOT: -fwchar-type=short +// CHECK-WCHAR2: -fwchar-type=short +// CHECK-WCHAR2-NOT: -fwchar-type=int // DELIMITERS: {{^ *"}} // RUN: %clang -### -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NEW-PM %s Index: test/Driver/rewrite-legacy-objc.m =================================================================== --- test/Driver/rewrite-legacy-objc.m +++ test/Driver/rewrite-legacy-objc.m @@ -3,11 +3,11 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fwchar-type=int" "-fsigned-wchar" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" // TEST0: rewrite-legacy-objc.m" // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \ // RUN: FileCheck -check-prefix=TEST1 %s // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \ // RUN: FileCheck -check-prefix=TEST2 %s -// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" -// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" +// TEST1: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fwchar-type=int" "-fsigned-wchar" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" +// TEST2: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fwchar-type=int" "-fsigned-wchar" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" Index: test/Driver/rewrite-objc.m =================================================================== --- test/Driver/rewrite-objc.m +++ test/Driver/rewrite-objc.m @@ -3,4 +3,4 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fwchar-type=int" "-fsigned-wchar" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option" Index: test/Driver/wchar_t.c =================================================================== --- /dev/null +++ test/Driver/wchar_t.c @@ -0,0 +1,76 @@ +// RUN: %clang -### -target i386-unknown-solarisiiiiiii %s 2>&1 | FileCheck %s -check-prefix CHECK-SOLARIS +// CHECK-SOLARIS-DAG: "-fwchar-type=int" +// CHECK-SOLARIS-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target avr-unknown-none %s 2>&1 | FileCheck %s -check-prefix CHECK-AVR +// CHECK-AVR-DAG: "-fwchar-type=int" +// CHECK-AVR-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target arm-unknown-none-eabi %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM-AAPCS +// CHECK-ARM-AAPCS-DAG: "-fwchar-type=int" +// CHECK-ARM-AAPCS-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target arm-unknown-none-gnu %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM-APCS +// CHECK-ARM-APCS-DAG: "-fwchar-type=int" +// CHECK-ARM-APCS-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target arm-unknown-netbsd-gnu %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM-NETBSD-AAPCS +// CHECK-ARM-NETBSD-AAPCS-DAG: "-fwchar-type=int" +// CHECK-ARM-NETBSD-AAPCS-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target arm-unknown-openbsd %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM-OPENBSD +// CHECK-ARM-OPENBSD-DAG: "-fwchar-type=int" +// CHECK-ARM-OPENBSD-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target arm64-apple-ios %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM64-DARWIN +// CHECK-ARM64-DARWIN-DAG: "-fwchar-type=int" +// CHECK-ARM64-DARWIN-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target aarch64-unknown-netbsd %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM64-NETBSD +// CHECK-ARM64-NETBSD-DAG: "-fwchar-type=int" +// CHECK-ARM64-NETBSD-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target aarch64-unknown-openbsd %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM64-OPENBSD +// CHECK-ARM64-OPENBSD-DAG: "-fwchar-type=int" +// CHECK-ARM64-OPENBSD-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target aarch64-unknown-none %s 2>&1 | FileCheck %s -check-prefix CHECK-ARM64-AAPCS64 +// CHECK-ARM64-AAPCS64-DAG: "-fwchar-type=int" +// CHECK-ARM64-AAPCS64-DAG: "-fsigned-wchar" + +// RUN: %clang -### -target xcore-unknown-none %s 2>&1 | FileCheck %s -check-prefix CHECK-XCORE +// CHECK-XCORE-DAG: "-fwchar-type=char" +// CHECK-XCORE-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target x86_64-unknown-windows-cygnus %s 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN-X64 +// CHECK-CYGWIN-X64-DAG: "-fwchar-type=short" +// CHECK-CYGWIN-X64-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target x86_64-unknown-windows-msvc %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-X64 +// CHECK-MSVC-X64-DAG: "-fwchar-type=short" +// CHECK-MSVC-X64-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target i686-unknown-windows-cygnus %s 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN-X86 +// CHECK-CYGWIN-X86-DAG: "-fwchar-type=short" +// CHECK-CYGWIN-X86-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target i686-unknown-windows-msvc %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-X86 +// CHECK-MSVC-X86-DAG: "-fwchar-type=short" +// CHECK-MSVC-X86-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target x86_64-scei-ps4 %s 2>&1 | FileCheck %s -check-prefix CHECK-PS4 +// CHECK-PS4-DAG: "-fwchar-type=short" +// CHECK-PS4-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target thumbv7-unknown-windows-cygnus %s 2>&1 | FileCheck %s -check-prefix CHECK-CYGWIN-ARM +// CHECK-CYGWIN-ARM-DAG: "-fwchar-type=short" +// CHECK-CYGWIN-ARM-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target thumbv7-unknown-windows-msvc %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-ARM +// CHECK-MSVC-ARM-DAG: "-fwchar-type=short" +// CHECK-MSVC-ARM-DAG: "-fno-signed-wchar" + +// RUN: %clang -### -target aarch64-unknown-windows-msvc %s 2>&1 | FileCheck %s -check-prefix CHECK-MSVC-ARM64 +// CHECK-MSVC-ARM64-DAG: "-fwchar-type=short" +// CHECK-MSVC-ARM64-DAG: "-fno-signed-wchar" + Index: test/Headers/wchar_limits.cpp =================================================================== --- test/Headers/wchar_limits.cpp +++ test/Headers/wchar_limits.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify %s -// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -fshort-wchar %s +// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -fwchar-type=short -fno-signed-wchar %s // expected-no-diagnostics #include Index: test/Index/index-pch.cpp =================================================================== --- test/Index/index-pch.cpp +++ test/Index/index-pch.cpp @@ -1,4 +1,4 @@ -// RUN: c-index-test -write-pch %t.pch -fshort-wchar %s +// RUN: c-index-test -write-pch %t.pch -fwchar-type=short -fno-signed-wchar %s // RUN: env LIBCLANG_NOTHREADS=1 c-index-test -index-tu %t.pch | FileCheck %s // CHECK: [indexDeclaration]: kind: variable | name: wideStr Index: test/Lexer/wchar-signedness.c =================================================================== --- test/Lexer/wchar-signedness.c +++ test/Lexer/wchar-signedness.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-X86 -// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM -// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple thumbv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM +// RUN: %clang_cc1 -fsyntax-only -fwchar-type=int -fsigned-wchar -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=CHECK-X86 +// RUN: %clang_cc1 -fsyntax-only -fwchar-type=int -fno-signed-wchar -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM +// RUN: %clang_cc1 -fsyntax-only -fwchar-type=int -fno-signed-wchar -dM -E %s -triple thumbv7-none-eabi | FileCheck %s --check-prefix=CHECK-ARM // CHECK-X86-NOT: #define __WCHAR_UNSIGNED__ // CHECK-X86: #define __WINT_UNSIGNED__ 1 Index: test/Lexer/wchar.c =================================================================== --- test/Lexer/wchar.c +++ test/Lexer/wchar.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fshort-wchar -verify %s +// RUN: %clang_cc1 -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify %s void f() { (void)L"\U00010000"; // unicode escape produces UTF-16 sequence, so no warning Index: test/Preprocessor/init.c =================================================================== --- test/Preprocessor/init.c +++ test/Preprocessor/init.c @@ -253,26 +253,26 @@ // SCHAR-NOT:#define __UNSIGNED_CHAR__ // SCHAR:#define __clang__ 1 // -// RUN: %clang_cc1 -E -dM -fshort-wchar < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s +// RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s // wchar_t is u16 for targeting Win32. // FIXME: Implement and check x86_64-cygwin. -// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=x86_64-w64-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s +// RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-w64-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s // // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2 // SHORTWCHAR: #define __WCHAR_MAX__ 65535 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short // SHORTWCHAR: #define __WCHAR_WIDTH__ 16 // -// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=i686-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s -// RUN: %clang_cc1 -E -dM -fno-short-wchar -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s +// RUN: %clang_cc1 -E -dM -fwchar-type=int -fsigned-wchar -triple=i686-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s +// RUN: %clang_cc1 -E -dM -fwchar-type=int -fsigned-wchar -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s // // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32 // Other definitions vary from platform to platform -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s -// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 -check-prefix AARCH64-CXX %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=aarch64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64 -check-prefix AARCH64-CXX %s // // AARCH64:#define _LP64 1 // AARCH64-NOT:#define __AARCH64EB__ 1 @@ -464,7 +464,7 @@ // AARCH64:#define __WINT_WIDTH__ 32 // AARCH64:#define __aarch64__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64_be-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-BE %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=aarch64_be-none-none < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-BE %s // // AARCH64-BE:#define _LP64 1 // AARCH64-BE:#define __AARCH64EB__ 1 @@ -1039,7 +1039,7 @@ // AARCH64-OPENBSD:#define __WINT_WIDTH__ 32 // AARCH64-OPENBSD:#define __aarch64__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-freebsd11 < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-FREEBSD %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=aarch64-freebsd11 < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-FREEBSD %s // // AARCH64-FREEBSD:#define _LP64 1 // AARCH64-FREEBSD-NOT:#define __AARCH64EB__ 1 @@ -1424,7 +1424,7 @@ // AARCH64-DARWIN: #define __WINT_WIDTH__ 32 // AARCH64-DARWIN: #define __aarch64__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=short -fno-signed-wchar -triple=aarch64-windows-msvc < /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s // // AARCH64-MSVC: #define _INTEGRAL_MAX_BITS 64 // AARCH64-MSVC-NOT: #define _LP64 1 @@ -1451,7 +1451,7 @@ // AARCH64-MSVC: #define __ARM_FP16_FORMAT_IEEE 1 // AARCH64-MSVC: #define __ARM_PCS_AAPCS64 1 // AARCH64-MSVC: #define __ARM_SIZEOF_MINIMAL_ENUM 4 -// AARCH64-MSVC: #define __ARM_SIZEOF_WCHAR_T 4 +// AARCH64-MSVC: #define __ARM_SIZEOF_WCHAR_T 2 // AARCH64-MSVC: #define __BIGGEST_ALIGNMENT__ 16 // AARCH64-MSVC: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // AARCH64-MSVC: #define __CHAR16_TYPE__ unsigned short @@ -1585,8 +1585,8 @@ // AARCH64-MSVC: #define __WINT_WIDTH__ 32 // AARCH64-MSVC: #define __aarch64__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM %s -// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM -check-prefix ARM-CXX %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM %s +// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM -check-prefix ARM-CXX %s // // ARM-NOT:#define _LP64 // ARM:#define __APCS_32__ 1 @@ -1777,7 +1777,7 @@ // ARM:#define __arm 1 // ARM:#define __arm__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=armeb-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM-BE %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=armeb-none-none < /dev/null | FileCheck -match-full-lines -check-prefix ARM-BE %s // // ARM-BE-NOT:#define _LP64 // ARM-BE:#define __APCS_32__ 1 @@ -1967,7 +1967,7 @@ // ARM-BE:#define __arm 1 // ARM-BE:#define __arm__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFTFP %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm-none-linux-gnueabi -target-feature +soft-float -target-feature +soft-float-abi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABISOFTFP %s // // ARMEABISOFTFP-NOT:#define _LP64 // ARMEABISOFTFP:#define __APCS_32__ 1 @@ -2162,7 +2162,7 @@ // ARMEABISOFTFP:#define __arm 1 // ARMEABISOFTFP:#define __arm__ 1 -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-linux-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABIHARDFP %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm-none-linux-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix ARMEABIHARDFP %s // // ARMEABIHARDFP-NOT:#define _LP64 // ARMEABIHARDFP:#define __APCS_32__ 1 @@ -8819,7 +8819,7 @@ // X86_64-NETBSD:#define __x86_64 1 // X86_64-NETBSD:#define __x86_64__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4 %s +// RUN: %clang_cc1 -E -dM -ffreestanding -fwchar-type=short -fno-signed-wchar -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4 %s // // PS4:#define _LP64 1 // PS4:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ Index: test/Preprocessor/pr19649-unsigned-wchar_t.c =================================================================== --- test/Preprocessor/pr19649-unsigned-wchar_t.c +++ test/Preprocessor/pr19649-unsigned-wchar_t.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-pc-cygwin -E -x c %s -// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fshort-wchar -x c %s +// RUN: %clang_cc1 -triple i386-pc-cygwin -fwchar-type=short -fno-signed-wchar -E -x c %s +// RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -E -fwchar-type=short -fno-signed-wchar -x c %s #if (L'\0' - 1 < 0) # error "Unexpected expression evaluation result" Index: test/Preprocessor/stdint.c =================================================================== --- test/Preprocessor/stdint.c +++ test/Preprocessor/stdint.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -E -ffreestanding -triple=arm-none-none %s | FileCheck -check-prefix ARM %s +// RUN: %clang_cc1 -E -ffreestanding -fwchar-type=int -fno-signed-wchar -triple=arm-none-none %s | FileCheck -check-prefix ARM %s // // ARM:typedef long long int int64_t; // ARM:typedef long long unsigned int uint64_t; @@ -1278,13 +1278,13 @@ // X86_64_LINUX:WINT_MAX_ 4294967295U // // -// RUN: %clang_cc1 -E -ffreestanding -triple=i386-mingw32 %s | FileCheck -check-prefix I386_MINGW32 %s +// RUN: %clang_cc1 -E -ffreestanding -fwchar-type=short -fno-signed-wchar -triple=i386-mingw32 %s | FileCheck -check-prefix I386_MINGW32 %s // // I386_MINGW32:WCHAR_MAX_ 65535 // I386_MINGW32:WCHAR_MIN_ 0 // // -// RUN: %clang_cc1 -E -ffreestanding -triple=xcore-none-none %s | FileCheck -check-prefix XCORE %s +// RUN: %clang_cc1 -E -ffreestanding -fwchar-type=char -fno-signed-wchar -triple=xcore-none-none %s | FileCheck -check-prefix XCORE %s // // XCORE:typedef long long int int64_t; // XCORE:typedef long long unsigned int uint64_t; Index: test/Preprocessor/wchar_t.c =================================================================== --- /dev/null +++ test/Preprocessor/wchar_t.c @@ -0,0 +1,90 @@ +// RUN: %clang_cc1 -triple i386-pc-solaris -dM -E %s -o - | FileCheck %s -check-prefix CHECK-SOLARIS +// CHECK-SOLARIS-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-SOLARIS-DAG: #define __WCHAR_TYPE__ int +// CHECK-SOLARIS-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple avr-unknown-unknown -fwchar-type=int -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-AVR +// CHECK-AVR-DAG: #define __WCHAR_MAX__ 32767 +// CHECK-AVR-DAG: #define __WCHAR_TYPE__ int +// CHECK-AVR-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple arm-unknown-none-gnu -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-APCS +// CHECK-ARM-APCS-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM-APCS-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM-APCS-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple arm-unknown-netbsd-gnu -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-NETBSD-AAPCS +// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM-NETBSD-AAPCS-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM-NETBSD-AAPCS-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple arm-unknown-openbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM-OPENBSD +// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM-OPENBSD-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple arm64-apple-ios -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-DARWIN +// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM64-DARWIN-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM64-DARWIN-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple aarch64-unknown-netbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-NETBSD +// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM64-NETBSD-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM64-NETBSD-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple aarch64-unknown-openbsd -fsigned-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-OPENBSD +// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_MAX__ 2147483647 +// CHECK-ARM64-OPENBSD-DAG: #define __WCHAR_TYPE__ int +// CHECK-ARM64-OPENBSD-NOT: #define __WCHAR_UNSIGNED__ 0 + +// RUN: %clang_cc1 -triple aarch64-unknown-none -fwchar-type=int -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-ARM64-AAPCS64 +// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_MAX__ 4294967295U +// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_TYPE__ unsigned int +// CHECK-ARM64-AAPCS64-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple xcore-unknown-unknown -fwchar-type=char -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-XCORE +// CHECK-XCORE-DAG: #define __WCHAR_MAX__ 255 +// CHECK-XCORE-DAG: #define __WCHAR_TYPE__ unsigned char +// CHECK-XCORE-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple x86_64-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X64 +// CHECK-CYGWIN-X64-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-CYGWIN-X64-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-CYGWIN-X64-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X64 +// CHECK-MSVC-X64-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-MSVC-X64-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-MSVC-X64-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple i686-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-X86 +// CHECK-CYGWIN-X86-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-CYGWIN-X86-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-CYGWIN-X86-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-X86 +// CHECK-MSVC-X86-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-MSVC-X86-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-MSVC-X86-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-PS4 +// CHECK-PS4-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-PS4-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-PS4-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple thumbv7-unknown-windows-cygnus -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-CYGWIN-ARM +// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-CYGWIN-ARM-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple thumbv7-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM +// CHECK-MSVC-ARM-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-MSVC-ARM-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-MSVC-ARM-DAG: #define __WCHAR_UNSIGNED__ 1 + +// RUN: %clang_cc1 -triple aarch64-unknown-windows-msvc -fwchar-type=short -fno-signed-wchar -dM -E %s -o - | FileCheck %s -check-prefix CHECK-MSVC-ARM64 +// CHECK-MSVC-ARM64-DAG: #define __WCHAR_MAX__ 65535 +// CHECK-MSVC-ARM64-DAG: #define __WCHAR_TYPE__ unsigned short +// CHECK-MSVC-ARM64-DAG: #define __WCHAR_UNSIGNED__ 1 + Index: test/Preprocessor/woa-defaults.c =================================================================== --- test/Preprocessor/woa-defaults.c +++ test/Preprocessor/woa-defaults.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -dM -triple armv7-windows -E %s | FileCheck %s +// RUN: %clang_cc1 -dM -fwchar-type=short -fsigned-wchar -triple armv7-windows -E %s | FileCheck %s // RUN: %clang_cc1 -dM -fno-signed-char -triple armv7-windows -E %s \ // RUN: | FileCheck %s -check-prefix CHECK-UNSIGNED-CHAR Index: test/Preprocessor/woa-wchar_t.c =================================================================== --- test/Preprocessor/woa-wchar_t.c +++ test/Preprocessor/woa-wchar_t.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -dM -triple armv7-windows -E %s | FileCheck %s -// RUN: %clang_cc1 -dM -fno-signed-char -triple armv7-windows -E %s | FileCheck %s +// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple armv7-windows -E %s | FileCheck %s +// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -fno-signed-char -triple armv7-windows -E %s | FileCheck %s // CHECK: #define __WCHAR_TYPE__ unsigned short Index: test/Sema/format-strings-ms.c =================================================================== --- test/Sema/format-strings-ms.c +++ test/Sema/format-strings-ms.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s -// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s +// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -fwchar-type=short -fno-signed-wchar -triple=i386-pc-win32 %s +// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -fwchar-type=short -fno-signed-wchar -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s int printf(const char *format, ...) __attribute__((format(printf, 1, 2))); int scanf(const char * restrict, ...) ; Index: test/Sema/wchar.c =================================================================== --- test/Sema/wchar.c +++ test/Sema/wchar.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -fsyntax-only -verify -// RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR +// RUN: %clang_cc1 %s -fsyntax-only -fwchar-type=short -fno-signed-wchar -verify -DSHORT_WCHAR typedef __WCHAR_TYPE__ wchar_t; Index: test/SemaCXX/no-wchar.cpp =================================================================== --- test/SemaCXX/no-wchar.cpp +++ test/SemaCXX/no-wchar.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s -// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++98 %s -// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++11 %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify -std=c++98 %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fwchar-type=short -fno-signed-wchar -fno-wchar -verify -std=c++11 %s wchar_t x; // expected-error {{unknown type name 'wchar_t'}} typedef unsigned short wchar_t; Index: test/SemaCXX/short-wchar-sign.cpp =================================================================== --- test/SemaCXX/short-wchar-sign.cpp +++ test/SemaCXX/short-wchar-sign.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s -// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s +// RUN: %clang_cc1 -fwchar-type=short -fno-signed-wchar -fsyntax-only -pedantic -verify %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -verify %s // expected-no-diagnostics