From 910285b238910084aabe786178337b158b82a3bb Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 27 Oct 2014 19:28:20 +0000 Subject: [libcxx] Fix use of operator comma where the types can be user defined Summary: An evil user might overload operator comma. Use a void cast to make sure any user overload is not selected. Modify all the test iterators to define operator comma. Reviewers: danalbert, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5929 llvm-svn: 220706 --- .../forwardlist/forwardlist.cons/assign_range.pass.cpp | 2 +- libcxx/test/support/test_iterators.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'libcxx/test') diff --git a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp index fb3765d2030..0b348e6920c 100644 --- a/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp +++ b/libcxx/test/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp @@ -70,7 +70,7 @@ int main() typedef input_iterator I; c.assign(I(std::begin(t0)), I(std::end(t0))); int n = 0; - for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n) + for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, (void) ++n) assert(*i == 10+n); assert(n == 4); } diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h index cf164be806d..71509083e13 100644 --- a/libcxx/test/support/test_iterators.h +++ b/libcxx/test/support/test_iterators.h @@ -38,6 +38,9 @@ public: output_iterator& operator++() {++it_; return *this;} output_iterator operator++(int) {output_iterator tmp(*this); ++(*this); return tmp;} + + template + void operator,(T const &); }; template @@ -71,6 +74,9 @@ public: {return x.it_ == y.it_;} friend bool operator!=(const input_iterator& x, const input_iterator& y) {return !(x == y);} + + template + void operator,(T const &); }; template @@ -120,6 +126,9 @@ public: {return x.it_ == y.it_;} friend bool operator!=(const forward_iterator& x, const forward_iterator& y) {return !(x == y);} + + template + void operator,(T const &); }; template @@ -168,6 +177,9 @@ public: bidirectional_iterator& operator--() {--it_; return *this;} bidirectional_iterator operator--(int) {bidirectional_iterator tmp(*this); --(*this); return tmp;} + + template + void operator,(T const &); }; template @@ -227,6 +239,9 @@ public: {random_access_iterator tmp(*this); tmp -= n; return tmp;} reference operator[](difference_type n) const {return it_[n];} + + template + void operator,(T const &); }; template -- cgit v1.2.3