Hi Bernd,

Bernd Edlinger wrote:
> It was caused by a strict aliasing violation, when passing a value of the type
> "class(x),pointer" to a formal procedure parameter of the type 
> "class(x),target".

I assume a VIEW_CONVERT_EXPR is directly on the argument is insufficient? 
Otherwise,
I think I would prefer that:

+                     gfc_conv_expr (&parmse, e);
+                     parmse.expr = fold_build1_loc (input_location,
+                                                      VIEW_CONVERT_EXPR,
+                                                      type, parmse.expr));
+                     parmse.expr = gfc_build_addr_expr (parmse.expr)


Otherwise, the approach of using a temporary is okay, but I believe the 
condition

> +               else if (e->ts.type == BT_CLASS && fsym
> +                        && fsym->ts.type == BT_CLASS
> +                        && fsym->attr.target)

is wrong. What you intent to do is independent of the target attribute (~ 
restrict
qualifier).


We have three different cases:

* Allocatable
* Pointer
* Nonalloc/nonpointer

Besides staying in one's own group, one can do:

Pointer -> Nonalloc
Allocatable - > Noalloc
Nonallocatable*/Allocatable* -> Pointer with intent(in)

* = must have the target attribute

Thus, you need to handle those; gfc_expr_attr(e) should give you
information about the expression. Or one could always check against
   gfc_typenode_for_spec (&fsym->ts);
of both fsym and e.

Tobias

Reply via email to