summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/host_assoc_function_3.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/host_assoc_function_3.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/host_assoc_function_3.f9027
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/host_assoc_function_3.f90 b/gcc/testsuite/gfortran.dg/host_assoc_function_3.f90
new file mode 100644
index 000000000..a83fa1738
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/host_assoc_function_3.f90
@@ -0,0 +1,27 @@
+! { dg-do run }
+! Tests the fix for the bug PR33233, in which the reference to 'x'
+! in 'inner' wrongly host-associated with the variable 'x' rather
+! than the function.
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+MODULE m
+ REAL :: x(3) = (/ 1.5, 2.5, 3.5 /)
+CONTAINS
+ SUBROUTINE s
+ if (x(2) .eq. 2.5) call abort ()
+ CONTAINS
+ FUNCTION x(n, m)
+ integer, optional :: m
+ if (present(m)) then
+ x = REAL(n)**m
+ else
+ x = 0.0
+ end if
+ END FUNCTION
+ END SUBROUTINE s
+END MODULE m
+ use m
+ call s
+end
+! { dg-final { cleanup-modules "m" } }