]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/20_util/unique_ptr/assign/assign_neg.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / assign / assign_neg.cc
index 4bf8e4b43490287b223db022d68070459ff6c100..7db9e197d56b582d6ff45e37537bac545d7bfbc0 100644 (file)
@@ -1,7 +1,6 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++0x" }
+// { dg-do compile { target c++11 } }
 
-// Copyright (C) 2008, 2009, 2010 Free Software Foundation
+// Copyright (C) 2008-2022 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -39,23 +38,35 @@ void
 test02()
 {
   std::unique_ptr<int[]> p1(new int(420));
-  std::unique_ptr<int[]> p2 = p1;
+  std::unique_ptr<int[]> p2 = p1; // { dg-error "deleted" }
 }
 
 void
 test03()
 {
-  std::unique_ptr<int[2]> p1(new int[3]);
-  std::unique_ptr<int[2]> p2 = p1;
+  std::unique_ptr<int[2]> p1(new int[3]); // { dg-error "no match" }
+  std::unique_ptr<int[2]> p2 = p1; // { dg-error "deleted" }
 }
 
-// { dg-error "deleted function" "" { target *-*-* } 342 }
-// { dg-error "used here" "" { target *-*-* } 42 }
-// { dg-error "no matching" "" { target *-*-* } 48 }
-// { dg-warning "candidates are" "" { target *-*-* } 115 }
-// { dg-warning "note" "" { target *-*-* } 108 }
-// { dg-warning "note" "" { target *-*-* } 103 }
-// { dg-warning "note" "" { target *-*-* } 98 }
-// { dg-warning "note" "" { target *-*-* } 92 }
-// { dg-error "deleted function" "" { target *-*-* } 207 }
-// { dg-error "used here" "" { target *-*-* } 49 }
+struct base_pointer { operator base*() const { return nullptr; } };
+
+template<typename T>
+struct deleter
+{
+  deleter() = default;
+  template<typename U>
+    deleter(const deleter<U>) { }
+  typedef T pointer;
+  void operator()(T) const { }
+};
+
+void
+test04()
+{
+  // Disallow conversions from incompatible deleter
+  std::unique_ptr<derived[], deleter<base_pointer>> p;
+  std::unique_ptr<base[], deleter<base*>> upA;
+  upA = std::move(p);  // { dg-error "no match" }
+}
+
+// { dg-prune-output "include" }