Skip to content

Commit

Permalink
[mlir] Fix build after ec50f58 (#101021)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ryan-holt-1 authored Aug 12, 2024
1 parent e2f9c18 commit 80ff391
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mlir/unittests/Support/CyclicReplacerCacheTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ TEST(CachedCyclicReplacerTest, testNoRecursion) {

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

// Starting at 0.
EXPECT_EQ(replacer(0), -1);
EXPECT_EQ((*replacer)(0), -1);
// Starting at 2.
EXPECT_EQ(replacer(2), -1);
EXPECT_EQ((*replacer)(2), -1);
}

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 80ff391

Please sign in to comment.