]> granicus.if.org Git - clang/commitdiff
Revert "Using an invalid -O falls back on -O3 instead of an error"
authorSylvestre Ledru <sylvestre@debian.org>
Mon, 11 Nov 2013 20:51:44 +0000 (20:51 +0000)
committerSylvestre Ledru <sylvestre@debian.org>
Mon, 11 Nov 2013 20:51:44 +0000 (20:51 +0000)
This reverts commit r194403.

Was breaking too many tests...

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

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
test/Driver/clang_f_opts.c

index b14a3b6a55d13d43f02a6cf0aa2ca269be3d193f..ed49006b215d44145cbd36ff880e6647bc7c9f79 100644 (file)
@@ -113,7 +113,6 @@ def err_drv_unknown_toolchain : Error<
   "cannot recognize the type of the toolchain">;
 
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup<Deprecated>;
-def warn_drv_invalid_value : Warning<"optimization level '%0' is unsupported; using '%1%2' instead.">;
 def warn_c_kext : Warning<
   "ignoring -fapple-kext which is valid for C++ and Objective-C++ only">;
 def warn_drv_input_file_unused : Warning<
index 87ec76350e07bc888600876f28ca4f4f371965af..c69ad53360f5d5fdcb37af1fcfc144f4e16e8307 100644 (file)
@@ -2727,7 +2727,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // preprocessed inputs and configure concludes that -fPIC is not supported.
   Args.ClaimAllArgs(options::OPT_D);
 
-  // Manually translate -O4 to -O3; let clang fall back on -O3 for others
+  // Manually translate -O4 to -O3; let clang reject others.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
     if (A->getOption().matches(options::OPT_O4)) {
       CmdArgs.push_back("-O3");
index d02e4a3e987176ae4dcfea46f83358ebb9dd42a6..98745aca682c186192ec8c025db8457dda98369c 100644 (file)
@@ -299,14 +299,14 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   using namespace options;
   bool Success = true;
 
-  Opts.OptimizationLevel = getOptimizationLevel(Args, IK, Diags);
-  unsigned MaxOptLevel = 3;
-  if (Opts.OptimizationLevel > MaxOptLevel) {
-    // If the optimization level is not supported, fall back on the default optimization
-    Diags.Report(diag::warn_drv_invalid_value)
-        << Args.getLastArg(OPT_O)->getAsString(Args) << "-O" << MaxOptLevel;
-    Opts.OptimizationLevel = MaxOptLevel;
+  unsigned OptLevel = getOptimizationLevel(Args, IK, Diags);
+  if (OptLevel > 3) {
+    Diags.Report(diag::err_drv_invalid_value)
+      << Args.getLastArg(OPT_O)->getAsString(Args) << OptLevel;
+    OptLevel = 3;
+    Success = false;
   }
+  Opts.OptimizationLevel = OptLevel;
 
   // We must always run at least the always inlining pass.
   Opts.setInlining(
index 462b11a112e3d4a75a55396f3be2a056ba1d7913..e8375838dca65873100c16d6e2ce44b54202ffa1 100644 (file)
 // CHECK-MAX-O: warning: -O4 is equivalent to -O3
 // CHECK-MAX-O: -O3
 
-// RUN: %clang -### -S -O20 %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-O %s
-// CHECK-INVALID-O: warning: optimization level '-O20' is unsupported; using '-O3' instead.
-
 // Test that we don't error on these.
 // RUN: %clang -### -S -Werror                                                \
 // RUN:     -falign-functions -falign-functions=2 -fno-align-functions        \