re PR fortran/47085 ([OOP] Problem in allocate( SOURCE=) for polymorphic component)
authorJanus Weil <janus@gcc.gnu.org>
Thu, 30 Dec 2010 11:53:35 +0000 (12:53 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Thu, 30 Dec 2010 11:53:35 +0000 (12:53 +0100)
2010-12-30  Janus Weil  <janus@gcc.gnu.org>

PR fortran/47085
* match.c (gfc_match_allocate): Check for 'class_ok'.
* primary.c (gfc_match_varspec): Ditto.

2010-12-30  Janus Weil  <janus@gcc.gnu.org>

PR fortran/47085
* gfortran.dg/allocate_class_1.f90: New.

From-SVN: r168340

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocate_class_1.f90 [new file with mode: 0644]

index e837b065c33df2630d8806a2bb489bf4bd1e5f8b..d9e91c7dc871a1fad2832b58a9538f3a45f2fac7 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/47085
+       * match.c (gfc_match_allocate): Check for 'class_ok'.
+       * primary.c (gfc_match_varspec): Ditto.
+
 2010-12-29  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        * dump_parse_tree.c (show_components):  Show
index 44da1bb97bd1205064a21cd21551319f11b033c7..a74fdb7fc98d5e7b232394096623a00b10cadb6f 100644 (file)
@@ -2956,7 +2956,7 @@ gfc_match_allocate (void)
       b1 = !(tail->expr->ref
           && (tail->expr->ref->type == REF_COMPONENT
                || tail->expr->ref->type == REF_ARRAY));
-      if (sym && sym->ts.type == BT_CLASS)
+      if (sym && sym->ts.type == BT_CLASS && sym->attr.class_ok)
        b2 = !(CLASS_DATA (sym)->attr.allocatable
               || CLASS_DATA (sym)->attr.class_pointer);
       else
index da028b42df835aa3080174264e14ac411feb579a..ed85398357aaed129cdcb82caa704e6d3d12dad9 100644 (file)
@@ -1774,7 +1774,8 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
          && !gfc_is_proc_ptr_comp (primary, NULL)
          && !(gfc_matching_procptr_assignment
               && sym->attr.flavor == FL_PROCEDURE))
-      || (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->attr.dimension))
+      || (sym->ts.type == BT_CLASS && sym->attr.class_ok
+         && CLASS_DATA (sym)->attr.dimension))
     {
       /* In EQUIVALENCE, we don't know yet whether we are seeing
         an array, character variable or array of character
index 0e5a5b62cf12658e410171f55bdc27472e8ceafb..794175161fece4a7f68a70048dd43529d82b79fd 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-30  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/47085
+       * gfortran.dg/allocate_class_1.f90: New.
+
 2010-12-30  Kai Tietz  <kai.tietz@onevision.com>
 
        PR testsuite/47050
diff --git a/gcc/testsuite/gfortran.dg/allocate_class_1.f90 b/gcc/testsuite/gfortran.dg/allocate_class_1.f90
new file mode 100644 (file)
index 0000000..1dea056
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR 47085: [OOP] Problem in allocate( SOURCE=) for polymorphic component
+!
+! Contributed by Janus Weil <janus@gcc.gnu.org>
+
+ type :: t0
+ end type
+ class(t0) :: x  ! { dg-error "must be dummy, allocatable or pointer" }
+ allocate(x)     ! { dg-error "is not a nonprocedure pointer or an allocatable variable" }
+ end