2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
gcc/fortran/ChangeLog: PR fortran/96727 * expr.c (gfc_check_init_expr): Add default error message for the AS_ASSUMED_RANK case. gcc/testsuite/ChangeLog: PR fortran/96727 * gfortran.dg/PR96727.f90: New test.
This commit is contained in:
parent
8f7d99acf6
commit
3a7a95a220
2 changed files with 40 additions and 0 deletions
|
@ -3007,6 +3007,12 @@ gfc_check_init_expr (gfc_expr *e)
|
|||
e->symtree->n.sym->name, &e->where);
|
||||
break;
|
||||
|
||||
case AS_ASSUMED_RANK:
|
||||
gfc_error ("Assumed-rank array %qs at %L is not permitted "
|
||||
"in an initialization expression",
|
||||
e->symtree->n.sym->name, &e->where);
|
||||
break;
|
||||
|
||||
default:
|
||||
gcc_unreachable();
|
||||
}
|
||||
|
|
34
gcc/testsuite/gfortran.dg/PR96727.f90
Normal file
34
gcc/testsuite/gfortran.dg/PR96727.f90
Normal file
|
@ -0,0 +1,34 @@
|
|||
! { dg-do run }
|
||||
!
|
||||
! Test the fix for PR96727
|
||||
!
|
||||
|
||||
program cref_p
|
||||
|
||||
implicit none
|
||||
|
||||
integer :: i
|
||||
|
||||
integer, parameter :: n = 3
|
||||
integer, parameter :: p(*) = [(i, i=1,n*n)]
|
||||
character(len=*), parameter :: q = repeat('a', n*n)
|
||||
|
||||
integer :: a(n,n)
|
||||
character(len=n*n) :: c
|
||||
|
||||
a = reshape(p, shape=[n,n])
|
||||
call csub(a, c)
|
||||
if (c/=q) stop 1
|
||||
stop
|
||||
|
||||
contains
|
||||
|
||||
subroutine csub(a, b)
|
||||
integer, intent(in) :: a(..)
|
||||
character(len=size(a)), intent(out) :: b
|
||||
|
||||
b = repeat('a', len(b))
|
||||
return
|
||||
end subroutine csub
|
||||
|
||||
end program cref_p
|
Loading…
Add table
Reference in a new issue