From 51d7ae2eabd3354b9d11621a562386ee151fada5 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 29 Jan 2015 00:56:17 +0000 Subject: [PATCH] Ensure that -fsyntax-only with fortran 90 passes along silently to the underlying gcc. PR22234 Patch by Artem Belevich. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227409 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 19 ++++++++++++------- test/Driver/gfortran.f90 | 9 +++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index a2b494de74..1ff5be7b03 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5116,16 +5116,21 @@ void gcc::Compile::RenderExtraToolArgs(const JobAction &JA, 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()); } } diff --git a/test/Driver/gfortran.f90 b/test/Driver/gfortran.f90 index d531f59cd3..3631f8c9f4 100644 --- a/test/Driver/gfortran.f90 +++ b/test/Driver/gfortran.f90 @@ -242,3 +242,12 @@ ! ! Clang understands this one and orders it weirdly. ! CHECK: "-fsyntax-only" +! +! PR22234: Ensure that -fsyntax-only doesn't complain about output types and +! passes along correctly. +! 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-PR22234 +! +! CHECK-PR22234-NOT: clang: error: invalid output type +! CHECK-PR22234: "-fsyntax-only" -- 2.40.0