From ce2ab24c22e3bc5a8a2993ef7de3fea3db7d4309 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Mon, 14 Feb 2011 19:12:55 +0100 Subject: [PATCH] re PR fortran/47728 ([OOP] ICE on invalid CLASS declaration) 2011-02-14 Janus Weil PR fortran/47728 * class.c (gfc_build_class_symbol): Give a fatal error on polymorphic arrays. * primary.c (gfc_match_varspec): Avoid ICE for invalid class declaration. 2011-02-14 Janus Weil PR fortran/47728 * gfortran.dg/class_38.f03: New. From-SVN: r170144 --- gcc/fortran/ChangeLog | 8 ++++++++ gcc/fortran/class.c | 2 +- gcc/fortran/primary.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/class_38.f03 | 22 ++++++++++++++++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/class_38.f03 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9bf2eb0af0f..db0069ea4e6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2011-02-14 Janus Weil + + PR fortran/47728 + * class.c (gfc_build_class_symbol): Give a fatal error on polymorphic + arrays. + * primary.c (gfc_match_varspec): Avoid ICE for invalid class + declaration. + 2011-02-14 Janus Weil PR fortran/47349 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 7c8babef7e3..67f19f7f694 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -186,7 +186,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, if (*as) { - gfc_error ("Polymorphic array at %C not yet supported"); + gfc_fatal_error ("Polymorphic array at %C not yet supported"); return FAILURE; } diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 360176edfdb..b673e0b4927 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1770,8 +1770,8 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, if ((equiv_flag && gfc_peek_ascii_char () == '(') || gfc_peek_ascii_char () == '[' || sym->attr.codimension - || (sym->attr.dimension && !sym->attr.proc_pointer - && !gfc_is_proc_ptr_comp (primary, NULL) + || (sym->attr.dimension && sym->ts.type != BT_CLASS + && !sym->attr.proc_pointer && !gfc_is_proc_ptr_comp (primary, NULL) && !(gfc_matching_procptr_assignment && sym->attr.flavor == FL_PROCEDURE)) || (sym->ts.type == BT_CLASS && sym->attr.class_ok diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 823ca7d6624..82e8ba34c01 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-02-14 Janus Weil + + PR fortran/47728 + * gfortran.dg/class_38.f03: New. + 2011-02-14 Eric Botcazou * gcc.dg/pr46494.c: New test. diff --git a/gcc/testsuite/gfortran.dg/class_38.f03 b/gcc/testsuite/gfortran.dg/class_38.f03 new file mode 100644 index 00000000000..2793627924e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_38.f03 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR 47728: [OOP] ICE on invalid CLASS declaration +! +! Contributed by Arjen Markus + +program test_objects + + implicit none + + type, abstract :: shape + end type + + type, extends(shape) :: rectangle + real :: width, height + end type + + class(shape), dimension(2) :: object ! { dg-error "must be dummy, allocatable or pointer" } + + object(1) = rectangle( 1.0, 2.0 ) ! { dg-error "Unclassifiable statement" } + +end program test_objects -- 2.30.2