Bug 93363 - [10 Regression] ICE in gfc_get_class_from_expr, at fortran/trans-expr.c:484
Summary: [10 Regression] ICE in gfc_get_class_from_expr, at fortran/trans-expr.c:484
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 10.0
: P4 normal
Target Milestone: 10.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2020-01-21 17:34 UTC by G. Steinmetz
Modified: 2020-03-27 10:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.2.0
Known to fail: 10.0
Last reconfirmed: 2020-01-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2020-01-21 17:34:13 UTC
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
Comment 1 G. Steinmetz 2020-01-21 17:34:54 UTC
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
Comment 2 Martin Liška 2020-01-22 08:52:03 UTC
Confirmed, started with r10-3456-g56b070e3bbc4364f86357d6651fe1391464db6d6.
Comment 3 GCC Commits 2020-03-27 09:57:47 UTC
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.
Comment 4 Tobias Burnus 2020-03-27 10:07:50 UTC
FIXED for GCC 10. Thanks for the testcase!