Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5076,16 +5076,21 @@ ArgStringList &CmdArgs) const { const Driver &D = getToolChain().getDriver(); + switch (JA.getType()) { // If -flto, etc. are present then make sure not to force assembly output. - if (JA.getType() == types::TY_LLVM_IR || JA.getType() == types::TY_LTO_IR || - JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC) + case types::TY_LLVM_IR: + case types::TY_LTO_IR: + case types::TY_LLVM_BC: + case types::TY_LTO_BC: CmdArgs.push_back("-c"); - else { - if (JA.getType() != types::TY_PP_Asm) - D.Diag(diag::err_drv_invalid_gcc_output_type) - << getTypeName(JA.getType()); - + break; + case types::TY_PP_Asm: CmdArgs.push_back("-S"); + case types::TY_Nothing: + CmdArgs.push_back("-fsyntax-only"); + break; + default: + D.Diag(diag::err_drv_invalid_gcc_output_type) << getTypeName(JA.getType()); } } Index: test/Driver/gfortran.f90 =================================================================== --- test/Driver/gfortran.f90 +++ test/Driver/gfortran.f90 @@ -242,3 +242,11 @@ ! ! Clang understands this one and orders it weirdly. ! CHECK: "-fsyntax-only" +! +! regression test for Bug 22234 +! RUN: %clang -no-canonical-prefixes -target i386-linux -fsyntax-only -### %s -o %t 2>&1 | \ +! grep for error message and command-line +! RUN: grep -e error: -e -fsyntax-only | FileCheck %s --check-prefix=CHECK-B22234 +! +! CHECK-B22234-NOT: clang: error: invalid output type +! CHECK-B22234: "-fsyntax-only"