Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]
gcc/fortran/ChangeLog: PR fortran/105813 * check.cc (gfc_check_unpack): Try to simplify MASK argument to UNPACK so that checking of the VECTOR argument can work when MASK is a variable. gcc/testsuite/ChangeLog: PR fortran/105813 * gfortran.dg/unpack_vector_1.f90: New test.
This commit is contained in:
parent
5cd0e80019
commit
f21f17f95c
2 changed files with 14 additions and 0 deletions
|
@ -6353,6 +6353,8 @@ gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field)
|
|||
if (!same_type_check (vector, 0, field, 2))
|
||||
return false;
|
||||
|
||||
gfc_simplify_expr (mask, 0);
|
||||
|
||||
if (mask->expr_type == EXPR_ARRAY
|
||||
&& gfc_array_size (vector, &vector_size))
|
||||
{
|
||||
|
|
12
gcc/testsuite/gfortran.dg/unpack_vector_1.f90
Normal file
12
gcc/testsuite/gfortran.dg/unpack_vector_1.f90
Normal file
|
@ -0,0 +1,12 @@
|
|||
! { dg-do compile }
|
||||
! PR fortran/105813
|
||||
! Fix checking of VECTOR argument to UNPACK when MASK is a variable.
|
||||
! Contributed by G.Steinmetz
|
||||
|
||||
program p
|
||||
logical, parameter :: mask(2,2) = reshape ([.true., .true., &
|
||||
.false., .true.], &
|
||||
shape (mask))
|
||||
print *, unpack ([1,2,3], mask, 0) ! OK
|
||||
print *, unpack ([1,2], mask, 0) ! { dg-error "must provide at least" }
|
||||
end
|
Loading…
Add table
Reference in a new issue