public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/32985]  New: Derived type variables need SEQUENCE attribute to be in a COMMON
@ 2007-08-04 13:05 burnus at gcc dot gnu dot org
  2007-08-04 13:17 ` [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE burnus at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-04 13:05 UTC (permalink / raw)
  To: gcc-bugs

"C589 (R558) If a common-block-object is of a derived type, it shall be a
sequence type (4.5.1) or a type with the BIND attribute and it shall have no
default initialization."

A default initializer is also accepted.

Testcase based on the invalid gfortran.dg/namelist_14.f90:

!{ dg-do compile }
module global
  type             ::  mt
    integer        ::  ii(4)
  end type mt
end module global

program namelist_14
  use global
  common /myc/ cdt
  type(mt)         ::  cdt
end program namelist_14

! { dg-final { cleanup-modules "global" } }


-- 
           Summary: Derived type variables need SEQUENCE attribute to be in
                    a COMMON
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
@ 2007-08-04 13:17 ` burnus at gcc dot gnu dot org
  2007-08-04 13:18 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-04 13:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-08-04 13:17 -------
Interestingly, the following gives an error:

  type a
    integer :: i
  end type a
  type(a) :: t
  common /c/ t
end


Related, the following is accepted but invalid (for different reasons):

"C588 (R558) A common-block-object shall not be a dummy argument, an
allocatable variable, a derived-type object with an ultimate component that is
allocatable, an automatic object, a function name, an entry name, a variable
with the BIND attribute, or a result name."

  type a
    sequence
    integer,allocatable :: i(:)
  end type a
  type(a) :: t
  common /c/ t
end

NAG f95 writes:
T has an allocatable component - cannot occur in COMMON
ifort:
Error: Variables containing ultimate allocatable array components cannot appear
in COMMON or EQUIVALENCE statements.   [T]
openf95/sunf95:
  "T" is of a derived type that has an ultimate component that is allocatable,
