From 09dbccba61a6d917b236fcd68041215ae45fa340 Mon Sep 17 00:00:00 2001 From: janus Date: Mon, 14 Feb 2011 18:12:55 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170144 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 9bf2eb0..db0069e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,13 @@ 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 * interface.c (get_expr_storage_size): Handle derived-type components. diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index 7c8babe..67f19f7 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 360176e..b673e0b 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 823ca7d..82e8ba3 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 0000000..2793627 --- /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.7.4