------- Comment #4 from burnus at gcc dot gnu dot org  2009-07-01 14:37 -------
The generic interface problem should be fixed by the following, which includes
the bits from the others patches:

--- trans-expr.c        (revision 149129)
+++ trans-expr.c        (working copy)
@@ -2778 +2778 @@ gfc_conv_procedure_call (gfc_se * se, gf
-      if (gfc_option.rtcheck & GFC_RTCHECK_POINTER)
+      if (gfc_option.rtcheck & GFC_RTCHECK_POINTER && e != NULL)
@@ -2780 +2780 @@ gfc_conv_procedure_call (gfc_se * se, gf
-         gfc_symbol *sym;
+         symbol_attribute *attr;
@@ -2785 +2785 @@ gfc_conv_procedure_call (gfc_se * se, gf
-           sym = e->symtree->n.sym;
+           attr = &e->symtree->n.sym->attr;
@@ -2787 +2787,10 @@ gfc_conv_procedure_call (gfc_se * se, gf
-           sym = e->symtree->n.sym->result;
+           {
+             /* For intrinsic functions, the gfc_attr are not available.  */
+             if (e->symtree->n.sym->attr.generic && e->value.function.isym)
+               goto end_pointer_check;
+
+             if (e->symtree->n.sym->attr.generic)
+               attr = &e->value.function.esym->result->attr;
+             else
+               attr = &e->symtree->n.sym->result->attr;
+           }
@@ -2791 +2800 @@ gfc_conv_procedure_call (gfc_se * se, gf
-         if (sym->attr.allocatable
+         if (attr->allocatable
@@ -2794,2 +2803,2 @@ gfc_conv_procedure_call (gfc_se * se, gf
-                     "allocated", sym->name);
-         else if (sym->attr.pointer
+                     "allocated", e->symtree->n.sym->name);
+         else if (attr->pointer
@@ -2798,2 +2807,2 @@ gfc_conv_procedure_call (gfc_se * se, gf
-                     "associated", sym->name);
-          else if (sym->attr.proc_pointer
+                     "associated", e->symtree->n.sym->name);
+          else if (attr->proc_pointer
@@ -2802 +2811 @@ gfc_conv_procedure_call (gfc_se * se, gf
-                     "associated", sym->name);
+                     "associated", e->symtree->n.sym->name);
@@ -2806 +2815,15 @@ gfc_conv_procedure_call (gfc_se * se, gf
-         cond  = fold_build2 (EQ_EXPR, boolean_type_node, parmse.expr,
+          if (sym->attr.optional)
+           {
+             tree present, nullptr, type;
+             type = TREE_TYPE (parmse.expr);
+              present = fold_build2 (NE_EXPR, boolean_type_node, parmse.expr,
+                                    fold_convert (type, null_pointer_node));
+             type = TREE_TYPE (type);
+             nullptr = fold_build2 (EQ_EXPR, boolean_type_node,
+                                    build1 (INDIRECT_REF, type, parmse.expr),
+                                    fold_convert (type, null_pointer_node));
+             cond = fold_build2 (TRUTH_ANDIF_EXPR, boolean_type_node,
+                                 present, nullptr);
+           }
+          else
+          cond = fold_build2 (EQ_EXPR, boolean_type_node, parmse.expr,


-- 


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

Reply via email to