aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_type_42.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/select_type_42.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/select_type_42.f9026
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/select_type_42.f90 b/gcc/testsuite/gfortran.dg/select_type_42.f90
new file mode 100644
index 00000000000..ff73e6c7858
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/select_type_42.f90
@@ -0,0 +1,26 @@
+! { dg-do run }
+!
+! Tests the fix for PR82275.
+! Associating a name with a reduced-dimension section of a
+! multidimensional array precluded subsequent use of the name
+! with the appropriately reduced dimensionality and instead
+! required use of the (invalid) full set of original dimensions.
+!
+! Contributed by Damian Rouson <damian@sourceryinstitute.org>
+!
+ type component
+ integer :: i
+ end type
+ type container
+ class(component), allocatable :: component_array(:,:)
+ end type
+ type(container) bag
+ type(component) section_copy
+ allocate(bag%component_array, source = reshape ([component(10), component (100)], [1,2]))
+ select type(associate_name=>bag%component_array(1,:))
+ type is (component)
+ section_copy = associate_name(2) ! gfortran rejected valid
+! section_copy = associate_name(1,1)! gfortran accepted invalid
+ end select
+ if (section_copy%i .ne. 100) stop 1
+end