diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2015-02-06 18:15:01 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2015-02-06 18:15:01 +0000 |
commit | 43a68a9df5b97efae86b3e8ab47776dc9d7fa702 (patch) | |
tree | c47511952bfacc8f9531ab1e507074197c8f3071 /gcc/fortran/expr.c | |
parent | 898c81f8312dedffeed01aac035324a698c249c7 (diff) | |
download | gcc-43a68a9df5b97efae86b3e8ab47776dc9d7fa702.zip gcc-43a68a9df5b97efae86b3e8ab47776dc9d7fa702.tar.gz gcc-43a68a9df5b97efae86b3e8ab47776dc9d7fa702.tar.bz2 |
re PR fortran/63205 ([OOP] Wrongly rejects type = class (for identical declared type))
2015-02-06 Paul Thomas <pault@gcc.gnu.org>
PR fortran/63205
* gfortran.h: Add 'must finalize' field to gfc_expr and
prototypes for gfc_is_alloc_class_scalar_function and for
gfc_is_alloc_class_array_function.
* expr.c (gfc_is_alloc_class_scalar_function,
gfc_is_alloc_class_array_function): New functions.
* trans-array.c (gfc_add_loop_ss_code): Do not move the
expression for allocatable class scalar functions outside the
loop.
(conv_array_index_offset): Cope with deltas being NULL_TREE.
(build_class_array_ref): Do not return with allocatable class
array functions. Add code to pick out the returned class array.
Dereference if necessary and return if not a class object.
(gfc_conv_scalarized_array_ref): Cope with offsets being NULL.
(gfc_walk_function_expr): Return an array ss for the result of
an allocatable class array function.
* trans-expr.c (gfc_conv_subref_array_arg): Remove the assert
that the argument should be a variable. If an allocatable class
array function, set the offset to zero and skip the write-out
loop in this case.
(gfc_conv_procedure_call): Add allocatable class array function
to the assert. Call gfc_conv_subref_array_arg for allocatable
class array function arguments with derived type formal arg..
Add the code for handling allocatable class functions, including
finalization calls to prevent memory leaks.
(arrayfunc_assign_needs_temporary): Return if an allocatable
class array function.
(gfc_trans_assignment_1): Set must_finalize to rhs expression
for allocatable class functions. Set scalar_to_array as needed
for scalar class allocatable functions assigned to an array.
Nullify the allocatable components corresponding the the lhs
derived type so that the finalization does not free them.
2015-02-06 Paul Thomas <pault@gcc.gnu.org>
PR fortran/63205
* gfortran.dg/class_to_type_4.f90: New test
From-SVN: r220482
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index e1fc1d0..ab6f7a5 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -4304,6 +4304,40 @@ gfc_is_proc_ptr_comp (gfc_expr *expr) } +/* Determine if an expression is a function with an allocatable class scalar + result. */ +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) + return true; + + return false; +} + + +/* Determine if an expression is a function with an allocatable class array + result. */ +bool +gfc_is_alloc_class_array_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) + return true; + + return false; +} + + /* Walk an expression tree and check each variable encountered for being typed. If strict is not set, a top-level variable is tolerated untyped in -std=gnu mode as is a basic arithmetic expression using those; this is for things in |