public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47572] New: [OOP] Invalid: Allocatable polymorphic with init expression.
@ 2011-02-01 14:34 burnus at gcc dot gnu.org
  2011-02-01 15:52 ` [Bug fortran/47572] " janus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-02-01 14:34 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47572

           Summary: [OOP] Invalid: Allocatable polymorphic with init
                    expression.
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: janus@gcc.gnu.org


Found at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/763785b16883ed68

The program looks very odd and surely is wrong; however, gfortran accepts it.

ifort does:
  error #6562: A data initialization-expr is not valid for this object.  [B]

I assume that one checks against the CLASS container and not against the actual
_data object.

"C506 (R503) An initialization shall not appear if object-name is a dummy
argument, a function result, an object in a named common block unless the type
declaration is in a block data program unit, an object in blank common, an
allocatable variable, or an automatic object." (F2008)



program scalarallocation
    type test
        real :: a
    end type
    class (test), allocatable :: b = test(3.4)
    print *,'B', allocated(b)
end program


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/47572] [OOP] Invalid: Allocatable polymorphic with init expression.
  2011-02-01 14:34 [Bug fortran/47572] New: [OOP] Invalid: Allocatable polymorphic with init expression burnus at gcc dot gnu.org
@ 2011-02-01 15:52 ` janus at gcc dot gnu.org
  2011-02-02 13:12 ` janus at gcc dot gnu.org
  2011-02-02 13:13 ` janus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-01 15:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47572

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.02.01 15:52:21
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from janus at gcc dot gnu.org 2011-02-01 15:52:21 UTC ---
The following should be enough to fix it:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c       (revision 169479)
+++ gcc/fortran/resolve.c       (working copy)
@@ -10063,7 +10063,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
   /* Reject illegal initializers.  */
   if (!sym->mark && sym->value)
     {
-      if (sym->attr.allocatable)
+      if (sym->attr.allocatable || (sym->ts.type == BT_CLASS
+                                   && CLASS_DATA (sym)->attr.allocatable))
        gfc_error ("Allocatable '%s' at %L cannot have an initializer",
                   sym->name, &sym->declared_at);
       else if (sym->attr.external)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/47572] [OOP] Invalid: Allocatable polymorphic with init expression.
  2011-02-01 14:34 [Bug fortran/47572] New: [OOP] Invalid: Allocatable polymorphic with init expression burnus at gcc dot gnu.org
  2011-02-01 15:52 ` [Bug fortran/47572] " janus at gcc dot gnu.org
@ 2011-02-02 13:12 ` janus at gcc dot gnu.org
  2011-02-02 13:13 ` janus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-02 13:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47572

--- Comment #2 from janus at gcc dot gnu.org 2011-02-02 13:11:54 UTC ---
Author: janus
Date: Wed Feb  2 13:11:50 2011
New Revision: 169520

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169520
Log:
2011-02-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/47572
    * resolve.c (resolve_fl_variable): Handle polymorphic allocatables.


2011-02-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/47572
    * gfortran.dg/class_36.f03: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_36.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/47572] [OOP] Invalid: Allocatable polymorphic with init expression.
  2011-02-01 14:34 [Bug fortran/47572] New: [OOP] Invalid: Allocatable polymorphic with init expression burnus at gcc dot gnu.org
  2011-02-01 15:52 ` [Bug fortran/47572] " janus at gcc dot gnu.org
  2011-02-02 13:12 ` janus at gcc dot gnu.org
@ 2011-02-02 13:13 ` janus at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: janus at gcc dot gnu.org @ 2011-02-02 13:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47572

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from janus at gcc dot gnu.org 2011-02-02 13:12:56 UTC ---
Fixed with r169520. Closing.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-02 13:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-01 14:34 [Bug fortran/47572] New: [OOP] Invalid: Allocatable polymorphic with init expression burnus at gcc dot gnu.org
2011-02-01 15:52 ` [Bug fortran/47572] " janus at gcc dot gnu.org
2011-02-02 13:12 ` janus at gcc dot gnu.org
2011-02-02 13:13 ` janus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).