* [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression
@ 2008-10-13 18:32 Mikael Morin
2008-10-31 15:13 ` Mikael Morin
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Morin @ 2008-10-13 18:32 UTC (permalink / raw)
To: correctifs gcc, gfortran
[-- Attachment #1: Type: text/plain, Size: 633 bytes --]
Hi,
this patch fixes PR35840.
It takes checking code from gfc_match_init_expr to a separated function
and uses it to check exotic (non-constant, but reducible) asynchronous
specifier ("y"//"e"//trim("s ") which reduces to "yes" was the one
reported).
This was first posted on the bugzilla, and pre-approved there.
It is regression tested.
Is this Ok ?*
Mikael.
PS : My copyright assignment should reach the FSF by the end of this
week or more probably next week.
(*) This is my first patch proposal so I'm awaiting comments about
everything (patch, Changelog, message, syntactic conventions, testcase,
...). Be very strict.
[-- Attachment #2: Changes --]
[-- Type: text/plain, Size: 535 bytes --]
2008-10-13 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35840
* expr.c (gfc_reduce_init_expr): New function, containing checking code
from gfc_match_init_expr, so that checking can be deferred.
(gfc_match_init_expr): Use gfc_reduce_init_expr.
* io.c (check_io_constraints): Use gfc_reduce_init_expr instead of
checking that the expression is a constant.
* match.h (gfc_reduce_init_expr): Prototype added.
2008-10-13 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35840
* gfortran.dg/write_check4.f90: New test.
[-- Attachment #3: 35840.diff --]
[-- Type: text/plain, Size: 3947 bytes --]
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (révision 141074)
+++ gcc/fortran/expr.c (copie de travail)
@@ -2378,21 +2378,15 @@
return t;
}
+/* Reduces a general expression to an initialization expression (a constant).
+ This used to be part of gfc_match_init_expr.
+ Note that this function doesn't free the given expression on FAILURE. */
-/* Match an initialization expression. We work by first matching an
- expression, then reducing it to a constant. */
-
-match
-gfc_match_init_expr (gfc_expr **result)
+gfc_try
+gfc_reduce_init_expr (gfc_expr *expr)
{
- gfc_expr *expr;
- match m;
gfc_try t;
- m = gfc_match_expr (&expr);
- if (m != MATCH_YES)
- return m;
-
gfc_init_expr = 1;
t = gfc_resolve_expr (expr);
if (t == SUCCESS)
@@ -2400,18 +2394,12 @@
gfc_init_expr = 0;
if (t == FAILURE)
- {
- gfc_free_expr (expr);
- return MATCH_ERROR;
- }
+ return FAILURE;
if (expr->expr_type == EXPR_ARRAY
&& (gfc_check_constructor_type (expr) == FAILURE
- || gfc_expand_constructor (expr) == FAILURE))
- {
- gfc_free_expr (expr);
- return MATCH_ERROR;
- }
+ || gfc_expand_constructor (expr) == FAILURE))
+ return FAILURE;
/* Not all inquiry functions are simplified to constant expressions
so it is necessary to call check_inquiry again. */
@@ -2419,6 +2407,33 @@
&& !gfc_in_match_data ())
{
gfc_error ("Initialization expression didn't reduce %C");
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+
+/* Match an initialization expression. We work by first matching an
+ expression, then reducing it to a constant. */
+
+match
+gfc_match_init_expr (gfc_expr **result)
+{
+ gfc_expr *expr;
+ match m;
+ gfc_try t;
+
+ expr = NULL;
+
+ m = gfc_match_expr (&expr);
+ if (m != MATCH_YES)
+ return m;
+
+ t = gfc_reduce_init_expr (expr);
+ if (t != SUCCESS)
+ {
+ gfc_free_expr (expr);
return MATCH_ERROR;
}
Index: gcc/fortran/io.c
===================================================================
--- gcc/fortran/io.c (révision 141074)
+++ gcc/fortran/io.c (copie de travail)
@@ -2973,7 +2973,7 @@
{
static const char * asynchronous[] = { "YES", "NO", NULL };
- if (dt->asynchronous->expr_type != EXPR_CONSTANT)
+ if (gfc_reduce_init_expr (dt->asynchronous) != SUCCESS)
{
gfc_error ("ASYNCHRONOUS= specifier at %L must be an initialization "
"expression", &dt->asynchronous->where);
Index: gcc/fortran/match.h
===================================================================
--- gcc/fortran/match.h (révision 141074)
+++ gcc/fortran/match.h (copie de travail)
@@ -199,6 +199,7 @@
/* expr.c -- FIXME: this one should be eliminated by moving the
matcher to matchexp.c and a call to a new function in expr.c that
only makes sure the init expr. is valid. */
+gfc_try gfc_reduce_init_expr (gfc_expr *expr);
match gfc_match_init_expr (gfc_expr **);
/* array.c. */
Index: gcc/testsuite/gfortran.dg/write_check4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/write_check4.f90 (révision 0)
+++ gcc/testsuite/gfortran.dg/write_check4.f90 (révision 0)
@@ -0,0 +1,17 @@
+! { dg-do compile }
+!
+! PR fortran/35840
+!
+! The asynchronous specifier for a data transfer statement shall be
+! an initialization expression
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+ character(2) :: no
+ no = "no"
+ open (unit=10, asynchronous = no) ! Ok, it isn't a transfer stmt
+ write(*,*, asynchronous="Y"//"E"//trim("S ")) ! Ok, it is an init expr
+ write(*,*, asynchronous=no) ! { dg-error "must be an initialization expression" }
+ read (*,*, asynchronous="Y"//"e"//trim("S "))
+ read (*,*, asynchronous=no) ! { dg-error "must be an initialization expression" }
+end
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression
2008-10-13 18:32 [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression Mikael Morin
@ 2008-10-31 15:13 ` Mikael Morin
2008-10-31 16:49 ` Mikael Morin
2008-10-31 16:49 ` Tobias Burnus
0 siblings, 2 replies; 4+ messages in thread
From: Mikael Morin @ 2008-10-31 15:13 UTC (permalink / raw)
To: correctifs gcc, gfortran
Hello,
same here:
ping and blablabla commit blablabla.
Mikael
Mikael Morin wrote:
> Hi,
>
> this patch fixes PR35840.
> It takes checking code from gfc_match_init_expr to a separated function
> and uses it to check exotic (non-constant, but reducible) asynchronous
> specifier ("y"//"e"//trim("s ") which reduces to "yes" was the one
> reported).
>
> This was first posted on the bugzilla, and pre-approved there.
> It is regression tested.
>
> Is this Ok ?*
> Mikael.
>
> PS : My copyright assignment should reach the FSF by the end of this
> week or more probably next week.
>
> (*) This is my first patch proposal so I'm awaiting comments about
> everything (patch, Changelog, message, syntactic conventions, testcase,
> ...). Be very strict.
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression
2008-10-31 15:13 ` Mikael Morin
2008-10-31 16:49 ` Mikael Morin
@ 2008-10-31 16:49 ` Tobias Burnus
1 sibling, 0 replies; 4+ messages in thread
From: Tobias Burnus @ 2008-10-31 16:49 UTC (permalink / raw)
To: Mikael Morin; +Cc: correctifs gcc, gfortran
Mikael Morin wrote:
>> This was first posted on the bugzilla, and pre-approved there.
>> It is regression tested.
>>
>> Is this Ok ?*
>>
A belate OK (since already checked in as Rev. 141497), but granted it
was pre-approved by Jerry in the PR.
Tobias
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression
2008-10-31 15:13 ` Mikael Morin
@ 2008-10-31 16:49 ` Mikael Morin
2008-10-31 16:49 ` Tobias Burnus
1 sibling, 0 replies; 4+ messages in thread
From: Mikael Morin @ 2008-10-31 16:49 UTC (permalink / raw)
To: correctifs gcc, gfortran
Patch committed as revision 141497.
I also fixed a wrong date in the ChangeLog for my previous commit.
For Tobias, sorry I have just got your e-mail.
This patch was reviewed on bugzilla only, I didn't get any feedback
after posting the patch on the list. But it is almost unchanged, with
just a testcase and a ChangeLog entry added.
Mikael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-31 16:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-13 18:32 [Patch, Fortran] PR fortran/35840: asynchronous specifier for a data transfert statement shall be an initialization expression Mikael Morin
2008-10-31 15:13 ` Mikael Morin
2008-10-31 16:49 ` Mikael Morin
2008-10-31 16:49 ` Tobias Burnus
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).