public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60507] New: Passing real expression into procedure argument not caught
@ 2014-03-12 8:52 vladimir.fuka at gmail dot com
2014-03-12 13:47 ` [Bug fortran/60507] " janus at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: vladimir.fuka at gmail dot com @ 2014-03-12 8:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
Bug ID: 60507
Summary: Passing real expression into procedure argument not
caught
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.fuka at gmail dot com
This compiles fine with the trunk and crashes at runtime:
print *, f(g(x))
contains
real function f(fun)
procedure(g) :: fun
f = fun(1.)
end
real function g(x)
real, intent(in) :: x
end
end
Similar to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25147
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing real expression into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
@ 2014-03-12 13:47 ` janus at gcc dot gnu.org
2014-03-12 16:46 ` [Bug fortran/60507] Passing function call " janus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-03-12 13:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-03-12
CC| |janus at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org ---
Confirmed. With
print *, f(1.)
one gets the correct error:
print *, f(1.)
1
Error: Expected a procedure for argument 'fun' at (1)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
2014-03-12 13:47 ` [Bug fortran/60507] " janus at gcc dot gnu.org
@ 2014-03-12 16:46 ` janus at gcc dot gnu.org
2014-03-13 20:12 ` janus at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-03-12 16:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |janus at gcc dot gnu.org
Summary|Passing real expression |Passing function call into
|into procedure argument not |procedure argument not
|caught |caught
--- Comment #2 from janus at gcc dot gnu.org ---
This helps (not regtested yet):
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 208455)
+++ gcc/fortran/interface.c (working copy)
@@ -2741,7 +2741,12 @@ compare_actual_formal (gfc_actual_arglist **ap, gf
/* Satisfy F03:12.4.1.3 by ensuring that a procedure actual argument is
provided for a procedure formal argument. */
if (f->sym->attr.flavor == FL_PROCEDURE
- && gfc_expr_attr (a->expr).flavor != FL_PROCEDURE)
+ && !((a->expr->expr_type == EXPR_VARIABLE
+ && (a->expr->symtree->n.sym->attr.flavor == FL_PROCEDURE
+ || a->expr->symtree->n.sym->attr.proc_pointer))
+ || (a->expr->expr_type == EXPR_FUNCTION
+ && a->expr->symtree->n.sym->result->attr.proc_pointer)
+ || gfc_is_proc_ptr_comp (a->expr)))
{
if (where)
gfc_error ("Expected a procedure for argument '%s' at %L",
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
2014-03-12 13:47 ` [Bug fortran/60507] " janus at gcc dot gnu.org
2014-03-12 16:46 ` [Bug fortran/60507] Passing function call " janus at gcc dot gnu.org
@ 2014-03-13 20:12 ` janus at gcc dot gnu.org
2014-03-18 15:33 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-03-13 20:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
--- Comment #3 from janus at gcc dot gnu.org ---
The patch in comment #2 ICEs on this extended test case:
type :: t
procedure(g), pointer, nopass :: ppc => g
end type
procedure(g), pointer :: pp => g
type(t)::x
print *, f(g) ! ok
print *, f(g()) ! illegal
print *, f(pp) ! ok
print *, f(pp()) ! illegal
print *, f(x%ppc) ! ok
print *, f(x%ppc()) ! illegal
contains
real function f(fun)
procedure(g) :: fun
f = fun()
end function
real function g()
g = 1.
end function
end
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
` (2 preceding siblings ...)
2014-03-13 20:12 ` janus at gcc dot gnu.org
@ 2014-03-18 15:33 ` janus at gcc dot gnu.org
2014-12-26 13:42 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-03-18 15:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to janus from comment #3)
> The patch in comment #2 ICEs on this extended test case:
Here is a better patch which works on comment 2:
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 208566)
+++ gcc/fortran/interface.c (working copy)
@@ -2506,6 +2506,18 @@ gfc_has_vector_subscript (gfc_expr *e)
}
+static bool
+is_procptr_result (gfc_expr *expr)
+{
+ gfc_component *c = gfc_get_proc_ptr_comp (expr);
+ if (c)
+ return (c->ts.interface && (c->ts.interface->attr.proc_pointer == 1));
+ else
+ return ((expr->symtree->n.sym->result != expr->symtree->n.sym)
+ && (expr->symtree->n.sym->result->attr.proc_pointer == 1));
+}
+
+
/* Given formal and actual argument lists, see if they are compatible.
If they are compatible, the actual argument list is sorted to
correspond with the formal list, and elements for missing optional
@@ -2727,10 +2739,10 @@ compare_actual_formal (gfc_actual_arglist **ap, gf
argument is provided for a procedure pointer formal argument. */
if (f->sym->attr.proc_pointer
&& !((a->expr->expr_type == EXPR_VARIABLE
- && a->expr->symtree->n.sym->attr.proc_pointer)
+ && (a->expr->symtree->n.sym->attr.proc_pointer
+ || gfc_is_proc_ptr_comp (a->expr)))
|| (a->expr->expr_type == EXPR_FUNCTION
- && a->expr->symtree->n.sym->result->attr.proc_pointer)
- || gfc_is_proc_ptr_comp (a->expr)))
+ && is_procptr_result (a->expr))))
{
if (where)
gfc_error ("Expected a procedure pointer for argument '%s' at %L",
@@ -2741,7 +2753,12 @@ compare_actual_formal (gfc_actual_arglist **ap, gf
/* Satisfy F03:12.4.1.3 by ensuring that a procedure actual argument is
provided for a procedure formal argument. */
if (f->sym->attr.flavor == FL_PROCEDURE
- && gfc_expr_attr (a->expr).flavor != FL_PROCEDURE)
+ && !((a->expr->expr_type == EXPR_VARIABLE
+ && (a->expr->symtree->n.sym->attr.flavor == FL_PROCEDURE
+ || a->expr->symtree->n.sym->attr.proc_pointer
+ || gfc_is_proc_ptr_comp (a->expr)))
+ || (a->expr->expr_type == EXPR_FUNCTION
+ && is_procptr_result (a->expr))))
{
if (where)
gfc_error ("Expected a procedure for argument '%s' at %L",
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
` (3 preceding siblings ...)
2014-03-18 15:33 ` janus at gcc dot gnu.org
@ 2014-12-26 13:42 ` dominiq at lps dot ens.fr
2014-12-29 12:12 ` janus at gcc dot gnu.org
2015-01-02 11:25 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-26 13:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
What is the status of the patch in comment 4?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
` (4 preceding siblings ...)
2014-12-26 13:42 ` dominiq at lps dot ens.fr
@ 2014-12-29 12:12 ` janus at gcc dot gnu.org
2015-01-02 11:25 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2014-12-29 12:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
--- Comment #6 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #5)
> What is the status of the patch in comment 4?
Alive 'n' kickin' ;)
Still applies (with a bit of fuzz) and regtests cleanly.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/60507] Passing function call into procedure argument not caught
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
` (5 preceding siblings ...)
2014-12-29 12:12 ` janus at gcc dot gnu.org
@ 2015-01-02 11:25 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2015-01-02 11:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60507
--- Comment #7 from janus at gcc dot gnu.org ---
Author: janus
Date: Fri Jan 2 11:24:32 2015
New Revision: 219141
URL: https://gcc.gnu.org/viewcvs?rev=219141&root=gcc&view=rev
Log:
2015-01-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/60507
* interface.c (is_procptr_result): New function to check if an
expression is a procedure-pointer result.
(compare_actual_formal): Use it.
2015-01-02 Janus Weil <janus@gcc.gnu.org>
PR fortran/60507
* gfortran.dg/dummy_procedure_11: New.
Added:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/ChangeLog-2014
- copied unchanged from r219140, trunk/gcc/fortran/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/ChangeLog-2014
- copied unchanged from r219140, trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/dummy_procedure_11.f90
Modified:
trunk/gcc/fortran/interface.c
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-01-02 11:25 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 8:52 [Bug fortran/60507] New: Passing real expression into procedure argument not caught vladimir.fuka at gmail dot com
2014-03-12 13:47 ` [Bug fortran/60507] " janus at gcc dot gnu.org
2014-03-12 16:46 ` [Bug fortran/60507] Passing function call " janus at gcc dot gnu.org
2014-03-13 20:12 ` janus at gcc dot gnu.org
2014-03-18 15:33 ` janus at gcc dot gnu.org
2014-12-26 13:42 ` dominiq at lps dot ens.fr
2014-12-29 12:12 ` janus at gcc dot gnu.org
2015-01-02 11:25 ` janus at gcc dot gnu.org
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).