diff options
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 9 | ||||
-rw-r--r-- | test/Driver/invalid-o-level.c | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 7876bcb243..8417aa48c0 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1076,13 +1076,14 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, using namespace cc1options; bool Success = true; - Opts.OptimizationLevel = getOptimizationLevel(Args, IK, Diags); - if (Opts.OptimizationLevel > 3) { + unsigned OptLevel = getOptimizationLevel(Args, IK, Diags); + if (OptLevel > 3) { Diags.Report(diag::err_drv_invalid_value) - << Args.getLastArg(OPT_O)->getAsString(Args) << Opts.OptimizationLevel; - Opts.OptimizationLevel = 3; + << 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.Inlining = (Opts.OptimizationLevel > 1) ? CodeGenOptions::NormalInlining diff --git a/test/Driver/invalid-o-level.c b/test/Driver/invalid-o-level.c new file mode 100644 index 0000000000..d5242c7ac0 --- /dev/null +++ b/test/Driver/invalid-o-level.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 %s -O900 2> %t.log +// RUN: FileCheck %s -input-file=%t.log + +// CHECK: invalid value '900' in '-O900' |