llvm-capstone/flang/test/Driver/dump-all-bad.f90
Andrzej Warzynski 6f8ef1d6e8 [flang][driver] Add actions that execute despite semantic errors
This patch adds a new abstract class for frontend actions:
`PrescanAndSemaDebugAction`. It's almost identical to
`PrescanAndSemaAction`, but in the presence of semantic errors it does
not skip the corresponding `ExecuteAction` specialisation. Instead, it
runs it as if there were no semantic errors. This class is for developer
actions only (i.e.  front-end driver options).

The new behaviour does not affect the return code from `flang-new -fc1`
when the input file is semantically incorrect. The return code is
inferred from the number of driver diagnostics generated in
`CompilerInstance::ExecuteAction` and this patch does not change that.
More specifically, the semantic errors are still reported and hence the
driver is able to correctly report that the compilation has failed (with
a non-zero return code).

This new base class is meant for debug actions only and
`DebugDumpAllAction` is updated to demonstrate the new behaviour. With
this change, `flang-new -fc1 -fdebug-dump-all` dumps the parse tree and
symbols for all input files, regardless of whether any semantic errors
were found.

This patch addresses https://bugs.llvm.org/show_bug.cgi?id=52097.

Differential Revision: https://reviews.llvm.org/D111308
2021-10-11 11:52:05 +00:00

22 lines
476 B
Fortran

! Verify that -fdebug-dump-all dumps both symbols and the parse tree, even when semantic errors are present
!----------
! RUN lines
!----------
! RUN: not %flang_fc1 -fdebug-dump-all %s 2>&1 | FileCheck %s
!----------------
! EXPECTED OUTPUT
!----------------
! CHECK: error: Semantic errors in
! CHECK: Flang: parse tree dump
! CHECK: Flang: symbols dump
!-------
! INPUT
!-------
program bad
real,pointer :: x
x = null() ! Error - must be pointer assignment
end