[flang] Do not ICE on out-of-range data statement designator

Print error message instead of assert trigger.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D123132
This commit is contained in:
Mike Kashkarov 2022-04-05 17:09:43 +03:00
parent d2bcb0a129
commit ba038a3080
2 changed files with 6 additions and 1 deletions

View File

@ -298,7 +298,9 @@ static std::optional<DataRef> OffsetToDataRef(FoldingContext &context,
// Reconstructs a Designator from a symbol, an offset, and a size.
std::optional<Expr<SomeType>> OffsetToDesignator(FoldingContext &context,
const Symbol &baseSymbol, ConstantSubscript offset, std::size_t size) {
CHECK(offset >= 0);
if (offset < 0) {
return std::nullopt;
}
if (std::optional<DataRef> dataRef{
OffsetToDataRef(context, NamedEntity{baseSymbol}, offset, size)}) {
const Symbol &symbol{dataRef->GetLastSymbol()};

View File

@ -28,6 +28,9 @@ subroutine s1
integer :: a4(3)
!ERROR: DATA statement designator 'a4(5_8)' is out of range
data (a4(j),j=1,5,2) /3*222/
integer :: a5(3)
!ERROR: DATA statement designator 'a5(-2_8)' is out of range
data a5(-2) / 1 /
interface
real function rfunc(x)
real, intent(in) :: x