* [PATCH] PR fortran/87993 -- An array can have a kind type inquiry suffix
@ 2019-08-13 4:48 Steve Kargl
2019-08-13 7:51 ` Janne Blomqvist
0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2019-08-13 4:48 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 441 bytes --]
The attached patch ahs been regression tested on x86_64-*-freebsd.
It probably borders on obvious, but I'll ask away. OK to commit?
2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/87993
* expr.c (gfc_simplify_expr): Simplifcation of an array with a kind
type inquiry suffix yields a constant expression.
2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/87993
* gfortran.dg/pr87993.f90: New test.
--
Steve
[-- Attachment #2: pr87993.diff --]
[-- Type: text/x-diff, Size: 1100 bytes --]
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 274320)
+++ gcc/fortran/expr.c (working copy)
@@ -2227,6 +2227,11 @@ gfc_simplify_expr (gfc_expr *p, int type)
if (!simplify_ref_chain (p->ref, type, &p))
return false;
+ /* If the following conditions hold, we found something like kind type
+ inquiry of the form a(2)%kind while simplify the ref chain. */
+ if (p->expr_type == EXPR_CONSTANT && !p->ref && !p->rank && !p->shape)
+ return true;
+
if (!simplify_constructor (p->value.constructor, type))
return false;
Index: gcc/testsuite/gfortran.dg/pr87993.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr87993.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr87993.f90 (working copy)
@@ -0,0 +1,8 @@
+! { dg-do run }
+! Code contributed by Gerhard Steinmetz <gscfq at t-online dot de>
+program p
+ integer, parameter :: a(2) = 1
+ integer, parameter :: b = a%kind
+ if (any(a /= 1)) stop 1
+ if (b /= kind(a)) stop 2
+end
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/87993 -- An array can have a kind type inquiry suffix
2019-08-13 4:48 [PATCH] PR fortran/87993 -- An array can have a kind type inquiry suffix Steve Kargl
@ 2019-08-13 7:51 ` Janne Blomqvist
2019-08-13 18:50 ` Steve Kargl
0 siblings, 1 reply; 3+ messages in thread
From: Janne Blomqvist @ 2019-08-13 7:51 UTC (permalink / raw)
To: Steve Kargl; +Cc: Fortran List, GCC Patches
On Tue, Aug 13, 2019 at 3:35 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> The attached patch ahs been regression tested on x86_64-*-freebsd.
> It probably borders on obvious, but I'll ask away. OK to commit?
>
> 2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/87993
> * expr.c (gfc_simplify_expr): Simplifcation of an array with a kind
> type inquiry suffix yields a constant expression.
>
> 2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/87993
> * gfortran.dg/pr87993.f90: New test.
Ok.
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PR fortran/87993 -- An array can have a kind type inquiry suffix
2019-08-13 7:51 ` Janne Blomqvist
@ 2019-08-13 18:50 ` Steve Kargl
0 siblings, 0 replies; 3+ messages in thread
From: Steve Kargl @ 2019-08-13 18:50 UTC (permalink / raw)
To: Janne Blomqvist; +Cc: Fortran List, GCC Patches
On Tue, Aug 13, 2019 at 09:53:34AM +0300, Janne Blomqvist wrote:
> On Tue, Aug 13, 2019 at 3:35 AM Steve Kargl
> <sgk@troutmask.apl.washington.edu> wrote:
> >
> > The attached patch ahs been regression tested on x86_64-*-freebsd.
> > It probably borders on obvious, but I'll ask away. OK to commit?
> >
> > 2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > PR fortran/87993
> > * expr.c (gfc_simplify_expr): Simplifcation of an array with a kind
> > type inquiry suffix yields a constant expression.
> >
> > 2019-08-12 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > PR fortran/87993
> > * gfortran.dg/pr87993.f90: New test.
>
> Ok.
>
Committed to trunk.
Committed to 9-branch successful regression testing.
--
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-13 18:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 4:48 [PATCH] PR fortran/87993 -- An array can have a kind type inquiry suffix Steve Kargl
2019-08-13 7:51 ` Janne Blomqvist
2019-08-13 18:50 ` 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).