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][preprocessor] C preprocessor can not be inside of statement #95476

Closed
foxtran opened this issue Jun 13, 2024 · 3 comments · Fixed by #96244
Closed

[flang][preprocessor] C preprocessor can not be inside of statement #95476

foxtran opened this issue Jun 13, 2024 · 3 comments · Fixed by #96244
Assignees

Comments

@foxtran
Copy link
Member

foxtran commented Jun 13, 2024

With the following example,

! example
subroutine test( &
ARG1, &
! test
#ifndef SWAP
#define ARG1 FA
#define ARG2 FB
#else
#define ARG1 FB
#define ARG2 FA
#endif
ARG1, ARG2, &
! test
#undef ARG1
#undef ARG2
&ARG2)
! comment
end

flang-new fails with the following errors:

error: Could not scan test.f90
./test.f90:2:16: error: Unmatched '('
  subroutine test( &
                 ^
./test.f90:12:13: error: bad character ('&') in Fortran token
  ARG1, ARG2, &
              ^
./test.f90:16:1: error: bad character ('&') in Fortran token
  &ARG2)
  ^
./test.f90:16:6: error: Unmatched ')'
  &ARG2)
       ^

Used version (after applying #95332, #93382):

$ flang-new --version
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 41587739a63f7622c36715421d215f07d79f9a7d)
@github-actions github-actions bot added the flang Flang issues not falling into any other category label Jun 13, 2024
@foxtran foxtran changed the title [flang] C preprocessor can not be inside of statement [flang][preprocessor] C preprocessor can not be inside of statement Jun 13, 2024
@EugeneZelenko EugeneZelenko added flang:frontend and removed flang Flang issues not falling into any other category labels Jun 13, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 13, 2024

@llvm/issue-subscribers-flang-frontend

Author: None (foxtran)

With the following example, ``` ! example subroutine test( & ARG1, & ! test #ifndef SWAP #define ARG1 FA #define ARG2 FB #else #define ARG1 FB #define ARG2 FA #endif ARG1, ARG2, & ! test #undef ARG1 #undef ARG2 &ARG2) ! comment end ``` flang-new fails with the following errors: ``` error: Could not scan test.f90 ./test.f90:2:16: error: Unmatched '(' subroutine test( & ^ ./test.f90:12:13: error: bad character ('&') in Fortran token ARG1, ARG2, & ^ ./test.f90:16:1: error: bad character ('&') in Fortran token &ARG2) ^ ./test.f90:16:6: error: Unmatched ')' &ARG2) ^ ```

Used version (after applying #95332, #93382):

$ flang-new --version
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 41587739a63f7622c36715421d215f07d79f9a7d)

@klausler
Copy link
Contributor

Is this output from -E close enough to what you want?

#line "./t.F90" 2
      subroutine test(ARG1,FA, FB,ARG2)
#line 18
      end

klausler added a commit to klausler/llvm-project that referenced this issue Jun 20, 2024
…ne continuation

Allow preprocessing directives to appear between a source line and
its continuation, including conditional compilation directives
(#if, #ifdef, &c.).

Fixes llvm#95476.
@klausler
Copy link
Contributor

#96244

klausler added a commit to klausler/llvm-project that referenced this issue Jun 22, 2024
…ne continuation

Allow preprocessing directives to appear between a source line and
its continuation, including conditional compilation directives
(#if, #ifdef, &c.).

Fixes llvm#95476.
klausler added a commit to klausler/llvm-project that referenced this issue Jun 23, 2024
…ne continuation

Allow preprocessing directives to appear between a source line and
its continuation, including conditional compilation directives
(#if, #ifdef, &c.).

Fixes llvm#95476.
klausler added a commit that referenced this issue Jun 24, 2024
#96244)

…ne continuation

Allow preprocessing directives to appear between a source line and its
continuation, including conditional compilation directives (#if, #ifdef,
&c.).

Fixes #95476.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this issue Jul 9, 2024
llvm#96244)

…ne continuation

Allow preprocessing directives to appear between a source line and its
continuation, including conditional compilation directives (#if, #ifdef,
&c.).

Fixes llvm#95476.
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