public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size
@ 2011-01-18 10:31 burnus at gcc dot gnu.org
  2011-01-18 12:59 ` [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted burnus at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-18 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Fortran 95: Reject namelist objects of non-constant
                    size
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Fortran 95 contains at "5.4 NAMELIST statement":

"Constraint: A namelist-group-object shall not be an array dummy argument with
a nonconstant bound, a variable with nonconstant character length, an automatic
object, a pointer, a variable of a type that has an ultimate component that is
a pointer, or an allocatable array."

However, the following programs is not rejected using "gfortran -std=f95
-pedantic":

subroutine test1(n)
  character(len=n) :: str
  namelist /nml/ str
end subroutine test1

Expected: An error as printed by g95:
  Error: Variable 'str' at (1) cannot have a variable length and be in a
NAMELIST
or as with NAG:
  Error: Namelist-group-object STR is an automatic object
or as with PathScale:
  "STR" is a namelist-group-object, therefore it must not be typed as variable
length character.


Note: In Fortran 2003 (and 2008) the restriction has been lifted and only the
following is left, which is properly diagnosed

C574 (R553) A namelist-group-object shall not be an assumed-size array.


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
@ 2011-01-18 12:59 ` burnus at gcc dot gnu.org
  2011-01-18 13:10 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-18 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Summary|Fortran 95: Reject namelist |Fortran 2003/2008: Valid
                   |objects of non-constant     |NAMELIST rejected; Fortran
                   |size                        |95: Invalid namelist
                   |                            |objects accepted

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-18 12:50:52 UTC ---
The check is currently done at match.c's gfc_match_namelist and at resolve.c's
resolve_fl_namelist.

MISSING (valid F2003, invalid F95):
- sym->ts.u.cl->length && !gfc_is_constant_expr (sym->ts.u.cl->length)
- sym->attr.pointer || sym->attr.allocatable

Seemingly in gfc_match_namelist already covered -- and is thus REJECTS-VALID
for Fortran 2003:
- Non-constant arrays
- Allocatable/pointer components*
+ Handling of polymorphic objects*

*Note: this requires defined I/O, cf. quote below.


Example for rejects valid:
  subroutine test1(n)
    integer:: a(n)
    namelist /nml/ a
  end subroutine test1


 * * *

For completeness: F2008 lists additionally the following in "5.6 NAMELIST
statement":

"A namelist group object shall either be accessed by use or host association or
shall have its type, type parameters, and shape specified by previous
specification statements or the procedure heading in the same scoping unit or
by the implicit typing rules in effect for the scoping unit. If a namelist
group object is typed by the implicit typing rules, its appearance in any
subsequent type declaration statement shall con\frm the implied type and type
parameters."


And in "9.6.4.7 Namelist formatting" [...]:

"Every allocatable namelist-group-object in the namelist group shall be
allocated and every namelist-group-object that is a pointer shall be associated
with a target. If a namelist-group-object is polymorphic or has an ultimate
component that is allocatable or a pointer, that object shall be processed by a
defined input/output procedure (9.6.4.8)."


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
  2011-01-18 12:59 ` [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted burnus at gcc dot gnu.org
@ 2011-01-18 13:10 ` burnus at gcc dot gnu.org
  2011-01-18 13:43 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-18 13:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-18 12:57:20 UTC ---
Related: PR 43062


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
  2011-01-18 12:59 ` [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted burnus at gcc dot gnu.org
  2011-01-18 13:10 ` burnus at gcc dot gnu.org
@ 2011-01-18 13:43 ` burnus at gcc dot gnu.org
  2011-01-22 22:37 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-18 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-18 13:31:48 UTC ---
Created attachment 23018
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23018
Draft patch

Draft patch; handles most of the items - except that ALLOCATABLEs/POINTERs are
still rejected via symbol.c (cf. PR 43062). In order to enable the support, one
needs to fix the ICE mentioned there. The -std=f95 diagnostic is already
included in this patch. -- As are objects which require defined I/O.


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-01-18 13:43 ` burnus at gcc dot gnu.org
@ 2011-01-22 22:37 ` burnus at gcc dot gnu.org
  2011-01-26 10:26 ` burnus at gcc dot gnu.org
  2011-02-02 17:57 ` dnovillo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-22 22:37 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #23018|0                           |1
        is obsolete|                            |

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-22 21:56:04 UTC ---
Created attachment 23080
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23080
Almost ready patch

Updated patch - should be almost ready.

TODO:
- Cleanup comment mess in nml_get_addr_expr
- Add character(len=n)  -std=f95 test case
- Add character run-time test case
- Do full bootstrap & regtesting


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-01-22 22:37 ` burnus at gcc dot gnu.org
@ 2011-01-26 10:26 ` burnus at gcc dot gnu.org
  2011-02-02 17:57 ` dnovillo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-26 10:26 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-26 10:12:51 UTC ---
