Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flang/lib/Semantics/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3700,7 +3700,10 @@ static MaybeExpr NumericUnaryHelper(ExpressionAnalyzer &context,
analyzer.CheckForNullPointer();
analyzer.CheckForAssumedRank();
if (opr == NumericOperator::Add) {
return analyzer.MoveExpr(0);
// +x -> (x), not a bare x, because the bounds of the argument must
// not be exposed to allocatable assignments or structure constructor
// components.
return Parenthesize(analyzer.MoveExpr(0));
} else {
return Negation(context.GetContextualMessages(), analyzer.MoveExpr(0));
}
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Evaluate/bug157379.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
program main
type t
integer, allocatable :: ia(:)
end type
type(t) x
integer, allocatable :: ja(:)
allocate(ja(2:2))
ja(2) = 2
!CHECK: x=t(ia=(ja))
x = t(+ja) ! must be t(ia=(ja)), not t(ia=ja)
print *, lbound(x%ia) ! must be 1, not 2
end