Message ID | trinity-9a6ab73b-c336-4435-8d44-df7cae72045a-1626205677017@3c-app-gmx-bap01 |
---|---|
State | New |
Headers | show |
Series | PR fortran/100949 - [9/10/11/12 Regression] ICE in gfc_conv_expr_present, at fortran/trans-expr.c:1975 | expand |
Hi Harald, > we rather shouldn't consider a presence check for a non-dummy variable. > > Regtested on x86_64-pc-linux-gnu. OK for all affected branches? OK for all. Thanks for the patch! Best regards Thomas
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index de406ad2e8f..9e0dcdefd25 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1741,8 +1741,9 @@ gfc_trans_class_init_assign (gfc_code *code) } } - if (code->expr1->symtree->n.sym->attr.optional - || code->expr1->symtree->n.sym->ns->proc_name->attr.entry_master) + if (code->expr1->symtree->n.sym->attr.dummy + && (code->expr1->symtree->n.sym->attr.optional + || code->expr1->symtree->n.sym->ns->proc_name->attr.entry_master)) { tree present = gfc_conv_expr_present (code->expr1->symtree->n.sym); tmp = build3_loc (input_location, COND_EXPR, TREE_TYPE (tmp), diff --git a/gcc/testsuite/gfortran.dg/pr100949.f90 b/gcc/testsuite/gfortran.dg/pr100949.f90 new file mode 100644 index 00000000000..6c736fd7f72 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr100949.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/100949 - ICE in gfc_conv_expr_present, at fortran/trans-expr.c:1975 + +subroutine s +entry f + type t + end type + class(t), allocatable :: y, z + allocate (z, mold=y) +end