mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fortran: Suppress bogus used uninitialized warnings [PR108889].
2024-07-18 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/108889 * gfortran.h: Add bit field 'allocated_in_scope' to gfc_symbol. * trans-array.cc (gfc_array_allocate): Set 'allocated_in_scope' after allocation if not a component reference. (gfc_alloc_allocatable_for_assignment): If 'allocated_in_scope' not set, not a component ref and not allocated, set the array bounds and offset to give zero length in all dimensions. Then set allocated_in_scope. gcc/testsuite/ PR fortran/108889 * gfortran.dg/pr108889.f90: New test.
- Loading branch information
Paul Thomas
committed
Jul 18, 2024
1 parent
cee56fe
commit c3aa339
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
! { dg-do compile } | ||
! { dg-options "-Wall -fdump-tree-original" } | ||
! | ||
! Contributed by Tobias Burnus <burnus@gcc.gnu.org> | ||
! | ||
program main | ||
implicit none | ||
|
||
type :: struct | ||
real, allocatable :: var(:) | ||
end type struct | ||
|
||
type(struct) :: single | ||
real, allocatable :: ref1(:), ref2(:), ref3(:), ref4(:) | ||
|
||
ref2 = [1,2,3,4,5] ! Warnings here | ||
|
||
single%var = ref2 ! No warnings for components | ||
ref1 = single%var ! Warnings here | ||
ref1 = [1,2,3,4,5] ! Should not add to tree dump count | ||
|
||
allocate (ref3(5)) | ||
ref3 = single%var ! No warnings following allocation | ||
|
||
call set_ref4 | ||
|
||
call test (ref1) | ||
call test (ref2) | ||
call test (ref3) | ||
call test (ref4) | ||
|
||
contains | ||
subroutine test (arg) | ||
real, allocatable :: arg(:) | ||
if (size(arg) /= size(single%var)) stop 1 | ||
if (lbound(arg, 1) /= 1) stop 2 | ||
if (any (arg /= single%var)) stop 3 | ||
end | ||
subroutine set_ref4 | ||
ref4 = single%var ! Warnings in contained scope | ||
end | ||
end | ||
! { df-final { scan-tree-dump-times "ubound = 0" 3 "original" } } |