When blank tokens arise from macro replacement in token sequences with
token pasting (##), the preprocessor is producing some bogus tokens
(e.g., "name(") that can lead to subtle bugs later when macro names are
not recognized as such.
The fix is to not paste tokens together when the result would not be a
valid Fortran or C token in the preprocessing context.
21 lines
603 B
Fortran
21 lines
603 B
Fortran
! RUN: %flang -E %s 2>&1 | FileCheck %s
|
|
#define STRINGIFY(x) #x
|
|
#define TOSTRING(x) STRINGIFY(x)
|
|
#define PREFIX(x) prefix ## x
|
|
#define NAME(x) PREFIX(foo ## x)
|
|
#define AUGMENT(x) NAME(x ## suffix)
|
|
|
|
! CHECK: subroutine prefixfoosuffix()
|
|
! CHECK: print *, "prefixfoosuffix"
|
|
! CHECK: end subroutine prefixfoosuffix
|
|
subroutine AUGMENT()()
|
|
print *, TOSTRING(AUGMENT())
|
|
end subroutine AUGMENT()
|
|
|
|
! CHECK: subroutine prefixfoobarsuffix()
|
|
! CHECK: print *, "prefixfoobarsuffix"
|
|
! CHECK: end subroutine prefixfoobarsuffix
|
|
subroutine AUGMENT(bar)()
|
|
print *, TOSTRING(AUGMENT(bar))
|
|
end subroutine AUGMENT(bar)
|