]> 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 76e33def11f109469e2646a0339c4b70a7a370b7..7db9e197d56b582d6ff45e37537bac545d7bfbc0 100644 (file)
@@ -1,7 +1,6 @@
-// { dg-do compile }
-// { dg-options "-std=gnu++0x" }
+// { dg-do compile { target c++11 } }
 
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// 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
@@ -46,8 +45,28 @@ void
 test03()
 {
   std::unique_ptr<int[2]> p1(new int[3]); // { dg-error "no match" }
-  // { dg-error "candidate" "candidate-note" { target *-*-* } 48 }
   std::unique_ptr<int[2]> p2 = p1; // { dg-error "deleted" }
 }
 
+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" }