OSDN Git Service

2010-11-10 Tobias Burnus <burnus@net-b.de>
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Nov 2010 17:44:58 +0000 (17:44 +0000)
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Nov 2010 17:44:58 +0000 (17:44 +0000)
        PR fortran/46244
        * resolve.c (resolve_fl_derived): Don't allow CLASS in
        sequence/BIND(C) types.

2010-11-10  Tobias Burnus <burnus@net-b.de>

        PR fortran/46244
        * gfortran.dg/class_30.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166547 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_30.f90 [new file with mode: 0644]

index e2af57f..d0b003d 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-10  Tobias Burnus <burnus@net-b.de>
+
+       PR fortran/46244
+       * resolve.c (resolve_fl_derived): Don't allow CLASS in
+       sequence/BIND(C) types.
+
 2010-11-09  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
            Mikael Morin   <mikael@gcc.gnu.org>
 
index f18d28c..2c9d6f6 100644 (file)
@@ -11491,6 +11491,13 @@ resolve_fl_derived (gfc_symbol *sym)
                             sym->name, &sym->declared_at) == FAILURE)
        return FAILURE;
 
+      if ((sym->attr.sequence || sym->attr.is_bind_c) && c->ts.type == BT_CLASS)
+       {
+         gfc_error ("Polymorphic component %s at %L in SEQUENCE or BIND(C) "
+                    "type %s", c->name, &c->loc, sym->name);
+         return FAILURE;
+       }
+
       if (sym->attr.sequence)
        {
          if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.sequence == 0)
index f560f4b..dfb3abc 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-10  Tobias Burnus <burnus@net-b.de>
+
+       PR fortran/46244
+       * gfortran.dg/class_30.f90: New.
+
 2010-11-10  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/46223
diff --git a/gcc/testsuite/gfortran.dg/class_30.f90 b/gcc/testsuite/gfortran.dg/class_30.f90
new file mode 100644 (file)
index 0000000..f81e614
--- /dev/null
@@ -0,0 +1,19 @@
+! { dg-do compile }
+!
+! PR fortran/46244 (comments 7 to 9)
+!
+! gfortran accepted CLASS in bind(C) and SEQUENCE types
+!
+type :: t
+  integer :: i
+end type t
+
+type t2
+  sequence
+  class(t), pointer :: x ! { dg-error "Polymorphic component x at .1. in SEQUENCE or BIND" }
+end type t2
+
+type, bind(C):: t3
+  class(t), pointer :: y ! { dg-error "may not be C interoperable|Polymorphic component y at .1. in SEQUENCE or BIND" }
+end type t3
+end