public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/64678] Expected association error on dependent associate statements
Date: Tue, 20 Jan 2015 01:45:00 -0000	[thread overview]
Message-ID: <bug-64678-4-8SmrwDyJFf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-64678-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64678

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Antony Lewis from comment #0)
> In trunk
> 
> module X
>   Type T
>    integer :: map
>   end Type T
> contains
> 
> subroutine DoBug
> Type(T) TT
>   
>  associate(A=>TT, B=>A%map)
>  end associate
>   
> end subroutine
> end module X
> 
> gives:
> 
> testbug.f90:10:17:
> 
>   associate(A=>TT, B=>A%map)
>                  1
> Error: Expected association at (1)
> testbug.f90:11:4:
> 
>   end associate
>     1
> 
> It's not entirely clear to me from the standard if this is allowed, but I
> don't see why not (useful when you are breaking up complicated array/class
> structures into associate names, where the second name refers to the first).
> It compiles in ifort. Obviously low priority as can be worked around easily
> enough

I believe gfortran is correct in issuing an error; although I admit
it seems to be a subtle distinction in language.  For F2003 standard

  8.1.4  ASSOCIATE construct

  The ASSOCIATE construct associates named entities with expressions
  or variables during the execution of its block. These named construct
  entities (16.3) are associating entities (16.4.1.5).  The names are
  associate names.

The BNF shows

  R818   association   is   associate-name => selector
  R819   selector      is   expr
                       or   variable


In your code, 'A' and 'B' are associate-names.  The target
of an associate-name is a selector, which is an expr or variable.
The target for 'B' is 'A%map'.  So, the question becomes whether 'A%map'
is now a variable or expression even though 'A' is an associate-name.

The BNF for 'variable is

  R601 variable                  is designator
  C601 (R601) designator shall not be a constant or a subobject of a constant.
  R602 variable-name             is  name
  C602 (R602) A variable-name shall be the name of a variable.
  R603 designator                is object-name
                                 or array-element
                                 or array-section
                                 or structure-component
                                 or substring

  R505 object-name     is   name
  C505 (R505) The object-name shall be the name of a data object.

  A data object (often abbreviated to object) is a constant (4.1.2),
  a variable (6), or a subobject of a constant. The type and type
  parameters of a named data object may be specified explicitly (5.1)
  or implicitly (5.3).

'A%map' as a data object is certainly not a constant or subobject of
a constant, so it must be a variable.  But, we've already established
that 'A' is an associate-name not a variable-name.  So, 'A%map' is
not an object-name.

array-element, array-section, and substring are of no consequence here.

So, now, structure-component

  R614 structure-component is data-ref

  R612 data-ref is part-ref [ % part-ref ] ...
  R613 part-ref is part-name [ ( section-subscript-list ) ]

  C612 (R612) The leftmost part-name shall be the name of a data object.

We've already established 'A' is not a data object.  So, now we
are left with 'expr'.  I have no interest in reproducing Section 7
of Fortran 2003 standard.  I suspect you'll find that 'A%map' is not
an 'expr'.

Note, I could be wrong.  You may want to post to comp.lang.fortran.
There are numerous people, who contribute to c.l.f, that are much
more in-tune with the nuances of the Fortran standard.


  reply	other threads:[~2015-01-20  1:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-20  0:09 [Bug fortran/64678] New: " antony at cosmologist dot info
2015-01-20  1:45 ` kargl at gcc dot gnu.org [this message]
2015-01-20  2:11 ` [Bug fortran/64678] " dominiq at lps dot ens.fr
2015-01-24 12:00 ` antony at cosmologist dot info
2015-01-24 12:15 ` dominiq at lps dot ens.fr
2015-01-24 14:05 ` anlauf at gmx dot de

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-64678-4-8SmrwDyJFf@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).