This changed between 20190922 and 20190929 : $ cat z1.f90 program p if (f() /= 1) stop associate (y => f) end associate contains integer function f() f = 1 end end $ cat z2.f90 program p interface g procedure s end interface associate (y => g) end associate contains subroutine s end end $ gfortran-10-20190922 -c z1.f90 $ $ gfortran-10-20200119 -c z1.f90 z1.f90:3:0: 3 | associate (y => f) | internal compiler error: tree check: expected class 'expression', have 'declaration' (function_decl) in tree_operand_check, at tree.h:3776 0x611182 tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../gcc/tree.c:9735 0x76b189 expr_check(tree_node*, char const*, int, char const*) ../../gcc/tree.h:3447 0x76b189 tree_operand_check(tree_node*, int, char const*, int, char const*) ../../gcc/tree.h:3776 0x76b189 gfc_get_class_from_expr(tree_node*) ../../gcc/fortran/trans-expr.c:484 0x7c6ca2 trans_associate_var ../../gcc/fortran/trans-stmt.c:2100 0x7cd539 gfc_trans_block_construct(gfc_code*) ../../gcc/fortran/trans-stmt.c:2283 0x72f3f7 trans_code ../../gcc/fortran/trans.c:1960 0x76678d gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6823 0x6e0546 translate_all_program_units ../../gcc/fortran/parse.c:6302 0x6e0546 gfc_parse_file() ../../gcc/fortran/parse.c:6541 0x72b6ef gfc_be_parse_file ../../gcc/fortran/f95-lang.c:210
A related case : $ cat z3.f90 program p type t integer :: a end type type(t) :: z z = t(1) associate (y => t) end associate end
Confirmed, started with r10-3456-g56b070e3bbc4364f86357d6651fe1391464db6d6.
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>: https://gcc.gnu.org/g:a76ff304f905db9fd9b049c2ca4ec84f0420da53 commit r10-7412-ga76ff304f905db9fd9b049c2ca4ec84f0420da53 Author: Tobias Burnus <tobias@codesourcery.com> Date: Fri Mar 27 10:56:25 2020 +0100 Fortran] Reject invalid association target (PR93363) PR fortran/93363 * resolve.c (resolve_assoc_var): Reject association to DT and function name. PR fortran/93363 * gfortran.dg/associate_51.f90: Fix test case. * gfortran.dg/associate_53.f90: New.
FIXED for GCC 10. Thanks for the testcase!