re PR fortran/47728 ([OOP] ICE on invalid CLASS declaration)
authorJanus Weil <janus@gcc.gnu.org>
Mon, 14 Feb 2011 18:12:55 +0000 (19:12 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Mon, 14 Feb 2011 18:12:55 +0000 (19:12 +0100)
2011-02-14  Janus Weil  <janus@gcc.gnu.org>

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  <janus@gcc.gnu.org>

PR fortran/47728
* gfortran.dg/class_38.f03: New.

From-SVN: r170144

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_38.f03 [new file with mode: 0644]

index 9bf2eb0af0f1186d1d9b5f5871ddec9a84b9a48b..db0069ea4e694f9f75c8273b216fe97973e7b155 100644 (file)
@@ -1,3 +1,11 @@
+2011-02-14  Janus Weil  <janus@gcc.gnu.org>
+
+       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  <janus@gcc.gnu.org>
 
        PR fortran/47349
index 7c8babef7e30044957f9e20c50b79c49b6bfb097..67f19f7f6942e68a2ce3c70ef6e617b1a492652d 100644 (file)
@@ -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;
     }
 
index 360176edfdbd1b094d63c7aaf2a4ea034d9d6ea9..b673e0b49273a7fa7f0fcec77f065e1ceaa1ef1a 100644 (file)
@@ -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
index 823ca7d6624b122d1d600c32ce4d7ab7d3774e53..82e8ba34c01870e44101a0450e760dbe5d3e6614 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-14  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/47728
+       * gfortran.dg/class_38.f03: New.
+
 2011-02-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        * 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 (file)
index 0000000..2793627
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+!
+! PR 47728: [OOP] ICE on invalid CLASS declaration
+!
+! Contributed by Arjen Markus <arjen.markus@deltares.nl>
+
+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