therefore it must not be a named constant or a variable in common.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Summary|Derived type variables need |COMMON checking: TYPE
                   |SEQUENCE attribute to be in |with(out) SEQUENCE/bind(C),
                   |a COMMON                    |ALLOCATABLE


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
  2007-08-04 13:17 ` [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE burnus at gcc dot gnu dot org
@ 2007-08-04 13:18 ` burnus at gcc dot gnu dot org
  2007-08-06 19:23 ` burnus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-04 13:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-08-04 13:18 -------
And the following valid program is rejected:

  use iso_c_binding
  implicit none
  type, bind(C):: a
    integer(c_int) :: i
  end type a
  type(a) :: t
  common /c/ t
end


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
  2007-08-04 13:17 ` [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE burnus at gcc dot gnu dot org
  2007-08-04 13:18 ` burnus at gcc dot gnu dot org
@ 2007-08-06 19:23 ` burnus at gcc dot gnu dot org
  2007-08-06 20:18 ` burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-06 19:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from burnus at gcc dot gnu dot org  2007-08-06 19:23 -------
Patch for the first part. Missing: Check for default initializer.

Index: resolve.c
===================================================================
--- resolve.c   (revision 127246)
+++ resolve.c   (working copy)
@@ -610 +610 @@ resolve_common_blocks (gfc_symtree *comm
-   gfc_symbol *sym;
+   gfc_symbol *sym, *csym;
@@ -618,0 +619,14 @@ resolve_common_blocks (gfc_symtree *comm
+        for (csym = symtree->n.common->head; csym; csym = csym->common_next)
+         {
+               printf("DEBUG '%s' - derived=%s?\n",csym->name, csym->ts.type
== BT_DERIVED?"yes":"no");
+           /* Derived type names must have the SEQUENCE attribute.  */
+           if (csym->ts.type == BT_DERIVED
+               && !(csym->ts.derived->attr.sequence
+                    || csym->ts.derived->attr.is_bind_c))
+             {
+               gfc_error ("Derived type variable '%s' in COMMON at %L has "
+                          "neither the SEQUENCE nor the BIND(C) attribute",
+                      csym->name, &csym->declared_at);
+             }
+         }
+
Index: match.c
===================================================================
--- match.c     (revision 127246)
+++ match.c     (working copy)
@@ -2635,8 +2634,0 @@ gfc_match_common (void)
-         /* Derived type names must have the SEQUENCE attribute.  */
-         if (sym->ts.type == BT_DERIVED && !sym->ts.derived->attr.sequence)
-           {
-             gfc_error ("Derived type variable in COMMON at %C does not "
-                        "have the SEQUENCE attribute");
-             goto cleanup;
-           }
-


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-08-06 19:23 ` burnus at gcc dot gnu dot org
@ 2007-08-06 20:18 ` burnus at gcc dot gnu dot org
  2007-08-08 15:09 ` fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-06 20:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-08-06 20:18 -------
Besides default initializers (TODO), I also forgot about the following, to be
added after the if clause of previous patch:
            else if (csym->ts.type == BT_DERIVED
                     && csym->ts.derived->attr.alloc_comp)
              {
                gfc_error ("Derived type variable '%s' at %L in COMMON has "
                           "an ultimate component that is allocatable",
                           csym->name, &csym->declared_at);
              }


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-08-06 20:18 ` burnus at gcc dot gnu dot org
@ 2007-08-08 15:09 ` fxcoudert at gcc dot gnu dot org
  2007-08-20 19:10 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-08 15:09 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-08-08 15:09:28
               date|                            |


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-08-08 15:09 ` fxcoudert at gcc dot gnu dot org
@ 2007-08-20 19:10 ` patchapp at dberlin dot org
  2007-08-26 18:30 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: patchapp at dberlin dot org @ 2007-08-20 19:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from patchapp at dberlin dot org  2007-08-20 19:10 -------
Subject: Bug number PR32985

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg01299.html


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-08-20 19:10 ` patchapp at dberlin dot org
@ 2007-08-26 18:30 ` burnus at gcc dot gnu dot org
  2007-08-26 18:34 ` burnus at gcc dot gnu dot org
  2007-08-26 18:39 ` burnus at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-26 18:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2007-08-26 18:29 -------
Subject: Bug 32985

Author: burnus
Date: Sun Aug 26 18:29:45 2007
New Revision: 127811

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127811
Log:
2007-08-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/32985
        * match.c (gfc_match_common): Remove SEQUENCE diagnostics.
        * resolve.c (resolve_common_blocks): Add SEQUENCE diagnostics;
        fix walking through the tree.

2007-08-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/32985
        * gfortran.dg/namelist_14.f90: Make test case valid.
        * gfortran.dg/common_10.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/common_10.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/namelist_14.f90


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-08-26 18:30 ` burnus at gcc dot gnu dot org
@ 2007-08-26 18:34 ` burnus at gcc dot gnu dot org
  2007-08-26 18:39 ` burnus at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-26 18:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from burnus at gcc dot gnu dot org  2007-08-26 18:34 -------
Partially fixed. The remaining bits (default initializer) are tracked in
PR33198.


-- 


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


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

* [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE
  2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-08-26 18:34 ` burnus at gcc dot gnu dot org
@ 2007-08-26 18:39 ` burnus at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-26 18:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from burnus at gcc dot gnu dot org  2007-08-26 18:39 -------
Mark as fixed.


-- 

burnus at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-08-26 18:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-04 13:05 [Bug fortran/32985] New: Derived type variables need SEQUENCE attribute to be in a COMMON burnus at gcc dot gnu dot org
2007-08-04 13:17 ` [Bug fortran/32985] COMMON checking: TYPE with(out) SEQUENCE/bind(C), ALLOCATABLE burnus at gcc dot gnu dot org
2007-08-04 13:18 ` burnus at gcc dot gnu dot org
2007-08-06 19:23 ` burnus at gcc dot gnu dot org
2007-08-06 20:18 ` burnus at gcc dot gnu dot org
2007-08-08 15:09 ` fxcoudert at gcc dot gnu dot org
2007-08-20 19:10 ` patchapp at dberlin dot org
2007-08-26 18:30 ` burnus at gcc dot gnu dot org
2007-08-26 18:34 ` burnus at gcc dot gnu dot org
2007-08-26 18:39 ` burnus at gcc dot gnu dot 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).