[Bug fortran/58857] [OOP] CLASS wrongly rejected in BLOCK DATA

2013-12-14 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58857

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2013-12-14
 CC||janus at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from janus at gcc dot gnu.org ---
The whole idea of using CLASS(*) with BLOCK DATA is rather sick if you ask me
;)

Anyway, here is a draft patch which helps to allow this bestiality (not
regtested):

Index: gcc/fortran/class.c
===
--- gcc/fortran/class.c(revision 205983)
+++ gcc/fortran/class.c(working copy)
@@ -644,7 +644,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_a
   if (!gfc_add_component (fclass, "_vptr", &c))
 return false;
   c->ts.type = BT_DERIVED;
-  if (delayed_vtab
+  if (delayed_vtab || ts->u.derived->attr.unlimited_polymorphic
   || (ts->u.derived->f2k_derived
   && ts->u.derived->f2k_derived->finalizers))
 c->ts.u.derived = NULL;


[Bug fortran/58857] [OOP] CLASS wrongly rejected in BLOCK DATA

2013-10-29 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58857

--- Comment #1 from Tobias Burnus  ---
I tried compiling the code of comment 0 with different compilers. Result:
* Cray ftn simply compiled it.
* Portland Group's pgf90 rejected it with the bogus:
  PGF90-S-0155-Polymorphic variable must be a pointer, allocatable, or dummy
  object -  zz
* Intel accepted it but warns:
  remark #7784: Symbol in BLOCK DATA program unit is not in a COMMON block.[ZZ]

(I think it would be useful to have a similar warning as ifort, but that's a
different issue.)


>From Fortran 2008 (11.3) for BLOCK DATA:

C1116 (R1120) A block-data specification-part shall contain only definitions of
derived-type definitions and ASYNCHRONOUS, BIND, COMMON, DATA, DIMENSION,
EQUIVALENCE, IMPLICIT, INTRINSIC, PARAMETER, POINTER, SAVE, TARGET, USE,
VOLATILE, and type declaration statements.

C1117 (R1120) A type declaration statement in a block-data specification-part
shall not contain ALLOCATABLE, EXTERNAL, or BIND attribute specifiers.