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 @@ -709,6 +709,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 @@ -1382,9 +1382,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 @@ -19,6 +19,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/TargetParser.h" #include using namespace clang; @@ -290,8 +291,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,18 +35,20 @@ : 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; } + bool IsNetBSD = getTriple().getOS() == llvm::Triple::NetBSD; + bool IsOpenBSD = getTriple().getOS() == llvm::Triple::OpenBSD; + if (!getTriple().isOSDarwin() && !IsNetBSD && !IsOpenBSD) + WCharType = UnsignedInt; + LongWidth = LongAlign = PointerWidth = PointerAlign = 64; MaxVectorAlign = 128; MaxAtomicInlineWidth = 128; @@ -154,7 +157,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 +424,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; @@ -502,7 +505,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,20 +36,10 @@ 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. + bool IsNetBSD = T.getOS() == llvm::Triple::NetBSD; + bool IsOpenBSD = T.getOS() == llvm::Triple::OpenBSD; + if (!T.isOSWindows() && !IsNetBSD && !IsOpenBSD) WCharType = UnsignedInt; - break; - } UseBitFieldTypeAlignment = true; @@ -99,7 +89,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 @@ -689,7 +678,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 +922,6 @@ WindowsARMTargetInfo::WindowsARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts), Triple(Triple) { - WCharType = UnsignedShort; SizeType = UnsignedInt; } @@ -1023,8 +1012,8 @@ CygwinARMTargetInfo::CygwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : ARMleTargetInfo(Triple, Opts) { + this->WCharType = TargetInfo::UnsignedShort; 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,7 +477,7 @@ public: PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo(Triple, Opts) { - this->WCharType = this->UnsignedShort; + this->WCharType = TargetInfo::UnsignedShort; // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits). this->MaxTLSAlign = 256; @@ -561,7 +561,6 @@ public: SolarisTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : OSTargetInfo(Triple, Opts) { - this->WCharType = this->SignedInt; // FIXME: WIntType should be SignedLong } }; @@ -628,7 +627,9 @@ public: WindowsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) - : OSTargetInfo(Triple, Opts) {} + : OSTargetInfo(Triple, Opts) { + this->WCharType = TargetInfo::UnsignedShort; + } }; template Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -639,7 +639,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(); @@ -700,7 +699,7 @@ public: CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86_32TargetInfo(Triple, Opts) { - WCharType = UnsignedShort; + this->WCharType = TargetInfo::UnsignedShort; DoubleAlign = LongLongAlign = 64; resetDataLayout("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"); } @@ -886,7 +885,6 @@ public: WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : WindowsTargetInfo(Triple, Opts) { - WCharType = UnsignedShort; LongWidth = LongAlign = 32; DoubleAlign = LongLongAlign = 64; IntMaxType = SignedLongLong; @@ -979,8 +977,8 @@ public: CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) : X86_64TargetInfo(Triple, Opts) { + this->WCharType = TargetInfo::UnsignedShort; TLSSupported = false; - WCharType = UnsignedShort; } void getTargetDefines(const LangOptions &Opts, Index: lib/Driver/ToolChains/Clang.cpp =================================================================== --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2601,6 +2601,33 @@ 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"); + } + + if (const Arg *A = Args.getLastArg(options::OPT_fshort_wchar, + options::OPT_fno_short_wchar)) { + if (A->getOption().matches(options::OPT_fshort_wchar)) { + CmdArgs.push_back("-fwchar-type=short"); + CmdArgs.push_back("-fno-signed-wchar"); + } else { + CmdArgs.push_back("-fwchar-type=int"); + 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, @@ -2991,6 +3018,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(); @@ -3000,7 +3030,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(); @@ -4003,17 +4032,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( @@ -4182,12 +4201,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 @@ -2154,7 +2154,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/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/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-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-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/Driver/clang_f_opts.c =================================================================== --- test/Driver/clang_f_opts.c +++ test/Driver/clang_f_opts.c @@ -1,7 +1,7 @@ // REQUIRES: clang-driver // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s -// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s +// RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // CHECK-OPTIONS1: -split-stacks // CHECK-OPTIONS1: -fgnu-keywords @@ -12,7 +12,6 @@ // CHECK-OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fshort-enums -// CHECK-OPTIONS2: -fshort-wchar // CHECK-OPTIONS2: -fno-common // CHECK-OPTIONS2: -fno-show-source-location @@ -466,15 +465,15 @@ // RUN: %clang -### -S -fno-unsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN4 %s // CHAR-SIGN4-NOT: -fno-signed-char -// RUN: %clang -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s -// RUN: %clang -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s +// RUN: %clang -target x86_64-unknown-none-none -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s +// RUN: %clang -target x86_64-unknown-none-none -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s // 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/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.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,18 +253,18 @@ // 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 +// RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-unknown-windows-cygnus -E /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 -triple=i686-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s +// RUN: %clang_cc1 -E -dM -fwchar-type=int -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 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 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/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/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/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