http://gcc.gnu.org/ml/fortran/2009-09/msg00003.html

g77 - but also openf95, sunf95 or ifort - support the following Fortran 66
vendor extension, which was effectively obsoleted by Fortran 77.

      LOGICAL :: L
      INTEGER :: I
      REAL    :: R
      DATA L/'abcd'/, I/'Text'/, R/'ZYXW'/  ! Missing legacy extension
      print *, L, transfer(L,"1234")
      print *, I, transfer(I,"1234")
      print *, R, transfer(R,"1234")
      END


Tim wrote: "Hollerith constant expressed with apostrophes was a vendor
extension to f66, typically supported by IBM and HP but few others. Its use was
often a sign of intentional non-portability. In order to support the extension
in f77, it involved the new extension of supporting character strings to assign
and initialize Hollerith."

 * * *

One needs to add a conversion similar as done in gfc_simplify_transfer -
with the proper warning if the string is too long (ignored characters)
or too short (undefined value) - somewhere in gfc_check_assign. The
first steps will be:

Index: expr.c
===================================================================
--- expr.c      (revision 151272)
+++ expr.c      (working copy)
@@ -3021,6 +3021,18 @@ gfc_check_assign (gfc_expr *lvalue, gfc_
       if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
        return SUCCESS;

+      if ((gfc_numeric_ts (&lvalue->ts) || lvalue->ts.type == BT_LOGICAL)
+         && rvalue->ts.type == BT_CHARACTER)
+        {
+         if (gfc_notify_std (GFC_STD_LEGACY, "Legacy: Assigning character "
+                        "literal in DATA statement at %L to a
noncharacter "
+                        "variable", &rvalue->where) == FAILURE)
+           return FAILURE;
+
+FIXME: Do actual conversion similar to gfc_simplify_transfer
+       (incl. too long/too shortwarnings)
+
+        }
+
       gfc_error ("Incompatible types in DATA statement at %L; attempted "
                 "conversion of %s to %s", &lvalue->where,
                 gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts));


-- 
           Summary: Vendor extension: character assignment in DATA to non-
                    character variables
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41218

Reply via email to