Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived type cannot be declared with both PRIVATE and BIND(C) with gfortran #59

Open
clementval opened this issue Jun 22, 2018 · 11 comments

Comments

@clementval
Copy link
Collaborator

clementval commented Jun 22, 2018

The following code is compilable with gfortran but not anymore once passed through the front-end and back-end.

MODULE mod1
  IMPLICIT NONE
  PRIVATE

  TYPE, BIND(c) :: t_rt
    INTEGER :: i
  END TYPE t_rt
END MODULE mod1
MODULE mod1
 TYPE , PRIVATE , BIND( C ) :: t_rt
 END TYPE t_rt
END MODULE mod1
  TYPE , PRIVATE , BIND( C ) :: t_rt
                                   1
Error: Derived type 't_rt' at (1) cannot be declared with both PRIVATE and BIND(C) attributes

This is specified in the Fortran standard at R427

@h-murai
Copy link
Collaborator

h-murai commented Jul 5, 2018

@clementval Do you mean that TYPE , PRIVATE , BIND( C ) :: t_rt should be accepted but gfortran doesn't due to its bug?

@clementval
Copy link
Collaborator Author

clementval commented Jul 5, 2018

@h-murai
TYPE , PRIVATE , BIND( C ) :: t_rt is not accepted by gfortran so the only way to do it is like I did in the PR

PRIVATE :: t_rt
TYPE , BIND( C ) :: t_rt

If you look into the standard is not super clear but R427

R427 type-attr-spec is ABSTRACT
or access-spec
or BIND (C)
or EXTENDS ( parent-type-name )

@h-murai
Copy link
Collaborator

h-murai commented Jul 5, 2018

@clementval Hmm. According to R426:

R426 derived-type-stmt is TYPE [ [ , type-attr-spec-list ] :: ] type-name

a TYPE statement can have multiple type-attr-spec. So, I consider that TYPE , PRIVATE , BIND( C ) :: t_rt should be accepted.

@clementval
Copy link
Collaborator Author

Ok but then this is not compilable with gfortran

@clementval
Copy link
Collaborator Author

@h-murai should try with other compiler to check the behavior

@clementval
Copy link
Collaborator Author

@h-murai I tried with PGI and Cray and both are ok with this. Only gfortran does not like this construct.

@h-murai
Copy link
Collaborator

h-murai commented Jul 5, 2018

@clementval Ok. I understand the situation. Considering that gfortran is important, I agree the PR is a better solution to this issue.

@clementval
Copy link
Collaborator Author

@h-murai I’ll try to fill a bug report for gfortran and see what they reply. So like this it would be only a temporary fix

@clementval clementval changed the title Derived type cannot be declared with both PRIVATE and BIND(C) Derived type cannot be declared with both PRIVATE and BIND(C) with gfortran Jul 18, 2018
@clementval
Copy link
Collaborator Author

@h-murai I made the workaround in the backend at the moment so the XcodeML still reflect the correct standard.
The PR is #71

@clementval
Copy link
Collaborator Author

I filed a but report in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86587

@h-murai h-murai assigned h-murai and unassigned clementval Jul 26, 2018
@h-murai h-murai added Priority: Low and removed Kind: Bug Module: F_Front PR ready Pull Request is ready for this issue Priority: Medium labels Jul 26, 2018
@h-murai
Copy link
Collaborator

h-murai commented Jul 26, 2018

keep this issue as a reminder. The status of the gfortran's limitation should be checked in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants