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] (Semantic check?) Incorrect error message when using the same name in interfaces and external statements #56605

Closed
UsmanNadeem opened this issue Jul 19, 2022 · 3 comments
Assignees

Comments

@UsmanNadeem
Copy link
Contributor

UsmanNadeem commented Jul 19, 2022

The standard states:

Only one appearance of a name in all of the EXTERNAL statements in a scoping unit is permitted. A name that
appears in an EXTERNAL statement must not also appear as a specific procedure name in an interface block in
the scoping unit.

I was testing a piece of code (from NumPy) that works fine on Gfortran but did not compile with Flang. I have put a small test case here.
Consider the following two functions where we violate this constraint:

function foo1()
    external bar1

    interface
        function bar1(value) result (r)
            integer, intent(in) :: value
        end function bar1
    end interface
end function foo1

function foo2(bar2)
    external bar2

    interface
        function bar2(value) result (r)
            integer, intent(in) :: value
        end function bar2
    end interface
end function foo2

On flang the errors dont make much sense:

error: Semantic errors in /app/example.f90
/app/example.f90:5:18: error: 'bar1' was previously called as a subroutine
          function bar1(value) result (r)
                   ^^^^
/app/example.f90:2:14: Previous call of 'bar1'
      external bar1
               ^^^^
/app/example.f90:15:18: error: 'bar2' is already declared in this scoping unit
          function bar2(value) result (r)
                   ^^^^
/app/example.f90:11:15: Previous declaration of 'bar2'
  function foo2(bar2)
                ^^^^
Compiler returned: 1

Surprisingly, Gfortran is successfully able to compile the second file but we get an appropriate error Error: Duplicate EXTERNAL attribute specified for the first file: https://godbolt.org/z/oKq14a9Kz

Would it be possible to change the error message to something appropriate? Doing so will make debugging much easier.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 19, 2022

@llvm/issue-subscribers-flang-frontend

@pscoro
Copy link
Contributor

pscoro commented Jan 6, 2023

@UsmanNadeem Could I get this issue assigned to me? Thanks

@UsmanNadeem UsmanNadeem assigned UsmanNadeem and pscoro and unassigned UsmanNadeem Jan 6, 2023
pscoro added a commit that referenced this issue Feb 7, 2023
…rnal statements and interfaces

For issue: #56605. Previous error messages are not descriptive of problem. Issuing warnings instead that do not halt compilation but offer better description of problem.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D143426
CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Feb 8, 2023
…rnal statements and interfaces

For issue: llvm/llvm-project#56605. Previous error messages are not descriptive of problem. Issuing warnings instead that do not halt compilation but offer better description of problem.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D143426
@pscoro
Copy link
Contributor

pscoro commented Feb 8, 2023

Complete and landed

@pscoro pscoro closed this as completed Feb 8, 2023
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Aug 9, 2024
…rnal statements and interfaces

For issue: llvm/llvm-project#56605. Previous error messages are not descriptive of problem. Issuing warnings instead that do not halt compilation but offer better description of problem.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D143426
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Aug 15, 2024
…rnal statements and interfaces

For issue: llvm/llvm-project#56605. Previous error messages are not descriptive of problem. Issuing warnings instead that do not halt compilation but offer better description of problem.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D143426
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

3 participants