Skip to content

[Flang] Preprocessor error when the name to be replaced contains trailing blank in a continuation line #106931

@ohno-fj

Description

@ohno-fj
Version of flang-new : 20.0.0(675c748bb606d75a959481e6014299849cf3094c)/AArch64

When building elpa, the preprocessor does not work correctly.
When the name to be replaced contains trailing blank in a continuation line, the preprocessor does not replace that name correctly.
When it does not contain blank, the name is replaced correctly.

The following are the test program, Flang-new compilation result.

test.F90:

#define PRECISION 8
subroutine foo_&
&PRECISION &
&(a,b)
  real(kind=8) :: a, b
  a = a + b
end subroutine foo_&
&PRECISION
$ flang-new -c -cpp test.F90
error: Semantic errors in test.F90
./test.F90:7:16: error: SUBROUTINE name mismatch
  end subroutine foo_&
                 ^
./test.F90:2:12: should be
  subroutine foo_&
             ^
$
$ flang-new -c -cpp -save-temps test.F90
error: Semantic errors in test.i
./test.F90:7:22: error: SUBROUTINE name mismatch
        end subroutine foo_8
                       ^^^^^
./test.F90:2:18: should be
        subroutine foo_PRECISION(a,b)
                   ^^^^^^^^^^^^^
$
$ cat test.i
#line "./test.F90" 2
      subroutine foo_PRECISION(a,b)


      real(kind=8) :: a, b
      a = a + b
      end subroutine foo_8
$

test2.F90:

#define PRECISION 8
subroutine foo_&
&PRECISION&
&(a,b)
!&PRECISION &
!&(a,b)
  real(kind=8) :: a, b
  a = a + b
end subroutine foo_&
&PRECISION
$ flang-new -c -cpp test2.F90
$

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions