This patch adds a new option for the new Flang driver: `-fno-analyzed-objects-for-unparse`. The semantics are similar to `-funparse-typed-exprs-to-f18-fc` from `f18`. For consistency, the latter is replaced with `-fno-analyzed-objects-for-unparse`. The new option controls the behaviour of the unparser (i.e. the action corresponding to `-fdebug-unparse`). The default behaviour is to use the analyzed objects when unparsing. The new flag can be used to turn this off, so that the original parse-tree objects are used. The analyzed objects are generated during the semantic checks [1]. This patch also updates the semantics of `-fno-analyzed-objects-for-unparse`/`-funparse-typed-exprs-to-f18-fc` in `f18`, so that this flag is always taken into account when `Unparse` is used (this way the semantics in `f18` and `flang-new` are identical). The added test file is based on example from Peter Steinfeld. [1] https://github.com/llvm/llvm-project/blob/main/flang/docs/Semantics.md Differential Revision: https://reviews.llvm.org/D103612
32 lines
1.0 KiB
Fortran
32 lines
1.0 KiB
Fortran
! Tests `-fno-analyzed-exprs-as-fortran` frontend option
|
|
|
|
!--------------------------
|
|
! RUN lines
|
|
!--------------------------
|
|
! RUN: %flang_fc1 -fdebug-unparse %s | FileCheck %s --check-prefix=DEFAULT
|
|
! RUN: %flang_fc1 -fdebug-unparse -fno-analyzed-objects-for-unparse %s | FileCheck %s --check-prefix=DISABLED
|
|
|
|
!------------------------------------------------
|
|
! EXPECTED OUTPUT: default - use analyzed objects
|
|
!------------------------------------------------
|
|
! DEFAULT: PROGRAM test
|
|
! DEFAULT-NEXT: REAL, PARAMETER :: val = 3.43e2_4
|
|
! DEFAULT-NEXT: PRINT *, 3.47e2_4
|
|
! DEFAULT-NEXT: END PROGRAM
|
|
|
|
!-----------------------------------------------------------
|
|
! EXPECTED OUTPUT: disabled - don't use the analyzed objects
|
|
!-----------------------------------------------------------
|
|
! DISABLED: PROGRAM test
|
|
! DISABLED-NEXT: REAL, PARAMETER :: val = 343.0
|
|
! DISABLED-NEXT: PRINT *, val+4
|
|
! DISABLED-NEXT: END PROGRAM
|
|
|
|
!--------------------------
|
|
! INPUT
|
|
!--------------------------
|
|
program test
|
|
real, parameter :: val = 343.0
|
|
print *, val + 4
|
|
end program
|