This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran, committed] Fix PR31972, ICE on Hollerith in TRANSFER.


This is a trivial two-line fix. Once we know the size of a BT_HOLLERITH expression, we already know how to export it to the memory buffer, since all BT_HOLLERITH expressions have representation.string defined.

This patch also adds a check to make sure that we aren't transferring a value _to_ a Hollerith, because that makes no sense.

Regression tested on powerpc-apple-darwin8.9.0, committed to trunk.

-----------------------------------------------------------------
2007-05-28  Brooks Moses  <brooks.moses@codesourcery.com>

	PR fortran/31972
	* target-memory.c (gfc_target_expr_size): Add handling
	for size of BT_HOLLERITH variables.
	* check.c (gfc_check_transfer): Reject BT_HOLLERITH
	variables in MOLD argument of TRANSFER.

-----------------------------------------------------------------
2007-05-28  Brooks Moses  <brooks.moses@codesourcery.com>

	PR fortran/31972
	* transfer_hollerith_1.f90: New test.

-----------------------------------------------------------------

- Brooks
Index: target-memory.c
===================================================================
--- target-memory.c	(revision 125135)
+++ target-memory.c	(working copy)
@@ -102,6 +102,8 @@
       return size_logical (e->ts.kind);
     case BT_CHARACTER:
       return size_character (e->value.character.length);
+    case BT_HOLLERITH:
+      return e->representation.length;
     case BT_DERIVED:
       type = gfc_typenode_for_spec (&e->ts);
       return int_size_in_bytes (type);
Index: check.c
===================================================================
--- check.c	(revision 125106)
+++ check.c	(working copy)
@@ -2601,6 +2601,13 @@
 gfc_check_transfer (gfc_expr *source ATTRIBUTE_UNUSED,
 		    gfc_expr *mold ATTRIBUTE_UNUSED, gfc_expr *size)
 {
+  if (mold->ts.type == BT_HOLLERITH)
+    {
+      gfc_error ("'MOLD' argument of 'TRANSFER' intrinsic at %L must not be %s",
+		 &mold->where, gfc_basic_typename (BT_HOLLERITH));
+      return FAILURE;
+    }
+
   if (size != NULL)
     {
       if (type_check (size, 2, BT_INTEGER) == FAILURE)
! { dg-do compile }
! { dg-options "-O2" }
! PR 31972, ICE in transfer of Hollerith constant
  integer, dimension(1) :: i
  integer :: j
  i = (/ transfer(4HSOLR, 0) /)

  j = transfer(0, 4HSOLR) ! { dg-error "must not be HOLLERITH" }
end

! { dg-warning "Hollerith constant" "const" { target *-*-* } 6 }

! { dg-warning "Hollerith constant" "const" { target *-*-* } 8 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]