[PATCH] D89367: [flang][msvc] Fix lambda capture ambiguity. NFC.
Michael Kruse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 13 23:43:21 PDT 2020
Meinersbur created this revision.
Meinersbur added reviewers: isuruf, DavidTruby, sscalpone, klausler, tskeith.
Meinersbur added a project: Flang.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
Meinersbur requested review of this revision.
Patch D88695 <https://reviews.llvm.org/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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89367
Files:
flang/lib/Evaluate/fold-implementation.h
Index: flang/lib/Evaluate/fold-implementation.h
===================================================================
--- flang/lib/Evaluate/fold-implementation.h
+++ flang/lib/Evaluate/fold-implementation.h
@@ -1167,12 +1167,12 @@
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);
}
@@ -1180,11 +1180,11 @@
} 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);
}
@@ -1197,7 +1197,7 @@
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) {
@@ -1205,9 +1205,9 @@
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));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89367.298048.patch
Type: text/x-patch
Size: 2802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201014/f7474099/attachment.bin>
More information about the llvm-commits
mailing list