Bug 45369 - problem with the associate statement
Summary: problem with the associate statement
Status: RESOLVED DUPLICATE of bug 38936
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-21 16:38 UTC by Norman S. Clerman
Modified: 2010-08-21 16:58 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
code that allow the bug to be reproduced (2.70 KB, text/plain)
2010-08-21 16:40 UTC, Norman S. Clerman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Norman S. Clerman 2010-08-21 16:38:56 UTC
I will upload a file, type_bound_demoP.f90. When I compile it, I see the following messages:

type_bound_demoP.f90:187.8:

        associate (pt1 => point_1%pt2d_t, pt2 => point_2%pt2d_t)
        1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:188.10:

          x_dist = pt1 % Get (X_COORD) - pt2 % Get (X_COORD)
          1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:189.10:

          y_dist = pt1 % Get (Y_COORD) - pt2 % Get (Y_COORD)
          1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:191.11:

        end associate
           1
Error: Expecting END SELECT statement at (1)
type_bound_demoP.f90:216.8:

        associate (pt2d => this % pt2d_t)
        1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:217.16:

          return_value = pt2d % Get (mold)
                1
Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE
type_bound_demoP.f90:218.11:

        end associate
           1
Error: Expecting END SELECT statement at (1)
type_bound_demoP.f90:233.4:

    associate (point_2d => this % pt2d_t)
    1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:234.12:

      return_value = point_2d % Get ()
            1
Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE
type_bound_demoP.f90:235.7:

    end associate
       1
Error: Expecting END FUNCTION statement at (1)
type_bound_demoP.f90:248.6:

      associate (point_2d => this % pt2d_t)
      1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:249.21:

        call point_2d % Print ()
                     1
Error: Syntax error in CALL statement at (1)
type_bound_demoP.f90:250.9:

      end associate
         1
Error: Expecting END SELECT statement at (1)
type_bound_demoP.f90:269.6:

      associate (point_2d => this % pt2d_t)
      1
Error: Unclassifiable statement at (1)
type_bound_demoP.f90:273.21:

        call point_2d % Set (coordinates)
                     1
Error: Syntax error in CALL statement at (1)
type_bound_demoP.f90:287.9:

      end associate
         1
Error: Expecting END SELECT statement at (1)
type_bound_demoP.f90:297.29:

  use Pt3d_mod, only : pt3d_t
                             1
Fatal Error: Can't open module file 'pt3d_mod.mod' for reading at (1): No such file or directory

I am using the following compiler flags:

/usr/gcc-trunk/bin/gfortran $1.f90 -Wall -Wextra -O3 -ffast-math -funroll-loops -std=f2003 -fno-backslash >&$1.gfortran_trunk
.xyz


This appears to be a problem with the associate statement. According to your documentation, there is some support for it in the latest version of the compiler. This will perhaps assist in completing support for it

Norm

Norman S. Clerman
Comment 1 Norman S. Clerman 2010-08-21 16:40:01 UTC
Created attachment 21538 [details]
code that allow the bug to be reproduced
Comment 2 Daniel Kraft 2010-08-21 16:57:19 UTC
I only get a limited set of errors:

test.f03:188.10:

          x_dist = pt1 % Get (X_COORD) - pt2 % Get (X_COORD)
          1
Error: Unclassifiable statement at (1)
test.f03:189.10:

          y_dist = pt1 % Get (Y_COORD) - pt2 % Get (Y_COORD)
          1
Error: Unclassifiable statement at (1)
test.f03:217.16:

          return_value = pt2d % Get (mold)
                1
Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE
test.f03:234.12:

      return_value = point_2d % Get ()
            1
Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE
test.f03:249.21:

        call point_2d % Print ()
                     1
Error: VARIABLE attribute of 'point_2d' conflicts with PROCEDURE attribute at (1
)
test.f03:273.21:

        call point_2d % Set (coordinates)
                     1
Error: VARIABLE attribute of 'point_2d' conflicts with PROCEDURE attribute at (1
)
test.f03:297.29:

  use Pt3d_mod, only : pt3d_t
                             1
Fatal Error: Can't open module file 'pt3d_mod.mod' for reading at (1): No such f
ile or directory



These are currently expected, because the parser does not know pt1 or pt2 are derived-types and thus rejects a component-reference on them.  This is what I meant with the statement, that ASSOCIATE is not yet completely working for derived-types, see PR 38936.

*** This bug has been marked as a duplicate of 38936 ***
Comment 3 Daniel Kraft 2010-08-21 16:58:03 UTC
Thanks for the test-case, I'll check against it when this will be implemented.
Comment 4 Norman S. Clerman 2010-08-21 21:35:52 UTC
Subject: Re:  problem with the associate statement


Thank you very much. I use the associate construct a great deal; it can really clarify your code.

Norm

---- domob at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> wrote: 

=============


------- Comment #3 from domob at gcc dot gnu dot org  2010-08-21 16:58 -------
Thanks for the test-case, I'll check against it when this will be implemented.