From 74a12a46a04b9d2bcd1251a641b7cb64dfc0c5f8 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 29 Apr 2012 10:53:29 +0000 Subject: SmallVector: Don't rely on having an assignment operator around in push_back for POD-like types. llvm-svn: 155791 --- llvm/unittests/ADT/SmallVectorTest.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp') diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp index d5bfe76..c2542d6 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -413,4 +413,17 @@ TEST_F(SmallVectorTest, IteratorTest) { theVector.insert(theVector.end(), L.begin(), L.end()); } +struct notassignable { + int &x; + notassignable(int &x) : x(x) {} +}; + +TEST_F(SmallVectorTest, NoAssignTest) { + int x = 0; + SmallVector vec; + vec.push_back(notassignable(x)); + x = 42; + EXPECT_EQ(42, vec.pop_back_val().x); +} + } -- cgit v1.1