diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6487,6 +6487,10 @@ def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">, HelpText<"Disable two-phase name lookup in templates (default)">, Alias; +def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">, + HelpText<"Enable C++ builtin type wchar_t (default)">; +def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">, + HelpText<"Disable C++ builtin type wchar_t">; def _SLASH_Z7 : CLFlag<"Z7">, HelpText<"Enable CodeView debug information in object files">; def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>, @@ -6674,7 +6678,6 @@ def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; -def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; def _SLASH_ZH_MD5 : CLIgnoredFlag<"ZH:MD5">; def _SLASH_ZH_SHA1 : CLIgnoredFlag<"ZH:SHA1">; def _SLASH_ZH_SHA_256 : CLIgnoredFlag<"ZH:SHA_256">; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7589,6 +7589,11 @@ CmdArgs.push_back("-fno-dllexport-inlines"); } + if (Args.hasFlag(options::OPT__SLASH_Zc_wchar_t_, + options::OPT__SLASH_Zc_wchar_t, false)) { + CmdArgs.push_back("-fno-wchar"); + } + Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg); Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb); if (MostGeneralArg && BestCaseArg) diff --git a/clang/test/Driver/cl-zc.cpp b/clang/test/Driver/cl-zc.cpp --- a/clang/test/Driver/cl-zc.cpp +++ b/clang/test/Driver/cl-zc.cpp @@ -47,7 +47,7 @@ // RUN: %clang_cl /c -### /Zc:wchar_t -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-ON %s // WCHAR_T-ON-NOT: argument unused during compilation // RUN: %clang_cl /c -### /Zc:wchar_t- -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-OFF %s -// WCHAR_T-OFF: argument unused during compilation +// WCHAR_T-OFF: "-fno-wchar" // RUN: %clang_cl /c -### /Zc:auto -- %s 2>&1 | FileCheck -check-prefix=AUTO-ON %s // AUTO-ON-NOT: argument unused during compilation