Author: burnus
Date: Wed Jan 26 10:12:47 2011
New Revision: 169282

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

        PR fortran/47339
        PR fortran/43062
        * match.c (gfc_match_namelist): Allow assumed-length characters.
        * resolve.c (resolve_fl_namelist): Adapt and add error messages.
        * symbol.c (check_conflict): Allow allocatables in NML for
        * F2003.
        * trans-io.c (nml_get_addr_expr,transfer_namelist_element):
        Changes due to that change.

2011-01-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47339
        PR fortran/43062
        * fortran.dg/namelist_69.f90: New test.
        * fortran.dg/namelist_70.f90: New test.
        * fortran.dg/namelist_assumed_char.f90: Modify dg-error, augment
        * test.
        * fortran.dg/namelist_3.f90: Adapt test.
        * fortran.dg/namelist_34.f90: Ditto.
        * fortran.dg/namelist_35.f90: Ditto.
        * fortran.dg/namelist_5.f90: Ditto.
        * fortran.dg/namelist_63.f90: Ditto.
        * gfortran.dg/alloc_comp_constraint_1.f90: Ditto.


Added:
    trunk/gcc/testsuite/gfortran.dg/namelist_69.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_70.f90
Modified:
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_3.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_34.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_35.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_5.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_63.f90
    trunk/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-26 10:13:26 UTC ---
FIXED on the trunk (4.6)


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

* [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted
  2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-01-26 10:26 ` burnus at gcc dot gnu.org
@ 2011-02-02 17:57 ` dnovillo at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dnovillo at gcc dot gnu.org @ 2011-02-02 17:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Diego Novillo <dnovillo at gcc dot gnu.org> 2011-02-02 17:52:20 UTC ---
Author: dnovillo
Date: Wed Feb  2 17:52:14 2011
New Revision: 169614

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

        PR fortran/47339
        PR fortran/43062
        * match.c (gfc_match_namelist): Allow assumed-length characters.
        * resolve.c (resolve_fl_namelist): Adapt and add error messages.
        * symbol.c (check_conflict): Allow allocatables in NML for
        * F2003.
        * trans-io.c (nml_get_addr_expr,transfer_namelist_element):
        Changes due to that change.

2011-01-26  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47339
        PR fortran/43062
        * fortran.dg/namelist_69.f90: New test.
        * fortran.dg/namelist_70.f90: New test.
        * fortran.dg/namelist_assumed_char.f90: Modify dg-error, augment
        * test.
        * fortran.dg/namelist_3.f90: Adapt test.
        * fortran.dg/namelist_34.f90: Ditto.
        * fortran.dg/namelist_35.f90: Ditto.
        * fortran.dg/namelist_5.f90: Ditto.
        * fortran.dg/namelist_63.f90: Ditto.
        * gfortran.dg/alloc_comp_constraint_1.f90: Ditto.

Added:
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_69.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_70.f90
Modified:
    branches/google/integration/gcc/fortran/match.c
    branches/google/integration/gcc/fortran/resolve.c
    branches/google/integration/gcc/fortran/symbol.c
    branches/google/integration/gcc/fortran/trans-io.c
   
branches/google/integration/gcc/testsuite/gfortran.dg/alloc_comp_constraint_1.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_3.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_34.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_35.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_5.f90
    branches/google/integration/gcc/testsuite/gfortran.dg/namelist_63.f90
   
branches/google/integration/gcc/testsuite/gfortran.dg/namelist_assumed_char.f90


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 10:31 [Bug fortran/47339] New: Fortran 95: Reject namelist objects of non-constant size burnus at gcc dot gnu.org
2011-01-18 12:59 ` [Bug fortran/47339] Fortran 2003/2008: Valid NAMELIST rejected; Fortran 95: Invalid namelist objects accepted burnus at gcc dot gnu.org
2011-01-18 13:10 ` burnus at gcc dot gnu.org
2011-01-18 13:43 ` burnus at gcc dot gnu.org
2011-01-22 22:37 ` burnus at gcc dot gnu.org
2011-01-26 10:26 ` burnus at gcc dot gnu.org
2011-02-02 17:57 ` dnovillo 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).