brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · e26dffc Raw
44 lines · plain
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -verify -fblocks -Wpessimizing-move -Wredundant-move %s2 3// definitions for std::move4namespace std {5inline namespace foo {6template <class T> struct remove_reference { typedef T type; };7template <class T> struct remove_reference<T&> { typedef T type; };8template <class T> struct remove_reference<T&&> { typedef T type; };9 10template <class T> typename remove_reference<T>::type &&move(T &&t);11}12}13 14class MoveOnly {15public:16  MoveOnly() { }17  MoveOnly(MoveOnly &&) = default; // expected-note 2 {{copy constructor is implicitly deleted}}18  MoveOnly &operator=(MoveOnly &&) = default;19  ~MoveOnly();20};21 22void copyInit() {23  __block MoveOnly temp;24  MoveOnly temp2 = temp; // expected-error {{call to implicitly-deleted copy constructor of 'MoveOnly'}}25  MoveOnly temp3 = std::move(temp); // ok26}27 28MoveOnly errorOnCopy() {29  __block MoveOnly temp;30  return temp; // expected-error {{call to implicitly-deleted copy constructor of 'MoveOnly'}}31}32 33MoveOnly dontWarnOnMove() {34  __block MoveOnly temp;35  return std::move(temp); // ok36}37 38class MoveOnlySub : public MoveOnly {};39 40MoveOnly dontWarnOnMoveSubclass() {41  __block MoveOnlySub temp;42  return std::move(temp); // ok43}44