This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 Jan 2012 11:28:23 +0000
- Subject: [Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument
- Auto-submitted: auto-generated
- References: <bug-50981-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981
--- Comment #23 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-20 11:28:23 UTC ---
Created attachment 26392
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26392
Small test case for polymorphic optional dummies
(In reply to comment #22)
> Updated patch.
> This passes the full comment #13 test fixed as follows:
Truly awesome! Will you submit the patch?
* * *
Related, but a bit separate issue: OPTIONAL CLASS dummies. See attached test
case. It seems to mostly work with the patch below, except for one ICE and one
SEGV at run time. (And - out-commented part - I'm hitting an ICE which might be
the same as PR 46356 comment 2.)
TODO: In the fixed-up test case of comment 13, copy sub_t and change "type" to
"class" - copy all calls to sub_t - and modify those to call the new function.
See what will break ...
TODO2: Call both the original sub_t and the new function with polymorphic
components of derived types.
--- trans-expr.c (revision 183328)
+++ trans-expr.c (working copy)
@@ -576,8 +576,16 @@ gfc_conv_expr_present (gfc_symbol * sym)
gcc_assert (sym->attr.dummy);
decl = gfc_get_symbol_decl (sym);
- if (TREE_CODE (decl) != PARM_DECL)
+
+ if (sym->ts.type == BT_CLASS)
{
+ decl = gfc_class_data_get (decl);
+ if (CLASS_DATA (sym)->attr.dimension
+ || CLASS_DATA (sym)->attr.codimension)
+ decl = gfc_build_addr_expr (NULL_TREE, decl);
+ }
+ else if (TREE_CODE (decl) != PARM_DECL)
+ {
/* Array parameters use a temporary descriptor, we want the real
parameter. */
gcc_assert (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl))