summaryrefslogtreecommitdiff
path: root/gcc/fortran/intrinsic.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/intrinsic.c')
-rw-r--r--gcc/fortran/intrinsic.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c
index 2f60fe8c877..8965d509882 100644
--- a/gcc/fortran/intrinsic.c
+++ b/gcc/fortran/intrinsic.c
@@ -4919,9 +4919,11 @@ gfc_convert_type_warn (gfc_expr *expr, gfc_typespec *ts, int eflag, int wflag)
if (ts->type == BT_UNKNOWN)
goto bad;
- /* NULL and zero size arrays get their type here. */
- if (expr->expr_type == EXPR_NULL
- || (expr->expr_type == EXPR_ARRAY && expr->value.constructor == NULL))
+ /* NULL and zero size arrays get their type here, unless they already have a
+ typespec. */
+ if ((expr->expr_type == EXPR_NULL
+ || (expr->expr_type == EXPR_ARRAY && expr->value.constructor == NULL))
+ && expr->ts.type == BT_UNKNOWN)
{
/* Sometimes the RHS acquire the type. */
expr->ts = *ts;