From: Tobias Burnus Date: Thu, 5 Feb 2015 21:58:38 +0000 (+0100) Subject: re PR fortran/64943 (No error on ultimate allocatable components in IO list) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2f72ca141dad4a52f34220c2be7113dca3dc4f0d;p=gcc.git re PR fortran/64943 (No error on ultimate allocatable components in IO list) 2015-02-05 Tobias Burnus PR fortran/64943 * resolve.c (resolve_transfer): Also check structure constructors. 2015-02-05 Tobias Burnus PR fortran/64943 * gfortran.dg/structure_constructor_12.f90: New. From-SVN: r220462 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index def6f1b2f2f..ae912cbe03f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2015-02-05 Tobias Burnus + + PR fortran/64943 + * resolve.c (resolve_transfer): Also check structure + constructors. + 2015-02-05 Paul Thomas PR fortran/64757 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 3b0c12a0e6b..0b188dad05b 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8364,7 +8364,8 @@ resolve_transfer (gfc_code *code) } if (exp == NULL || (exp->expr_type != EXPR_VARIABLE - && exp->expr_type != EXPR_FUNCTION)) + && exp->expr_type != EXPR_FUNCTION + && exp->expr_type != EXPR_STRUCTURE)) return; /* If we are reading, the variable will be changed. Note that @@ -8375,8 +8376,7 @@ resolve_transfer (gfc_code *code) _("item in READ"))) return; - sym = exp->symtree->n.sym; - ts = &sym->ts; + ts = exp->expr_type == EXPR_STRUCTURE ? &exp->ts : &exp->symtree->n.sym->ts; /* Go to actual component transferred. */ for (ref = exp->ref; ref; ref = ref->next) @@ -8436,6 +8436,11 @@ resolve_transfer (gfc_code *code) return; } } + + if (exp->expr_type == EXPR_STRUCTURE) + return; + + sym = exp->symtree->n.sym; if (sym->as != NULL && sym->as->type == AS_ASSUMED_SIZE && exp->ref && exp->ref->type == REF_ARRAY && exp->ref->u.ar.type == AR_FULL) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a86c9db6de..cf3a21e282e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-05 Tobias Burnus + + PR fortran/64943 + * gfortran.dg/structure_constructor_12.f90: New. + 2015-02-05 Jeff Law PR target/58400 diff --git a/gcc/testsuite/gfortran.dg/structure_constructor_12.f90 b/gcc/testsuite/gfortran.dg/structure_constructor_12.f90 new file mode 100644 index 00000000000..aa7e91d96e6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/structure_constructor_12.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! +! PR fortran/64943 +! +! Contributed Dominique d'Humieres +! + type :: Test + integer :: i + end type + + type :: TestReference + class(Test), allocatable :: test(:) + end type +print *, TestReference([Test(99), Test(199)]) ! { dg-error "Data transfer element at .1. cannot have ALLOCATABLE components unless it is processed by a defined input/output procedure" } +end