[PATCH] Do not fail if -fsyntax-only is passed to Fortran compilation.Fixes PR22234.

Artem Belevich tra at google.com
Thu Jan 29 10:12:30 PST 2015


Removed extraneous comment line.

Updating D7210: Do not fail if -fsyntax-only is passed to Fortran compilation.
==============================================================================

Fixes PR22234.


http://reviews.llvm.org/D7210

Files:
  lib/Driver/Tools.cpp
  test/Driver/gfortran.f90

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,12 @@
 !
 ! Clang understands this one and orders it weirdly.
 ! CHECK: "-fsyntax-only"
+
+! PR22234: Verifies that -fsyntax-only no longer fails with fortran files.
+!
+! 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"

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7210.18975.patch
Type: text/x-patch
Size: 1746 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150129/0943d6b6/attachment.bin>


More information about the cfe-commits mailing list