[flang-commits] [PATCH] D131756: [Fortran] Flexible matching for long character constant in FCVS FM905

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Fri Aug 12 02:34:03 PDT 2022


rovka created this revision.
rovka added reviewers: Meinersbur, sscalpone, klausler, awarzynski.
rovka added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
rovka requested review of this revision.

FM905 uses list-directed output for printing a long character constant.
By default, flang splits the constant when it reaches a line length of
80, whereas gfortran leaves it all on one line.

I couldn't find a clear way to tell flang to never introduce newlines,
nor a way to force a line length for gfortran. However, flang's line
length can be controlled via an environment variable called
FORT_FMT_RECL, so this patch updates the reference output to leave the
line unsplit (as gfortran would print it), and to set FORT_FMT_RECL to
1000 unless otherwise defined in the environment (which will effectively
cause flang to dump the whole constant on one line).


Repository:
  rT test-suite

https://reviews.llvm.org/D131756

Files:
  Fortran/UnitTests/fcvs21_f95/FM905.reference_output
  Fortran/UnitTests/fcvs21_f95/lit.local.cfg


Index: Fortran/UnitTests/fcvs21_f95/lit.local.cfg
===================================================================
--- Fortran/UnitTests/fcvs21_f95/lit.local.cfg
+++ Fortran/UnitTests/fcvs21_f95/lit.local.cfg
@@ -6,3 +6,12 @@
 # they might choke on warnings about signaling INEXACT exceptions.
 if 'NO_STOP_MESSAGE' in os.environ:
   config.environment['NO_STOP_MESSAGE'] = os.environ['NO_STOP_MESSAGE']
+
+# Flang uses FORT_FMT_RECL to control the length of a line for list-directed
+# output. FM905 needs a large enough value for this (values larger than about
+# 150 should work). We either forward the value that we find in the environment,
+# or set a default of 1000 to make sure the test passes.
+if 'FORT_FMT_RECL' in os.environ:
+  config.environment['FORT_FMT_RECL'] = os.environ['FORT_FMT_RECL']
+else:
+  config.environment['FORT_FMT_RECL'] = "1000"
Index: Fortran/UnitTests/fcvs21_f95/FM905.reference_output
===================================================================
--- Fortran/UnitTests/fcvs21_f95/FM905.reference_output
+++ Fortran/UnitTests/fcvs21_f95/FM905.reference_output
@@ -67,8 +67,7 @@
        5 O'CLOCK
      9    INSPECT
                  COMPUTED= 
- SHORTTHIS IS A LONGER CHARACTER STRING1234567890123456789012345678901234567890
- 12345678901234567890123456789012          
+ SHORTTHIS IS A LONGER CHARACTER STRING123456789012345678901234567890123456789012345678901234567890123456789012          
                  CORRECT=  
  SHORT  THIS IS A LONGER CHARACTER STRING 123456789012345678901234567890123456789
  012345678901234567890123456789012


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131756.452117.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220812/7e615887/attachment.bin>


More information about the flang-commits mailing list