[Bug fortran/52864] [4.6/4.7/4.8 Regression] Assignment to pointer component for INTENT(IN) dummy argument
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 4 14:23:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52864
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-04-04
Ever Confirmed|0 |1
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-04 14:23:09 UTC ---
Interesting issue. The problem is that
ptr = <value>
is valid while
nonptr = <value>
is not. That was checked via "is_pointer". However, "ptr(1,1)" has is_pointer
== false (which is correct).
On the other hand, "check_intentin" handles both pointer assignments and normal
assignment. While for pointers:
ptr%ptr => null()
is valid, the following isn't
ptr => null()
By contrast,
val = value
val%val = value
are valid.
Solution: Set check_intentin differently for assignments than for pointer
assignments.
Draft patch.
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4654,11 +4654,15 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer,
bool alloc_obj,
for (ref = e->ref; ref && check_intentin; ref = ref->next)
{
if (ptr_component && ref->type == REF_COMPONENT)
check_intentin = false;
if (ref->type == REF_COMPONENT && ref->u.c.component->attr.pointer)
- ptr_component = true;
+ {
+ ptr_component = true;
+ if (!pointer)
+ check_intentin = false;
+ }
}
if (check_intentin && sym->attr.intent == INTENT_IN)
{
if (pointer && is_pointer)
{
More information about the Gcc-bugs
mailing list