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 @@ -6471,6 +6471,8 @@ 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<"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>, 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 @@ -7584,6 +7584,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