]> granicus.if.org Git - clang/commitdiff
[clang-cl] Do not allow using both /Zc:dllexportInlines- and /fallback flag
authorTakuto Ikuta <takuto.ikuta@gmail.com>
Tue, 13 Nov 2018 04:14:09 +0000 (04:14 +0000)
committerTakuto Ikuta <takuto.ikuta@gmail.com>
Tue, 13 Nov 2018 04:14:09 +0000 (04:14 +0000)
Summary: /Zc:dllexportInlines with /fallback may cause unexpected linker error. It is better to disallow compile rather than warn for this combination.

Reviewers: hans, thakis

Reviewed By: hans

Subscribers: cfe-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D54426

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346733 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/ToolChains/Clang.cpp
lib/Driver/ToolChains/MSVC.cpp
test/Driver/cl-options.c

index 357b739d4ce57f709ee3c1355182947e111960ee..5d4a2264e7864781a9ebefcbcb91273acebd1fd4 100644 (file)
@@ -161,9 +161,8 @@ def warn_drv_yc_multiple_inputs_clang_cl : Warning<
   "support for '/Yc' with more than one source file not implemented yet; flag ignored">,
   InGroup<ClangClPch>;
 
-def warn_drv_non_fallback_argument_clang_cl : Warning<
-  "option '%0' is ignored when /fallback happens">,
-  InGroup<OptionIgnored>;
+def err_drv_dllexport_inlines_and_fallback : Error<
+  "option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'">;
 
 def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
 def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
index c35f7a94053cfaae7eeeade07d6dd9a0ad0eb36e..8de20f6e2e6f22af3577f4dc348eae592af5f6fd 100644 (file)
@@ -5502,8 +5502,13 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
 
  if (Args.hasFlag(options::OPT__SLASH_Zc_dllexportInlines_,
                   options::OPT__SLASH_Zc_dllexportInlines,
-                  false))
+                  false)) {
+   if (Args.hasArg(options::OPT__SLASH_fallback)) {
+     D.Diag(clang::diag::err_drv_dllexport_inlines_and_fallback);
+   } else {
     CmdArgs.push_back("-fno-dllexport-inlines");
+   }
+ }
 
   Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
   Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
index ac68db602f8cfc22649d6af7e68c6f4ff8b49c6b..839f313623097ae10271a7fe2447c8585ad691b0 100644 (file)
@@ -669,12 +669,6 @@ std::unique_ptr<Command> visualstudio::Compiler::GetCommand(
   // them too.
   Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN);
 
-  // Warning for ignored flag.
-  if (const Arg *dllexportInlines =
-      Args.getLastArg(options::OPT__SLASH_Zc_dllexportInlines_))
-    C.getDriver().Diag(clang::diag::warn_drv_non_fallback_argument_clang_cl)
-      << dllexportInlines->getAsString(Args);
-
   // Input filename.
   assert(Inputs.size() == 1);
   const InputInfo &II = Inputs[0];
index 12409431726bbe497de2bc897b11b99a41fdb8fc..f5171d5c040c5aa54267a25d627e6bcda742691e 100644 (file)
 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
 // DllExportInlines-NOT: "-fno-dllexport-inlines"
 // RUN: %clang_cl /fallback /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlinesFallback %s
-// DllExportInlinesFallback: warning: option '/Zc:dllexportInlines-' is ignored when /fallback happens [-Woption-ignored]
+// DllExportInlinesFallback: error: option '/Zc:dllexportInlines-' is ABI-changing and not compatible with '/fallback'
 
 // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s
 // Zi: "-gcodeview"