Skip to content

[flang] Failed substitution with preprocessor #78797

Closed
@bcornille

Description

@bcornille

Issue:

flang does not substitute a preprocessor variable in a snake case Fortran variable. In order to get substitution some codes use continuation lines so that the preprocessor variable can be inserted in-between underscores in code. flang appears to concatenate continuation lines prior to applying the preprocessor substitutions so the substitution does not occur.

Reproducer:

main.F90

program main
  implicit none
#define LETTER b
  integer, parameter :: a_&
    &LETTER&
    &_c = 1
  write(*,*) a_b_c
end program main

compilation:

>> flang-new -c main.F90
error: Semantic errors in main.F90
./main.F90:8:14: error: No explicit type declared for 'a_b_c'
    write(*,*) a_b_c
               ^^^^^

preprocessed source:

>> flang-new -E main.F90
#line "./main.F90" 1
      program main
      implicit none
      integer, parameter :: a_LETTER_c = 1
      write(*,*) a_b_c
      end program main

GNU behavior:

>> gfortran -E main.F90
# 1 "main.F90"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "main.F90"
program main
  implicit none
  integer, parameter :: a_&
    &b&
    &_c = 1
  write(*,*) a_b_c
end program main

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions