diff options
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/expr.cc | 13 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.cc | 35 |
2 files changed, 26 insertions, 22 deletions
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index a162744..be138d1 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -5573,11 +5573,14 @@ bool gfc_is_alloc_class_scalar_function (gfc_expr *expr) { if (expr->expr_type == EXPR_FUNCTION - && expr->value.function.esym - && expr->value.function.esym->result - && expr->value.function.esym->result->ts.type == BT_CLASS - && !CLASS_DATA (expr->value.function.esym->result)->attr.dimension - && CLASS_DATA (expr->value.function.esym->result)->attr.allocatable) + && ((expr->value.function.esym + && expr->value.function.esym->result + && expr->value.function.esym->result->ts.type == BT_CLASS + && !CLASS_DATA (expr->value.function.esym->result)->attr.dimension + && CLASS_DATA (expr->value.function.esym->result)->attr.allocatable) + || (expr->ts.type == BT_CLASS + && CLASS_DATA (expr)->attr.allocatable + && !CLASS_DATA (expr)->attr.dimension))) return true; return false; diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 9f6cc8f..d6f4d6b 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -8301,7 +8301,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, } /* Finalize the result, if necessary. */ - attr = CLASS_DATA (expr->value.function.esym->result)->attr; + attr = expr->value.function.esym + ? CLASS_DATA (expr->value.function.esym->result)->attr + : CLASS_DATA (expr)->attr; if (!((gfc_is_class_array_function (expr) || gfc_is_alloc_class_scalar_function (expr)) && attr.pointer)) @@ -10085,27 +10087,26 @@ trans_class_vptr_len_assignment (stmtblock_t *block, gfc_expr * le, if (re->expr_type != EXPR_VARIABLE && re->expr_type != EXPR_NULL && rse->expr != NULL_TREE) { - if (re->ts.type == BT_CLASS && !GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr))) - class_expr = gfc_get_class_from_expr (rse->expr); + if (!DECL_P (rse->expr)) + { + if (re->ts.type == BT_CLASS && !GFC_CLASS_TYPE_P (TREE_TYPE (rse->expr))) + class_expr = gfc_get_class_from_expr (rse->expr); - if (rse->loop) - pre = &rse->loop->pre; - else - pre = &rse->pre; + if (rse->loop) + pre = &rse->loop->pre; + else + pre = &rse->pre; - if (class_expr != NULL_TREE && UNLIMITED_POLY (re)) - { - tmp = TREE_OPERAND (rse->expr, 0); - tmp = gfc_create_var (TREE_TYPE (tmp), "rhs"); - gfc_add_modify (&rse->pre, tmp, TREE_OPERAND (rse->expr, 0)); + if (class_expr != NULL_TREE && UNLIMITED_POLY (re)) + tmp = gfc_evaluate_now (TREE_OPERAND (rse->expr, 0), &rse->pre); + else + tmp = gfc_evaluate_now (rse->expr, &rse->pre); + + rse->expr = tmp; } else - { - tmp = gfc_create_var (TREE_TYPE (rse->expr), "rhs"); - gfc_add_modify (&rse->pre, tmp, rse->expr); - } + pre = &rse->pre; - rse->expr = tmp; temp_rhs = true; } |