From 43a9eec7c4ce367bd971617831372cc53bbeb85a Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Sat, 21 May 2011 21:12:51 +0200 Subject: re PR fortran/48699 ([OOP] MOVE_ALLOC inside SELECT TYPE) 2011-05-21 Janus Weil PR fortran/48699 * match.c (select_type_set_tmp): Make the temporary ALLOCATABLE if the selector is ALLOCATABLE. 2011-05-21 Janus Weil PR fortran/48699 * gfortran.dg/select_type_23.f03: New. From-SVN: r174001 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/match.c | 6 +++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/select_type_23.f03 | 22 ++++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/select_type_23.f03 (limited to 'gcc') diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 45ca79c..b0f4e92 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-05-21 Janus Weil + + PR fortran/48699 + * match.c (select_type_set_tmp): Make the temporary ALLOCATABLE if the + selector is ALLOCATABLE. + 2011-05-20 Janus Weil PR fortran/48706 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index f1c953a..75f2a7f 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4533,7 +4533,11 @@ select_type_set_tmp (gfc_typespec *ts) gfc_get_sym_tree (name, gfc_current_ns, &tmp, false); gfc_add_type (tmp->n.sym, ts, NULL); gfc_set_sym_referenced (tmp->n.sym); - gfc_add_pointer (&tmp->n.sym->attr, NULL); + if (select_type_stack->selector->ts.type == BT_CLASS && + CLASS_DATA (select_type_stack->selector)->attr.allocatable) + gfc_add_allocatable (&tmp->n.sym->attr, NULL); + else + gfc_add_pointer (&tmp->n.sym->attr, NULL); gfc_add_flavor (&tmp->n.sym->attr, FL_VARIABLE, name, NULL); if (ts->type == BT_CLASS) gfc_build_class_symbol (&tmp->n.sym->ts, &tmp->n.sym->attr, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d5fba0b..fa4549c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-21 Janus Weil + + PR fortran/48699 + * gfortran.dg/select_type_23.f03: New. + 2011-05-20 Jason Merrill * g++.dg/cpp0x/defaulted26.C: New. diff --git a/gcc/testsuite/gfortran.dg/select_type_23.f03 b/gcc/testsuite/gfortran.dg/select_type_23.f03 new file mode 100644 index 0000000..d7788d2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_23.f03 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR 48699: [OOP] MOVE_ALLOC inside SELECT TYPE +! +! Contributed by Salvatore Filippone + +program testmv2 + + type bar + integer, allocatable :: ia(:), ja(:) + end type bar + + class(bar), allocatable :: sm,sm2 + + allocate(sm2) + + select type(sm2) + type is (bar) + call move_alloc(sm2,sm) + end select + +end program testmv2 -- cgit v1.1