From: Janus Weil Date: Wed, 14 Feb 2018 21:46:59 +0000 (+0100) Subject: re PR fortran/84385 ([F03] Reject invalid SELECT TYPE selector (allocate_with_source_... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee3bb1b7a2f73c9ccc99b0861e8a3408d408ca2d;p=gcc.git re PR fortran/84385 ([F03] Reject invalid SELECT TYPE selector (allocate_with_source_22.f03)) 2018-02-14 Janus Weil PR fortran/84385 * match.c (gfc_match_select_type): Fix check for selector in SELECT TYPE statement. 2018-02-14 Janus Weil PR fortran/84385 * gfortran.dg/allocate_with_source_22.f03: Fix invalid test case. * gfortran.dg/allocate_with_source_23.f90: Ditto. * gfortran.dg/select_type_1.f03: Extend test case. From-SVN: r257673 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 01e2a906443..ed91bf79b52 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-14 Janus Weil + + PR fortran/84385 + * match.c (gfc_match_select_type): Fix check for selector in + SELECT TYPE statement. + 2018-02-13 Janus Weil PR fortran/84313 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 9313f435ffb..8f3a027c209 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -6201,9 +6201,10 @@ gfc_match_select_type (void) || CLASS_DATA (expr1)->attr.codimension) && expr1->ref && expr1->ref->type == REF_ARRAY + && expr1->ref->u.ar.type == AR_FULL && expr1->ref->next == NULL); - /* Check for F03:C811. */ + /* Check for F03:C811 (F08:C835). */ if (!expr2 && (expr1->expr_type != EXPR_VARIABLE || (!class_array && expr1->ref != NULL))) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c7df80c57e9..e3d1cec40f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-02-14 Janus Weil + + PR fortran/84385 + * gfortran.dg/allocate_with_source_22.f03: Fix invalid test case. + * gfortran.dg/allocate_with_source_23.f90: Ditto. + * gfortran.dg/select_type_1.f03: Extend test case. + 2017-02-14 Uros Bizjak * gcc.target/i386/pr57193.c (dg-do): Remove target selector. diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_22.f03 b/gcc/testsuite/gfortran.dg/allocate_with_source_22.f03 index b8689f95a54..babda71a325 100644 --- a/gcc/testsuite/gfortran.dg/allocate_with_source_22.f03 +++ b/gcc/testsuite/gfortran.dg/allocate_with_source_22.f03 @@ -27,7 +27,7 @@ subroutine test_class() ! with -fcheck=bounds. if (size(b) /= 4) call abort() if (any(b(1:2)%i /= [ 1,2])) call abort() - select type (b(1)) + select type (b1 => b(1)) class is (tt) continue class default diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_23.f03 b/gcc/testsuite/gfortran.dg/allocate_with_source_23.f03 index cfe8bd80e2f..51ea0c627a4 100644 --- a/gcc/testsuite/gfortran.dg/allocate_with_source_23.f03 +++ b/gcc/testsuite/gfortran.dg/allocate_with_source_23.f03 @@ -28,7 +28,7 @@ subroutine test_class_correct() allocate(b(1:4), source=a(1)) if (size(b) /= 4) call abort() if (any(b(:)%i /= [ 1,1,1,1])) call abort() - select type (b(1)) + select type (b1 => b(1)) class is (tt) continue class default @@ -46,7 +46,7 @@ subroutine test_class_fail() allocate(b(1:4), source=a) ! Fail expected: sizes do not conform if (size(b) /= 4) call abort() if (any(b(1:2)%i /= [ 1,2])) call abort() - select type (b(1)) + select type (b1 => b(1)) class is (tt) continue class default diff --git a/gcc/testsuite/gfortran.dg/select_type_1.f03 b/gcc/testsuite/gfortran.dg/select_type_1.f03 index b92366db704..695f75661b8 100644 --- a/gcc/testsuite/gfortran.dg/select_type_1.f03 +++ b/gcc/testsuite/gfortran.dg/select_type_1.f03 @@ -23,6 +23,7 @@ end type class(t1), pointer :: a => NULL() + class(t1), allocatable, dimension(:) :: ca type(t1), target :: b type(t2), target :: c a => b @@ -32,6 +33,7 @@ select type (3.5) ! { dg-error "is not a named variable" } select type (a%cp) ! { dg-error "is not a named variable" } + select type (ca(1))! { dg-error "is not a named variable" } select type (b) ! { dg-error "Selector shall be polymorphic" } end select