[flang] Finer control over error recovery with GetExpr()
authorPeter Klausler <pklausler@nvidia.com>
Fri, 15 Apr 2022 20:23:16 +0000 (13:23 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Fri, 15 Apr 2022 21:25:41 +0000 (14:25 -0700)
commit7e225423d39ae1982e9380a4a0836888ab6b3bd8
tree8d446965234ce50541867df97042a0cc14b4d007
parent64c045e25b8471bbb572bd29159c294a82a86a25
[flang] Finer control over error recovery with GetExpr()

Prior to this patch, the semantics utility GetExpr() will crash
unconditionally if it encounters a typed expression in the parse
tree that has not been set by expression semantics.  This is the
right behavior when called from lowering, by which time it is known
that the program had no fatal user errors, since it signifies a
fatal internal error.  However, prior to lowering, in the statement
semantics checking code, a more nuanced test should be used before
crashing -- specifically, we should not crash in the face of a
missing typed expression when in error recovery mode.

Getting this right requires GetExpr() and its helper class to have
access to the semantics context, so that it can check AnyFatalErrors()
before crashing.  So this patch touches nearly all of its call sites.

Differential Revision: https://reviews.llvm.org/D123873
16 files changed:
flang/include/flang/Semantics/tools.h
flang/lib/Semantics/assignment.cpp
flang/lib/Semantics/check-allocate.cpp
flang/lib/Semantics/check-arithmeticif.cpp
flang/lib/Semantics/check-case.cpp
flang/lib/Semantics/check-coarray.cpp
flang/lib/Semantics/check-deallocate.cpp
flang/lib/Semantics/check-do-forall.cpp
flang/lib/Semantics/check-io.cpp
flang/lib/Semantics/check-io.h
flang/lib/Semantics/check-nullify.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-stop.cpp
flang/lib/Semantics/data-to-inits.cpp
flang/lib/Semantics/resolve-directives.cpp
flang/lib/Semantics/tools.cpp