[Bug fortran/52270] [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy

burnus at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Feb 16 09:57:00 GMT 2012


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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-16 09:54:51 UTC ---
Untested patch for both issues.

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4650,3 +4650,4 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool
alloc_obj,
   check_intentin = true;
-  ptr_component = sym->attr.pointer;
+  ptr_component = (sym->ts.type == BT_CLASS)
+                 ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer;
   for (ref = e->ref; ref && check_intentin; ref = ref->next)
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1708,5 +1708,6 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,

-  /* F2008, 12.5.2.5.  */
+  /* F2008, 12.5.2.5; IR F08/0073.  */
   if (formal->ts.type == BT_CLASS
-      && (CLASS_DATA (formal)->attr.class_pointer
+      && ((CLASS_DATA (formal)->attr.class_pointer
+          && !formal->attr.intent == INTENT_IN)
           || CLASS_DATA (formal)->attr.allocatable))



More information about the Gcc-bugs mailing list