-// { 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-2024 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
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 *-*-* } 357 }
-// { dg-error "used here" "" { target *-*-* } 42 }
-// { dg-error "no matching" "" { target *-*-* } 48 }
-// { dg-warning "note" "" { target *-*-* } 130 }
-// { dg-warning "note" "" { target *-*-* } 134 }
-// { dg-warning "note" "" { target *-*-* } 123 }
-// { dg-warning "note" "" { target *-*-* } 118 }
-// { dg-warning "note" "" { target *-*-* } 113 }
-// { dg-warning "note" "" { target *-*-* } 107 }
-// { dg-error "deleted function" "" { target *-*-* } 222 }
-// { 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" }