aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-types.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/trans-types.c')
-rw-r--r--gcc/fortran/trans-types.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 85c13fa..2b4edfc 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -972,7 +972,14 @@ gfc_sym_type (gfc_symbol * sym)
See f95_get_function_decl. For dummy function parameters return the
function type. */
if (byref)
- type = build_reference_type (type);
+ {
+ /* We must use pointer types for potentially absent variables. The
+ optimizers assume a reference type argument is never NULL. */
+ if (sym->attr.optional || sym->ns->proc_name->attr.entry_master)
+ type = build_pointer_type (type);
+ else
+ type = build_reference_type (type);
+ }
return (type);
}