public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60507] Passing function call into procedure argument not caught
Date: Tue, 18 Mar 2014 15:33:00 -0000	[thread overview]
Message-ID: <bug-60507-4-MLx9nzquPh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-60507-4@http.gcc.gnu.org/bugzilla/>

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",


  parent reply	other threads:[~2014-03-18 15:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12  8:52 [Bug fortran/60507] New: Passing real expression " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60507-4-MLx9nzquPh@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).