diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/primary.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr103475.f90 | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 28ce5fe..1bea17d 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -2770,7 +2770,7 @@ gfc_expr_attr (gfc_expr *e) { gfc_symbol *sym = e->value.function.esym->result; attr = sym->attr; - if (sym->ts.type == BT_CLASS) + if (sym->ts.type == BT_CLASS && sym->attr.class_ok) { attr.dimension = CLASS_DATA (sym)->attr.dimension; attr.pointer = CLASS_DATA (sym)->attr.class_pointer; diff --git a/gcc/testsuite/gfortran.dg/pr103475.f90 b/gcc/testsuite/gfortran.dg/pr103475.f90 new file mode 100644 index 0000000..6cce5e8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103475.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-O2 -Wall" } +! PR fortran/103475 - ICE in gfc_expr_attr +! Contributed by G.Steinmetz + +program p + type t + end type + class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" } + y = x() ! { dg-error "Cannot convert invalid class" } +end |