Index: unittests/ADT/ArrayRefTest.cpp =================================================================== --- unittests/ADT/ArrayRefTest.cpp +++ unittests/ADT/ArrayRefTest.cpp @@ -134,7 +134,8 @@ } TEST(ArrayRefTest, InitializerList) { - ArrayRef A = { 0, 1, 2, 3, 4 }; + std::initializer_list init_list = { 0, 1, 2, 3, 4 }; + ArrayRef A = init_list; for (int i = 0; i < 5; ++i) EXPECT_EQ(i, A[i]); @@ -146,6 +147,17 @@ ArgTest12({1, 2}); } +static void ArrayRefInitArg(ArrayRef A) { + for (int i = 0; i < 5; ++i) + EXPECT_EQ(i, A[i]); +} + +// A more realistic test for the Init-list ctor +TEST(ArrayRefTest, InitializerListTemporary) { + ArrayRefInitArg({0, 1, 2, 3, 4 }); +} + + // Test that makeArrayRef works on ArrayRef (no-op) TEST(ArrayRefTest, makeArrayRef) { static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8};