[PATCH] D117767: [flang] Get rid of code duplication in wrapper. Fix checking of undefined variables.

Yury Gribov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 06:48:03 PST 2022


ygribov updated this revision to Diff 402893.
ygribov retitled this revision from "[flang] Fix checking of undefined variables in wrapper." to "[flang] Get rid of code duplication in wrapper. Fix  checking of undefined variables.".
ygribov added a comment.

Resolve review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117767/new/

https://reviews.llvm.org/D117767

Files:
  flang/tools/f18/flang


Index: flang/tools/f18/flang
===================================================================
--- flang/tools/f18/flang
+++ flang/tools/f18/flang
@@ -270,6 +270,22 @@
   done
 }
 
+# === get_external_fc_name ====================================================
+#
+# Returns the name of external Fortran compiler based on values of
+# environment variables.
+# =============================================================================
+get_external_fc_name() {
+  if [[ -v FLANG_FC ]]; then
+    echo ${FLANG_FC}
+  elif [[ -v F18_FC ]]; then
+    # We support F18_FC for backwards compatibility.
+    echo ${F18_FC}
+  else
+    echo gfortran
+  fi
+}
+
 # === preprocess ==============================================================
 #
 # Runs the preprocessing. Fortran files are preprocessed using Flang. Other
@@ -285,18 +301,8 @@
   local -n other_srcs=$2
   local -n opts=$3
 
-  local ext_fc=""
-  if [[ -v $FLANG_FC ]]; then
-    ext_fc="${FLANG_FC}"
-  elif [[ -v $F18_FC ]]; then
-    # We support F18_FC for backwards compatibility.
-    ext_fc="${F18_FC}"
-  else
-    ext_fc=gfortran
-  fi
-
+  local ext_fc="$(get_external_fc_name)"
 
-  local ext_fc="${FLANG_FC:-gfortran}"
   local -r wd=$(cd "$(dirname "$0")/.." && pwd)
 
   # Use the provided output file name.
@@ -419,7 +425,7 @@
   done
 
   # STEP 2: Compile Fortran Source Files
-  readonly ext_fc="${F18_FC:-gfortran}"
+  local ext_fc="$(get_external_fc_name)"
   # Temporary object files generated by this script. To be deleted at the end.
   local temp_object_files=()
   for idx in "${!fortran_source_files[@]}"; do


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117767.402893.patch
Type: text/x-patch
Size: 1602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220125/2981e5bb/attachment.bin>


More information about the llvm-commits mailing list