[flang-commits] [flang] 0b671a4 - [flang][msvc] Fix lambda capture ambiguity. NFC.
Michael Kruse via flang-commits
flang-commits at lists.llvm.org
Fri Oct 23 20:58:51 PDT 2020
Author: Michael Kruse
Date: 2020-10-23T22:58:40-05:00
New Revision: 0b671a44ad2d606647aa14d5782425b39aed9271
URL: https://github.com/llvm/llvm-project/commit/0b671a44ad2d606647aa14d5782425b39aed9271
DIFF: https://github.com/llvm/llvm-project/commit/0b671a44ad2d606647aa14d5782425b39aed9271.diff
LOG: [flang][msvc] Fix lambda capture ambiguity. NFC.
Patch D88695 introduces a new local variable inside a lambda with the same name as a variable outside of it. In some of the if constexpr regions, msvc prioritizes the outer declaration and emits the error.
```
C:\Users\meinersbur\src\llvm-project\flang\lib\Evaluate\fold-implementation.h(1200): error C3493: 'context' cannot be implicitly captured because no default capture mode has been specified
```
This is fixed by giving the inner variable a different name.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D89367
Added:
Modified:
flang/lib/Evaluate/fold-implementation.h
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/fold-implementation.h b/flang/lib/Evaluate/fold-implementation.h
index 49c8beb02854..78df7e7b9312 100644
--- a/flang/lib/Evaluate/fold-implementation.h
+++ b/flang/lib/Evaluate/fold-implementation.h
@@ -1185,12 +1185,12 @@ Expr<TO> FoldOperation(
auto &convert{msvcWorkaround.convert};
char buffer[64];
if (auto value{GetScalarConstantValue<Operand>(kindExpr)}) {
- FoldingContext &context{msvcWorkaround.context};
+ FoldingContext &ctx{msvcWorkaround.context};
if constexpr (TO::category == TypeCategory::Integer) {
if constexpr (Operand::category == TypeCategory::Integer) {
auto converted{Scalar<TO>::ConvertSigned(*value)};
if (converted.overflow) {
- context.messages().Say(
+ ctx.messages().Say(
"INTEGER(%d) to INTEGER(%d) conversion overflowed"_en_US,
Operand::kind, TO::kind);
}
@@ -1198,11 +1198,11 @@ Expr<TO> FoldOperation(
} else if constexpr (Operand::category == TypeCategory::Real) {
auto converted{value->template ToInteger<Scalar<TO>>()};
if (converted.flags.test(RealFlag::InvalidArgument)) {
- context.messages().Say(
+ ctx.messages().Say(
"REAL(%d) to INTEGER(%d) conversion: invalid argument"_en_US,
Operand::kind, TO::kind);
} else if (converted.flags.test(RealFlag::Overflow)) {
- context.messages().Say(
+ ctx.messages().Say(
"REAL(%d) to INTEGER(%d) conversion overflowed"_en_US,
Operand::kind, TO::kind);
}
@@ -1215,7 +1215,7 @@ Expr<TO> FoldOperation(
std::snprintf(buffer, sizeof buffer,
"INTEGER(%d) to REAL(%d) conversion", Operand::kind,
TO::kind);
- RealFlagWarnings(context, converted.flags, buffer);
+ RealFlagWarnings(ctx, converted.flags, buffer);
}
return ScalarConstantToExpr(std::move(converted.value));
} else if constexpr (Operand::category == TypeCategory::Real) {
@@ -1223,9 +1223,9 @@ Expr<TO> FoldOperation(
if (!converted.flags.empty()) {
std::snprintf(buffer, sizeof buffer,
"REAL(%d) to REAL(%d) conversion", Operand::kind, TO::kind);
- RealFlagWarnings(context, converted.flags, buffer);
+ RealFlagWarnings(ctx, converted.flags, buffer);
}
- if (context.flushSubnormalsToZero()) {
+ if (ctx.flushSubnormalsToZero()) {
converted.value = converted.value.FlushSubnormalToZero();
}
return ScalarConstantToExpr(std::move(converted.value));
More information about the flang-commits
mailing list