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

--- Comment #8 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Feb 28, 2024 at 08:24:16PM +0000, sgk at troutmask dot
apl.washington.edu wrote:
> 
> Indeed.  Bit more reading of F2023, 11.1.3 agrees with you.
> 
>    11.1.3.1
> 
>    The ASSOCIATE construct associates named entities with expressions
>    or variables during the execution of its block.  These named construct
>    entities (19.4) are associating entities (19.5.1.6).  The names are
>    associate names.
> 
>    11.1.3.3(5) The associating entity itself is a variable, but ...
> 
> The "but ..." applies to whether the selector is a definable variable.
> 
> So, 'y = x%im' is allowed, but 'x%im = 42' is disallowed because
> the selector is not definable.  Interesting twist.  This then 
> suggests that Jerry's use of parentheses should be accepted.
> 

As a quick follow-up.

program p
   associate(x => sin(cmplx(0.5,0.5)))
      print *, x
      print *, x%im  ! <-- allowed with my patch
      x%im = 42      ! <-- this is an error
      print *, x
   end associate
end

% gfcx -o z a.f90
a.f90:5:6:

    5 |       x%im = 42
      |      1
Error: 'x' at (1) associated to expression cannot be used in
a variable definition context (assignment)

Mikael, thanks for the feedback.  I'll see if I can fix
the parentheses case this weekend.

Reply via email to