[Bug fortran/35203] OPTIONAL, VALUE actual argument cannot be an INTEGER 0

jvdelisle at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Feb 15 06:12:00 GMT 2008



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2008-02-15 06:11 -------
Try this, seems to work, though I have not regression tested.

Index: trans-expr.c
===================================================================
--- trans-expr.c        (revision 132313)
+++ trans-expr.c        (working copy)
@@ -139,8 +139,13 @@ gfc_conv_expr_present (gfc_symbol * sym)
              || GFC_ARRAY_TYPE_P (TREE_TYPE (decl)));
       decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
     }
-  return build2 (NE_EXPR, boolean_type_node, decl,
-                fold_convert (TREE_TYPE (decl), null_pointer_node));
+
+  if (sym->attr.value)
+    return build2 (NE_EXPR, boolean_type_node, build_fold_addr_expr (decl),
+                  fold_convert (TREE_TYPE (decl), null_pointer_node));
+  else
+    return build2 (NE_EXPR, boolean_type_node, decl,
+                  fold_convert (TREE_TYPE (decl), null_pointer_node));
 }



-- 


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



More information about the Gcc-bugs mailing list