]> granicus.if.org Git - clang/commitdiff
Convert MC command line flag for fatal assembler warnings into a proper
authorJoerg Sonnenberger <joerg@bec.de>
Tue, 26 Aug 2014 18:40:25 +0000 (18:40 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Tue, 26 Aug 2014 18:40:25 +0000 (18:40 +0000)
flag.

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

include/clang/Driver/CC1Options.td
include/clang/Frontend/CodeGenOptions.def
lib/CodeGen/BackendUtil.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/Driver/fatal-warnings.c [new file with mode: 0644]
tools/driver/cc1as_main.cpp

index 837d5d5cf032fa40640f5989c4d18b6b34b0682a..2c699a2bbe50f964d58f47380ca1c755cf5ef437 100644 (file)
@@ -135,6 +135,8 @@ def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
   HelpText<"The string to embed in the Dwarf debug flags record.">;
 def mno_exec_stack : Flag<["-"], "mnoexecstack">,
   HelpText<"Mark the file as not needing an executable stack">;
+def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">,
+  HelpText<"Make assembler warnings fatal">;
 def compress_debug_sections : Flag<["-"], "compress-debug-sections">,
     HelpText<"Compress DWARF debug sections using zlib">;
 def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
index 71795a2ed2ab0830e81ec640bf693d64f137cc5a..06f4c1ab449df59cd1a4b61a77416ae78e982aab 100644 (file)
@@ -71,6 +71,8 @@ CODEGENOPT(NoCommon          , 1, 0) ///< Set when -fno-common or C++ is enabled
 CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm is
                                        ///< enabled.
 CODEGENOPT(NoExecStack       , 1, 0) ///< Set when -Wa,--noexecstack is enabled.
+CODEGENOPT(FatalWarnings     , 1, 0) ///< Set when -Wa,--fatal-warnings is
+                                     ///< enabled.
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is enabled.
 CODEGENOPT(NoGlobalMerge     , 1, 0) ///< Set when -mno-global-merge is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is enabled.
index 36a6c638e6f244c21bf5d545c5484fb05b51aafe..8829680314b5045bb570eb08f0326a93188f4ab1 100644 (file)
@@ -483,6 +483,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
   Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack;
+  Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
   Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
 
   TargetMachine *TM = TheTarget->createTargetMachine(Triple, TargetOpts.CPU,
index 08130890cf68b3b383e686ac8bbaafbd863f1b19..db1a48e6765bdf134723150fe13fc09f853c00ce 100644 (file)
@@ -2043,8 +2043,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
         } else if (Value == "-L") {
           CmdArgs.push_back("-msave-temp-labels");
         } else if (Value == "--fatal-warnings") {
-          CmdArgs.push_back("-mllvm");
-          CmdArgs.push_back("-fatal-assembler-warnings");
+          CmdArgs.push_back("-massembler-fatal-warnings");
         } else if (Value == "--noexecstack") {
           CmdArgs.push_back("-mnoexecstack");
         } else if (Value == "-compress-debug-sections" ||
index 9696c4902e1966fbb3b3f91aa020c5080c1d340f..3eb6df84a0d5ff0ff32267a2006174e160cc104a 100644 (file)
@@ -425,6 +425,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
   Opts.NoGlobalMerge = Args.hasArg(OPT_mno_global_merge);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
+  Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
   Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
   Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer);
diff --git a/test/Driver/fatal-warnings.c b/test/Driver/fatal-warnings.c
new file mode 100644 (file)
index 0000000..6239b25
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as -Wa,--fatal-warnings 2>&1 | FileCheck %s
+// RUN: not %clang %s -c -o %t.o -target i686-pc-linux-gnu -integrated-as -Wa,--fatal-warnings 2>&1 %t.log
+// FileCheck --check-prefix=CHECK-AS %s -input-file %t.log
+
+// CHECK: "-cc1" {{.*}} "-massembler-fatal-warnings"
+// CHECK-AS: error: .warning argument must be a string
+
+__asm(".warning 1");
index 9b847ab7c4c9e8170814910d005e1a1c7d55dd6c..1fa793c298eb2d2e0f4fe8e8fcc68fa5824e07f7 100644 (file)
@@ -123,6 +123,7 @@ struct AssemblerInvocation {
 
   unsigned RelaxAll : 1;
   unsigned NoExecStack : 1;
+  unsigned FatalWarnings : 1;
 
   /// @}
 
@@ -138,6 +139,7 @@ public:
     ShowEncoding = 0;
     RelaxAll = 0;
     NoExecStack = 0;
+    FatalWarnings = 0;
     DwarfVersion = 3;
   }
 
@@ -246,7 +248,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
 
   // Assemble Options
   Opts.RelaxAll = Args->hasArg(OPT_mrelax_all);
-  Opts.NoExecStack =  Args->hasArg(OPT_mno_exec_stack);
+  Opts.NoExecStack = Args->hasArg(OPT_mno_exec_stack);
+  Opts.FatalWarnings =  Args->hasArg(OPT_massembler_fatal_warnings);
 
   return Success;
 }