Skip to content

Commit

Permalink
[flang] Do not ICE on out-of-range data statement designator
Browse files Browse the repository at this point in the history
Print error message instead of assert trigger.

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D123132
  • Loading branch information
FruitClover committed Apr 14, 2022
1 parent d2bcb0a commit ba038a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion flang/lib/Evaluate/fold-designator.cpp
Expand Up @@ -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()};
Expand Down
3 changes: 3 additions & 0 deletions flang/test/Semantics/data06.f90
Expand Up @@ -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
Expand Down

0 comments on commit ba038a3

Please sign in to comment.