Skip to content

Commit 80ff391

Browse files
authored
[mlir] Fix build after ec50f58 (llvm#101021)
This commit fixes what appears to be invalid C++ -- a lambda capturing a variable before it is declared. The code compiles with GCC and Clang but not MSVC.
1 parent e2f9c18 commit 80ff391

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

mlir/unittests/Support/CyclicReplacerCacheTest.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ TEST(CachedCyclicReplacerTest, testNoRecursion) {
2626

2727
TEST(CachedCyclicReplacerTest, testInPlaceRecursionPruneAnywhere) {
2828
// Replacer cycles through ints 0 -> 1 -> 2 -> 0 -> ...
29-
CachedCyclicReplacer<int, int> replacer(
30-
/*replacer=*/[&](int n) { return replacer((n + 1) % 3); },
29+
std::optional<CachedCyclicReplacer<int, int>> replacer;
30+
replacer.emplace(
31+
/*replacer=*/[&](int n) { return (*replacer)((n + 1) % 3); },
3132
/*cycleBreaker=*/[&](int n) { return -1; });
3233

3334
// Starting at 0.
34-
EXPECT_EQ(replacer(0), -1);
35+
EXPECT_EQ((*replacer)(0), -1);
3536
// Starting at 2.
36-
EXPECT_EQ(replacer(2), -1);
37+
EXPECT_EQ((*replacer)(2), -1);
3738
}
3839

3940
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)