public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikael at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument
Date: Wed, 11 Jan 2012 23:32:00 -0000	[thread overview]
Message-ID: <bug-50981-4-PDepuNQJto@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50981-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981

--- Comment #18 from Mikael Morin <mikael at gcc dot gnu.org> 2012-01-11 23:31:32 UTC ---
(In reply to comment #17)
> I think the proper solution is to remove the trans-stmt.c manual scalarization
> and handle somewhere in trans-{array,expr}.c the array bounds.
> 
Some of it might actually be dead code. I don't see where the `temp' variable
is used.

> Stupid attempts fail for various reasons: Changing the BT_CLASS to BT_DERIVED
> in gfc_trans_allocate does not work as one the offsets will no longer be
> class._size (why?). Keeping BT_CLASS but removing the gfc_add_data_component > in trans-stmt.c will ICE for dataref - and removing that as well will lead to
> valid code with class._size, but without scalarization loop ...

Below is my `stupid' attempt at the not-so-proper solution: it does an
`intelligent' e->ts.type == BT_CLASS in the new conditions in
gfc_conv_procedure_call.  It passes gfortran.dg/*elemental* and
gfortran.dg/*class*.  But it is admittedly somewhat hackish.



diff --git a/trans-expr.c b/trans-expr.c
index a2268a1..1a24d4b 100644
--- a/trans-expr.c
+++ b/trans-expr.c
@@ -3259,6 +3259,35 @@ conv_isocbinding_procedure (gfc_se * se, gfc_symbol *
sym,
 }


+static bool
+needs_class_data_ref (gfc_expr *e)
+{
+  gfc_ref *ref;
+  bool result;
+
+  if (e->expr_type != EXPR_VARIABLE)
+    return false;
+
+  if (e->symtree->n.sym->ts.type == BT_CLASS)
+    result = true;
+
+  for (ref = e->ref; ref; ref = ref->next)
+    {
+      if (ref->type != REF_COMPONENT)
+    {
+      result = false;
+      continue;
+    }
+
+      if (ref->u.c.component->ts.type == BT_CLASS)
+    result = true; 
+      else if (!strcmp (ref->u.c.component->name, "_data"))
+    result = false;
+    }
+
+  return result;
+}
+
 /* Generate code for a procedure call.  Note can return se->post != NULL.
    If se->direct_byref is set then se->expr contains the return parameter.
    Return nonzero, if the call has alternate specifiers.
@@ -3435,7 +3464,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
       else
         gfc_conv_expr_reference (&parmse, e);

-      if (fsym && fsym->ts.type == BT_DERIVED && e->ts.type == BT_CLASS)
+      if (fsym && fsym->ts.type == BT_DERIVED && needs_class_data_ref (e))
         parmse.expr = gfc_class_data_get (parmse.expr);

       /* The scalarizer does not repackage the reference to a class
@@ -3514,7 +3543,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,


           if (fsym && fsym->ts.type == BT_DERIVED
-              && e->ts.type == BT_CLASS)
+              && needs_class_data_ref (e))
             parmse.expr = gfc_class_data_get (parmse.expr);

           /* A class array element needs converting back to be a


  parent reply	other threads:[~2012-01-11 23:32 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 14:19 [Bug fortran/50981] New: [4.4/4.5/4.6/4.7 " burnus at gcc dot gnu.org
2011-11-03 16:39 ` [Bug fortran/50981] " mikael at gcc dot gnu.org
2011-11-03 17:12 ` burnus at gcc dot gnu.org
2011-11-03 19:20 ` mikael at gcc dot gnu.org
2011-11-05 12:14 ` rguenth at gcc dot gnu.org
2011-11-22 19:30 ` mikael at gcc dot gnu.org
2012-01-04 14:05 ` mikael at gcc dot gnu.org
2012-01-04 14:22 ` mikael at gcc dot gnu.org
2012-01-04 14:37 ` mikael at gcc dot gnu.org
2012-01-04 15:06 ` [Bug fortran/50981] [4.4/4.5/4.6 " mikael at gcc dot gnu.org
2012-01-04 15:06 ` mikael at gcc dot gnu.org
2012-01-05 14:51 ` mikael at gcc dot gnu.org
2012-01-05 14:51 ` mikael at gcc dot gnu.org
2012-01-06 11:07 ` burnus at gcc dot gnu.org
2012-01-10 14:21 ` burnus at gcc dot gnu.org
2012-01-10 14:29 ` burnus at gcc dot gnu.org
2012-01-10 15:16 ` mikael at gcc dot gnu.org
2012-01-10 17:31 ` mikael at gcc dot gnu.org
2012-01-10 23:56 ` burnus at gcc dot gnu.org
2012-01-11 23:32 ` mikael at gcc dot gnu.org [this message]
2012-01-16 20:17 ` burnus at gcc dot gnu.org
2012-01-18 10:45 ` burnus at gcc dot gnu.org
2012-01-18 13:29 ` mikael at gcc dot gnu.org
2012-01-20  0:49 ` mikael at gcc dot gnu.org
2012-01-20 11:37 ` burnus at gcc dot gnu.org
2012-01-20 15:53 ` mikael at gcc dot gnu.org
2012-01-20 16:25 ` dominiq at lps dot ens.fr
2012-01-21 12:30 ` dominiq at lps dot ens.fr
2012-01-25 23:27 ` mikael at gcc dot gnu.org
2012-01-25 23:27 ` burnus at gcc dot gnu.org
2012-01-26  0:37 ` mikael at gcc dot gnu.org
2012-01-26 16:42 ` dominiq at lps dot ens.fr
2012-01-28 14:00 ` dominiq at lps dot ens.fr
2012-01-29 13:56 ` dominiq at lps dot ens.fr
2012-01-29 14:00 ` burnus at gcc dot gnu.org
2012-01-29 14:08 ` dominiq at lps dot ens.fr
2012-02-02 23:14 ` mikael at gcc dot gnu.org
2012-02-03 15:06 ` burnus at gcc dot gnu.org
2012-02-12 15:47 ` mikael at gcc dot gnu.org
2012-02-21 13:36 ` burnus at gcc dot gnu.org
2012-03-04 21:05 ` mikael at gcc dot gnu.org
2012-03-04 21:50 ` mikael at gcc dot gnu.org
2012-03-13 13:22 ` [Bug fortran/50981] [4.5/4.6 " jakub at gcc dot gnu.org
2012-05-07 14:41 ` burnus at gcc dot gnu.org
2012-07-02 13:14 ` [Bug fortran/50981] [4.6 " rguenth at gcc dot gnu.org
2012-09-25 14:22 ` burnus at gcc dot gnu.org
2012-10-16 13:02 ` burnus at gcc dot gnu.org
2012-10-16 13:09 ` burnus 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-50981-4-PDepuNQJto@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).