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

[flang] renamed specific shadowed by generic cause error when reading module files #83836

Closed
jeanPerier opened this issue Mar 4, 2024 · 3 comments · Fixed by #83915
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior flang:frontend

Comments

@jeanPerier
Copy link
Contributor

Reproducer:

modules.f90 :

module mod0
    interface proc
      module procedure  proc
    end interface
contains
  subroutine proc(n)
    print *, n
  end subroutine
end module
module mod1
  use mod0,renamed_proc=>proc
  procedure(renamed_proc),pointer :: p
end module

main.f90 :

  use mod1
  p => renamed_proc
  call p(343)
end program
flang-new -c modules.f90
flang-new -c main.f90

Bogus error:

error: Semantic errors in main.f90
./main.f90:2:3: error: 'proc' is not a procedure
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./main.f90:2:3: error: In assignment to object pointer 'p', the target 'proc' is a procedure designator
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./mod1.mod:5:26: Declaration of 'p'
  procedure(proc),pointer::p
                           ^
./main.f90:3:3: error: 'proc' is not a procedure
    call p(343)
    ^^^^^^^^^^^
./mod1.mod:5:11: error: 'proc' must be an abstract interface or a procedure with an explicit interface
  procedure(proc),pointer::p

This test is derived from discussions in #81544 and was not fixed by #82837.

@jeanPerier jeanPerier added bug Indicates an unexpected problem or unintended behavior flang:semantics labels Mar 4, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 4, 2024

@llvm/issue-subscribers-bug

Author: None (jeanPerier)

Reproducer:

modules.f90 :

module mod0
    interface proc
      module procedure  proc
    end interface
contains
  subroutine proc(n)
    print *, n
  end subroutine
end module
module mod1
  use mod0,renamed_proc=>proc
  procedure(renamed_proc),pointer :: p
end module

main.f90 :

  use mod1
  p => renamed_proc
  call p(343)
end program
flang-new -c modules.f90
flang-new -c main.f90

Bogus error:

error: Semantic errors in main.f90
./main.f90:2:3: error: 'proc' is not a procedure
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./main.f90:2:3: error: In assignment to object pointer 'p', the target 'proc' is a procedure designator
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./mod1.mod:5:26: Declaration of 'p'
  procedure(proc),pointer::p
                           ^
./main.f90:3:3: error: 'proc' is not a procedure
    call p(343)
    ^^^^^^^^^^^
./mod1.mod:5:11: error: 'proc' must be an abstract interface or a procedure with an explicit interface
  procedure(proc),pointer::p

This test is derived from discussions in #81544 and was not fixed by #82837.

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 4, 2024

@llvm/issue-subscribers-flang-frontend

Author: None (jeanPerier)

Reproducer:

modules.f90 :

module mod0
    interface proc
      module procedure  proc
    end interface
contains
  subroutine proc(n)
    print *, n
  end subroutine
end module
module mod1
  use mod0,renamed_proc=>proc
  procedure(renamed_proc),pointer :: p
end module

main.f90 :

  use mod1
  p => renamed_proc
  call p(343)
end program
flang-new -c modules.f90
flang-new -c main.f90

Bogus error:

error: Semantic errors in main.f90
./main.f90:2:3: error: 'proc' is not a procedure
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./main.f90:2:3: error: In assignment to object pointer 'p', the target 'proc' is a procedure designator
    p => renamed_proc
    ^^^^^^^^^^^^^^^^^
./mod1.mod:5:26: Declaration of 'p'
  procedure(proc),pointer::p
                           ^
./main.f90:3:3: error: 'proc' is not a procedure
    call p(343)
    ^^^^^^^^^^^
./mod1.mod:5:11: error: 'proc' must be an abstract interface or a procedure with an explicit interface
  procedure(proc),pointer::p

This test is derived from discussions in #81544 and was not fixed by #82837.

@klausler klausler self-assigned this Mar 4, 2024
klausler added a commit to klausler/llvm-project that referenced this issue Mar 4, 2024
Save both the raw procedure interface symbol as well as the result
of passing it through GetUltimate() and BypassGeneric() in symbol
table entries with ProcEntityDetails.  The raw symbol of the interface
needs to be the one used for emitting procedure symbols to module
files.

Fixes llvm#83836.
@klausler
Copy link
Contributor

klausler commented Mar 4, 2024

#83915

klausler added a commit to klausler/llvm-project that referenced this issue Mar 4, 2024
Save both the raw procedure interface symbol as well as the result
of passing it through GetUltimate() and BypassGeneric() in symbol
table entries with ProcEntityDetails.  The raw symbol of the interface
needs to be the one used for emitting procedure symbols to module
files.

Fixes llvm#83836.
klausler added a commit that referenced this issue Mar 5, 2024
Save both the raw procedure interface symbol as well as the result of
passing it through GetUltimate() and BypassGeneric() in symbol table
entries with ProcEntityDetails. The raw symbol of the interface needs to
be the one used for emitting procedure symbols to module files.

Fixes #83836.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior flang:frontend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants