* [PATCH] PR fortran/68154 -- repair damage done byfix for PR fortran/65429
@ 2015-10-30 0:03 Steve Kargl
2015-10-30 9:31 ` Paul Richard Thomas
0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2015-10-30 0:03 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 664 bytes --]
The attached patch restores 3 lines of code removed in my
fix for PR fortran/65429. The code now checks for a NULL
character length in the typespec. If it is indeed NULL,
gfortran will look for a valid constructor to use (ie.,
the 3 lines of code). It is somewhat surprising that
it took 6 months for this bug to appear. Patch tested
on x86_64-*-freebsd. OK to commit?
2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68154
* decl.c (add_init_expr_to_sym): if the char length in the typespec
is NULL, check for and use the constructor.
2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68154
*gfortran.dg/pr68154.f90
--
Steve
[-- Attachment #2: pr68154.diff --]
[-- Type: text/x-diff, Size: 1340 bytes --]
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 229542)
+++ gcc/fortran/decl.c (working copy)
@@ -1461,7 +1461,16 @@ add_init_expr_to_sym (const char *name,
}
else if (init->expr_type == EXPR_ARRAY)
{
- clen = mpz_get_si (init->ts.u.cl->length->value.integer);
+ if (init->ts.u.cl)
+ clen = mpz_get_si (init->ts.u.cl->length->value.integer);
+ else if (init->value.constructor)
+ {
+ gfc_constructor *c;
+ c = gfc_constructor_first (init->value.constructor);
+ clen = c->expr->value.character.length;
+ }
+ else
+ clen = 1;
sym->ts.u.cl->length
= gfc_get_int_expr (gfc_default_integer_kind,
NULL, clen);
Index: gcc/testsuite/gfortran.dg/pr68154.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68154.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/pr68154.f90 (working copy)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/68154
+! Original code contributed by Gerhard Steinmetz
+! gerhard dot steinmetz dot fortran at t-online dot de
+program p
+ character(1), parameter :: x1(2) = 'a'
+ character(*), parameter :: x2(2) = x1
+ character(*), parameter :: x3(*) = x1
+end
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/68154 -- repair damage done byfix for PR fortran/65429
2015-10-30 0:03 [PATCH] PR fortran/68154 -- repair damage done byfix for PR fortran/65429 Steve Kargl
@ 2015-10-30 9:31 ` Paul Richard Thomas
0 siblings, 0 replies; 2+ messages in thread
From: Paul Richard Thomas @ 2015-10-30 9:31 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
Dear Steve,
OK to commit.
Thanks for the fix.
Paul
On 30 October 2015 at 01:03, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
> The attached patch restores 3 lines of code removed in my
> fix for PR fortran/65429. The code now checks for a NULL
> character length in the typespec. If it is indeed NULL,
> gfortran will look for a valid constructor to use (ie.,
> the 3 lines of code). It is somewhat surprising that
> it took 6 months for this bug to appear. Patch tested
> on x86_64-*-freebsd. OK to commit?
>
> 2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/68154
> * decl.c (add_init_expr_to_sym): if the char length in the typespec
> is NULL, check for and use the constructor.
>
> 2015-10-29 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/68154
> *gfortran.dg/pr68154.f90
>
> --
> Steve
--
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.
Groucho Marx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-30 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 0:03 [PATCH] PR fortran/68154 -- repair damage done byfix for PR fortran/65429 Steve Kargl
2015-10-30 9:31 ` Paul Richard Thomas
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).