diff options
| author | Mingming Liu <mingmingl@google.com> | 2025-09-10 15:25:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-10 15:25:31 -0700 |
| commit | 1417dafa1db9cb1b2b09438aa9f53ea5ab6e36e2 (patch) | |
| tree | 57f4b1f313c8cf74eed8819870f39c36ea263c68 /flang/lib/Semantics/expression.cpp | |
| parent | 898b813bc8a6d0276bf0f4769f5f2f64b34e632d (diff) | |
| parent | b8cefcb601ddaa18482555c4ff363c01a270c2fe (diff) | |
Merge branch 'main' into users/mingmingl-llvm/samplefdo-profile-formatusers/mingmingl-llvm/samplefdo-profile-format
Diffstat (limited to 'flang/lib/Semantics/expression.cpp')
| -rw-r--r-- | flang/lib/Semantics/expression.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index d022378ce145..3f048ab6f7a4 100644 --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -2198,7 +2198,8 @@ MaybeExpr ExpressionAnalyzer::CheckStructureConstructor( } if (symbol) { const semantics::Scope &innermost{context_.FindScope(exprSource)}; - if (auto msg{CheckAccessibleSymbol(innermost, *symbol)}) { + if (auto msg{CheckAccessibleSymbol( + innermost, *symbol, /*inStructureConstructor=*/true)}) { Say(exprSource, std::move(*msg)); } if (checkConflicts) { @@ -3699,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)); } @@ -3783,10 +3787,9 @@ MaybeExpr NumericBinaryHelper( analyzer.CheckForNullPointer(); analyzer.CheckForAssumedRank(); analyzer.CheckConformance(); - constexpr bool canBeUnsigned{opr != NumericOperator::Power}; - return NumericOperation<OPR, canBeUnsigned>( - context.GetContextualMessages(), analyzer.MoveExpr(0), - analyzer.MoveExpr(1), context.GetDefaultKind(TypeCategory::Real)); + return NumericOperation<OPR>(context.GetContextualMessages(), + analyzer.MoveExpr(0), analyzer.MoveExpr(1), + context.GetDefaultKind(TypeCategory::Real)); } else { return analyzer.TryDefinedOp(AsFortran(opr), "Operands of %s must be numeric; have %s and %s"_err_en_US); @@ -4632,7 +4635,7 @@ bool ArgumentAnalyzer::CheckForNullPointer(const char *where) { bool ArgumentAnalyzer::CheckForAssumedRank(const char *where) { for (const std::optional<ActualArgument> &arg : actuals_) { - if (arg && IsAssumedRank(arg->UnwrapExpr())) { + if (arg && semantics::IsAssumedRank(arg->UnwrapExpr())) { context_.Say(source_, "An assumed-rank dummy argument is not allowed %s"_err_en_US, where); fatalErrors_ = true; |
