…INCLUDE lines The compiler current treats an INCLUDE line as essentially a synonym for a preprocessing #include directive. The causes macros that have been defined at the point where the INCLUDE line is processed to be replaced within the text of the included file. This behavior is surprising to users who expect an INCLUDE line to be expanded into its contents *after* preprocessing has been applied to the original source file, with no further macro expansion. Change INCLUDE line processing to use a fresh instance of Preprocessor containing no macro definitions except _CUDA in CUDA Fortran compilations and, if the original file was being preprocessed, the standard definitions of __FILE__, __LINE__, and so forth.
61 lines
2.0 KiB
Fortran
61 lines
2.0 KiB
Fortran
! Ensure argument -I works as expected with an included header.
|
|
|
|
!--------------------------
|
|
! FLANG DRIVER (flang)
|
|
!--------------------------
|
|
! RUN: not %flang -E %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED
|
|
! RUN: %flang -E -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
|
|
! RUN: %flang -E -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
|
|
! RUN: %flang -E -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
|
|
|
|
!----------------------------------------
|
|
! FRONTEND FLANG DRIVER (flang_fc1)
|
|
!----------------------------------------
|
|
! RUN: not %flang_fc1 -E %s 2>&1 | FileCheck %s --check-prefix=UNINCLUDED
|
|
! RUN: %flang_fc1 -E -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
|
|
! RUN: %flang_fc1 -E -I %S/Inputs -I %S/Inputs/header-dir %s 2>&1 | FileCheck %s --check-prefix=MAINDIRECTORY
|
|
! RUN: %flang_fc1 -E -I %S/Inputs/header-dir -I %S/Inputs %s 2>&1 | FileCheck %s --check-prefix=SUBDIRECTORY
|
|
|
|
! UNINCLUDED:#include: Source file 'basic-header-one.h' was not found
|
|
! UNINCLUDED-NOT:program b
|
|
! UNINCLUDED-NOT:program c
|
|
|
|
! SINGLEINCLUDE:program MainDirectoryOne
|
|
! SINGLEINCLUDE-NOT:program X
|
|
! SINGLEINCLUDE-NOT:program B
|
|
! SINGLEINCLUDE:program MainDirectoryTwo
|
|
! SINGLEINCLUDE-NOT:program Y
|
|
! SINGLEINCLUDE-NOT:program C
|
|
|
|
! MAINDIRECTORY:program MainDirectoryOne
|
|
! MAINDIRECTORY-NOT:program SubDirectoryOne
|
|
! MAINDIRECTORY-NOT:program B
|
|
! MAINDIRECTORY:program MainDirectoryTwo
|
|
! MAINDIRECTORY-NOT:program SubDirectoryTwo
|
|
! MAINDIRECTORY-NOT:program C
|
|
|
|
! SUBDIRECTORY:program SubDirectoryOne
|
|
! SUBDIRECTORY-NOT:program MainDirectoryOne
|
|
! SUBDIRECTORY-NOT:program B
|
|
! SUBDIRECTORY:program SubDirectoryTwo
|
|
! SUBDIRECTORY-NOT:program MainDirectoryTwo
|
|
! SUBDIRECTORY-NOT:program C
|
|
|
|
! include-test-one.f90
|
|
#include <basic-header-one.h>
|
|
#ifdef X
|
|
program X
|
|
#else
|
|
program B
|
|
#endif
|
|
end
|
|
|
|
! include-test-two.f90
|
|
#include "basic-header-two.h"
|
|
#ifdef Y
|
|
program Y
|
|
#else
|
|
program C
|
|
#endif
|
|
end
|