* [PATCH, committed] Fix PR fortran/82884
@ 2017-11-08 21:01 Steve Kargl
0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2017-11-08 21:01 UTC (permalink / raw)
To: fortran, gcc-patches
Once the bug is found, the fix is obvious. Briefly,
in a typespec, ts.u.cl and ts.u.pad are in the same
union. When parsing a Hollerith, ts.u.pad is is set
to a nonzero value. Later, when resolving the array
constructor with Hollerith entities, a reference to
ts.u.cl is made which is a mangled non-NULL pointer.
The fix is to clear ts.u.pad in the hollerith to
character conversion function.
Regression tested on x86_64-*-freebsd.
2017-11-08 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82884
* arith.c (gfc_hollerith2character): Clear pad.
2017-11-08 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82884
* gfortran.dg/hollerith_character_array_constructor.f90: New test.
Index: gcc/fortran/arith.c
===================================================================
--- gcc/fortran/arith.c (revision 254461)
+++ gcc/fortran/arith.c (working copy)
@@ -2604,6 +2604,7 @@ gfc_hollerith2character (gfc_expr *src, int kind)
result = gfc_copy_expr (src);
result->ts.type = BT_CHARACTER;
result->ts.kind = kind;
+ result->ts.u.pad = 0;
result->value.character.length = result->representation.length;
result->value.character.string
Index: gcc/testsuite/gfortran.dg/hollerith_character_array_constructor.f90
===================================================================
--- gcc/testsuite/gfortran.dg/hollerith_character_array_constructor.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/hollerith_character_array_constructor.f90 (working copy)
@@ -0,0 +1,11 @@
+! { dg-do run }
+! { dg-options "-w" }
+! PR fortran/82884
+! Original code contributed by Gerhard Steinmetz
+program p
+ character :: c(4) = [1h(, 1hi, 1h4, 1h)]
+ if (c(1) /= '(') call abort
+ if (c(2) /= 'i') call abort
+ if (c(3) /= '4') call abort
+ if (c(4) /= ')') call abort
+end
--
Steve
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-08 21:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 21:01 [PATCH, committed] Fix PR fortran/82884 Steve Kargl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).