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] legacy extension of kind selector does not work properly #78927

Closed
foxtran opened this issue Jan 22, 2024 · 4 comments · Fixed by #79029
Closed

[flang] legacy extension of kind selector does not work properly #78927

foxtran opened this issue Jan 22, 2024 · 4 comments · Fixed by #79029
Assignees

Comments

@foxtran
Copy link
Member

foxtran commented Jan 22, 2024

In the following example (test.f):

      subroutine test(r8heap, i8heap, scrsize)
      integer*4 i8heap(*)
      real*8 r8heap(scrsize)
      end

flang says:

$ flang-new test.f
error: Could not scan test.f
./test.f:3:28: error: Unmatched ')'
        real*8 r8heap(scrsize)
                             ^

I had similar issues with integer*4 i8heap(*) but I could not reproduce it. I suppose it has the same reason like with real*8 r8heap(scrsize).

Used version:

bin/flang-new --version
flang-new version 18.0.0git (https://github.com/llvm/llvm-project.git 5518a9d7673bfe55b4110bea049140316d032fbf)
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Jan 22, 2024
@EugeneZelenko EugeneZelenko added flang:frontend and removed flang Flang issues not falling into any other category labels Jan 22, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 22, 2024

@llvm/issue-subscribers-flang-frontend

Author: None (foxtran)

In the following example (`test.f`): ```fortran subroutine test(r8heap, i8heap, scrsize) integer*4 i8heap(*) real*8 r8heap(scrsize) end ``` flang says: ``` $ flang-new test.f error: Could not scan test.f ./test.f:3:28: error: Unmatched ')' real*8 r8heap(scrsize) ^ ```

I had similar issues with integer*4 i8heap(*) but I could not reproduce it. I suppose it has the same reason like with real*8 r8heap(scrsize).

Used version:

bin/flang-new --version
flang-new version 18.0.0git (https://github.com/llvm/llvm-project.git 5518a9d7673bfe55b4110bea049140316d032fbf)

@klausler
Copy link
Contributor

The 8H is probably being mistaken for the beginning of a Hollerith literal.

@klausler klausler self-assigned this Jan 22, 2024
klausler added a commit to klausler/llvm-project that referenced this issue Jan 22, 2024
llvm#78927 contains a case
of fixed-form source in which a Hollerith literal is mistakenly
tokenized, leading to grief later due to apparently unbalanced
parentheses.

The source looks like "REAL*8 R8HEAP(SCRSIZE)" and the Hollerith
literal is misrecognized as such because it follows "8R".  In order
to properly tokenize Hollerith literals in old comma-free FORMAT
statements like "1 FORMAT(3I5HFLANG)", the tokenizer in the prescanner
treats a letter after an integer token ("3I") as a special case.
The fix is to do this only when the characters involved are nested
in parentheses and Hollerith is a possibility.

Fixes llvm#78927.
@klausler
Copy link
Contributor

#79029

klausler added a commit that referenced this issue Jan 26, 2024
#78927 contains a case of
fixed-form source in which a Hollerith literal is mistakenly tokenized,
leading to grief later due to apparently unbalanced parentheses.

The source looks like "REAL*8 R8HEAP(SCRSIZE)" and the Hollerith literal
is misrecognized as such because it follows "8R". In order to properly
tokenize Hollerith literals in old comma-free FORMAT statements like "1
FORMAT(3I5HFLANG)", the tokenizer in the prescanner treats a letter
after an integer token ("3I") as a special case. The fix is to do this
only when the characters involved are nested in parentheses and
Hollerith is a possibility.

Fixes #78927.
@klausler
Copy link
Contributor

Fix has been merged into llvm-project/main.

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

Successfully merging a pull request may close this issue.

4 participants