This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/50684] Incorrect error for move_alloc on element inside intent(in) pointer
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Oct 2011 19:52:57 +0000
- Subject: [Bug fortran/50684] Incorrect error for move_alloc on element inside intent(in) pointer
- Auto-submitted: auto-generated
- References: <bug-50684-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50684
--- Comment #1 from janus at gcc dot gnu.org 2011-10-12 19:52:57 UTC ---
Some carryover form PR50570, where I proposed a draft patch:
Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c (revision 179722)
+++ gcc/fortran/check.c (working copy)
@@ -458,7 +458,8 @@ variable_check (gfc_expr *e, int n, bool allow_pro
if (e->expr_type == EXPR_VARIABLE
&& e->symtree->n.sym->attr.intent == INTENT_IN
&& (gfc_current_intrinsic_arg[n]->intent == INTENT_OUT
- || gfc_current_intrinsic_arg[n]->intent == INTENT_INOUT))
+ || gfc_current_intrinsic_arg[n]->intent == INTENT_INOUT)
+ && !(e->symtree->n.sym->attr.pointer && e->ref))
{
gfc_error ("'%s' argument of '%s' intrinsic at %L cannot be INTENT(IN)",
gfc_current_intrinsic_arg[n]->name, gfc_current_intrinsic,
Tobias commented on this as follows ...
That won't work for:
type(t), intent(in) :: dt
call move_alloc(dt%allocatable, ...)
That's invalid as dt%allocatable is intent(in); it would be valid for, e.g.,
call move_alloc(dt%dt2%ptr%allocatable, ...)
One really needs to walk the expression.