* decl2.c (mark_used): Adjust error for use of deleted function.

From-SVN: r161580
This commit is contained in:
Jason Merrill 2010-06-29 20:51:13 -04:00 committed by Jason Merrill
parent ac1774315c
commit 9a71b305bf
46 changed files with 146 additions and 146 deletions

View File

@ -1,5 +1,7 @@
2010-06-29 Jason Merrill <jason@redhat.com>
* decl2.c (mark_used): Adjust error for use of deleted function.
Machinery to support implicit delete/move.
* cp-tree.h: (struct lang_type_class): Add lazy_move_assign,
has_complex_move_ctor, has_complex_move_assign bitfields.

View File

@ -4110,8 +4110,9 @@ mark_used (tree decl)
return;
}
}
error ("deleted function %q+D", decl);
error ("used here");
error ("use of deleted function %qD", decl);
if (!maybe_explain_implicit_delete (decl))
error_at (DECL_SOURCE_LOCATION (decl), "declared here");
return;
}
/* If we don't need a value, then we don't need to synthesize DECL. */

View File

@ -1,5 +1,14 @@
2010-06-29 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/defaulted10.C: Adjust for new deleted message.
* g++.dg/cpp0x/defaulted13.C: Adjust.
* g++.dg/cpp0x/defaulted2.C: Adjust.
* g++.dg/cpp0x/defaulted3.C: Adjust.
* g++.dg/cpp0x/initlist9.C: Adjust.
* g++.dg/cpp0x/lambda/lambda-errloc.C: Adjust.
* g++.dg/cpp0x/lambda/lambda-errloc2.C: Adjust.
* g++.dg/init/synth2.C: Adjust.
* g++.dg/cpp0x/defaulted19.C: New.
* g++.dg/expr/string-1.C: Fix for -std=c++0x.

View File

@ -3,12 +3,12 @@
struct A
{
template<typename T> void foo(T) = delete; // { dg-error "previously|deleted" }
template<typename T> void foo(T) = delete; // { dg-error "previously|declared" }
};
template<typename T> void A::foo(T) {} // { dg-error "redefinition" }
void bar()
{
A().foo(0); // { dg-error "used" }
A().foo(0); // { dg-error "use" }
}

View File

@ -7,22 +7,22 @@ struct NonCopyable {
};
template<>
NonCopyable<int>::NonCopyable(NonCopyable<int> const&) = delete; // { dg-error "deleted" }
NonCopyable<int>::NonCopyable(NonCopyable<int> const&) = delete; // { dg-error "declared" }
template<typename T>
NonCopyable<T>::NonCopyable(NonCopyable<T> const&) = default;
template<>
NonCopyable<double>::NonCopyable(NonCopyable<double> const&) = delete; // { dg-error "deleted" }
NonCopyable<double>::NonCopyable(NonCopyable<double> const&) = delete; // { dg-error "declared" }
int main()
{
NonCopyable<double> nc_dbl;
NonCopyable<double> nc_dbl_cpy(nc_dbl); // { dg-error "used here" }
NonCopyable<double> nc_dbl_cpy(nc_dbl); // { dg-error "use" }
NonCopyable<int> nc_int;
NonCopyable<int> nc_int_cpy(nc_int); // { dg-error "used here" }
NonCopyable<int> nc_int_cpy(nc_int); // { dg-error "use" }
NonCopyable<char> nc_char;
NonCopyable<char> nc_char_cpy(nc_char);

View File

@ -41,7 +41,7 @@ struct E
struct F
{
F() = default;
F(const F&) = delete; // { dg-error "deleted" }
F(const F&) = delete; // { dg-error "declared" }
};
struct G
@ -60,7 +60,7 @@ union U
int main()
{
F f;
F f2(f); // { dg-error "used" }
F f2(f); // { dg-error "use" }
B* b = new const B; // { dg-error "uninitialized const" }
}

View File

@ -4,7 +4,7 @@
template<class T>
struct A {
template<class U>
bool operator==(const A<U>&) = delete; // { dg-error "deleted function" }
bool operator==(const A<U>&) = delete; // { dg-error "declared" }
operator bool () { return true; }
};
@ -12,5 +12,5 @@ int main()
{
A<int> a1;
A<void> a2;
if(a1 == a2) {} // { dg-error "used here" }
if(a1 == a2) {} // { dg-error "use" }
}

View File

@ -8,7 +8,7 @@ struct b
b() = default;
~b() = default;
b& operator=(const b&) = delete;
b(const b&) = delete; // { dg-error "deleted" }
b(const b&) = delete; // { dg-error "declared" }
b(bool _t): t (_t) { }
};
@ -19,7 +19,7 @@ int main()
b tst1 = { false };
// copy initialization.
b tst2 = false; // { dg-error "used here" }
b tst2 = false; // { dg-error "use" }
// direct list initialization
b tst3 { false };

View File

@ -5,7 +5,7 @@
struct A
{
A();
A(const A& a) = delete; // { dg-error "deleted" }
A(const A& a) = delete; // { dg-error "declared" }
};
int main()

View File

@ -3,14 +3,14 @@
struct A {
A();
A(const A&) = delete; // { dg-error "deleted function" }
A(const A&) = delete; // { dg-error "declared" }
};
template <class T>
void f()
{
T t;
[t] { return 0; }; // { dg-error "used here" }
[t] { return 0; }; // { dg-error "use" }
}
int main()

View File

@ -13,5 +13,5 @@ class A // { dg-error "no match" }
int main()
{
A a;
A b = a; // { dg-message "required here" }
A b = a; // { dg-message "required here|deleted" }
}

View File

@ -1,3 +1,41 @@
2010-06-29 Jason Merrill <jason@redhat.com>
* 19_diagnostics/error_category/cons/copy_neg.cc: Adjust expected
errors, use dg-prune-output.
* 20_util/function/cmp/cmp_neg.cc: Likewise.
* 20_util/unique_ptr/assign/assign_neg.cc: Likewise.
* 20_util/unique_ptr/cons/pointer_array_convertible.cc: Likewise.
* 20_util/unique_ptr/modifiers/reset_neg.cc: Likewise.
* 29_atomics/atomic/cons/assign_neg.cc: Likewise.
* 29_atomics/atomic/cons/copy_neg.cc: Likewise.
* 29_atomics/atomic_address/cons/assign_neg.cc: Likewise.
* 29_atomics/atomic_address/cons/copy_neg.cc: Likewise.
* 29_atomics/atomic_flag/cons/assign_neg.cc: Likewise.
* 29_atomics/atomic_flag/cons/copy_neg.cc: Likewise.
* 29_atomics/atomic_integral/cons/assign_neg.cc: Likewise.
* 29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
* 29_atomics/condition_variable/cons/assign_neg.cc: Likewise.
* 30_threads/condition_variable/cons/copy_neg.cc: Likewise.
* 30_threads/condition_variable_any/cons/assign_neg.cc: Likewise.
* 30_threads/condition_variable_any/cons/copy_neg.cc: Likewise.
* 30_threads/future/cons/assign_neg.cc: Likewise.
* 30_threads/future/cons/copy_neg.cc: Likewise.
* 30_threads/mutex/cons/assign_neg.cc: Likewise.
* 30_threads/mutex/cons/copy_neg.cc: Likewise.
* 30_threads/packaged_task/cons/assign_neg.cc: Likewise.
* 30_threads/packaged_task/cons/copy_neg.cc: Likewise.
* 30_threads/promise/cons/assign_neg.cc: Likewise.
* 30_threads/promise/cons/copy_neg.cc: Likewise.
* 30_threads/recursive_mutex/cons/assign_neg.cc: Likewise.
* 30_threads/recursive_mutex/cons/copy_neg.cc: Likewise.
* 30_threads/recursive_timed_mutex/cons/assign_neg.cc: Likewise.
* 30_threads/recursive_timed_mutex/cons/copy_neg.cc: Likewise.
* 30_threads/thread/cons/assign_neg.cc: Likewise.
* 30_threads/thread/cons/copy_neg.cc: Likewise.
* 30_threads/timed_mutex/cons/assign_neg.cc: Likewise.
* 30_threads/timed_mutex/cons/copy_neg.cc: Likewise.
* ext/ext_pointer/1_neg.cc: Likewise.
2010-06-29 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/44708

View File

@ -27,10 +27,10 @@ int main()
bool test __attribute__((unused)) = true;
__gnu_test::test_category c1;
__gnu_test::test_category c2(c1); // { dg-error "first required here" }
__gnu_test::test_category c2(c1); // { dg-error "deleted" }
return 0;
}
// { dg-error "deleted function" "" { target *-*-* } 72 }
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-prune-output "testsuite_error" }
// { dg-prune-output "include" }

View File

@ -18,15 +18,16 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-prune-output "include" }
#include <functional>
void test01()
{
std::function<void()> f1;
std::function<void()> f2;
f1 == f2; // { dg-error "here" }
f1 != f2; // { dg-error "here" }
// { dg-excess-errors "" }
f1 == f2; // { dg-error "deleted" }
f1 != f2; // { dg-error "deleted" }
}
int main()

View File

@ -39,25 +39,14 @@ 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 *-*-* } 373 }
// { dg-error "used here" "" { target *-*-* } 42 }
// { dg-error "no matching" "" { target *-*-* } 48 }
// { dg-warning "note" "" { target *-*-* } 137 }
// { dg-warning "note" "" { target *-*-* } 133 }
// { dg-warning "note" "" { target *-*-* } 128 }
// { dg-warning "note" "" { target *-*-* } 122 }
// { dg-warning "note" "" { target *-*-* } 117 }
// { dg-warning "note" "" { target *-*-* } 112 }
// { dg-warning "note" "" { target *-*-* } 106 }
// { dg-error "deleted function" "" { target *-*-* } 225 }
// { dg-error "used here" "" { target *-*-* } 49 }
// { dg-prune-output "include" }

View File

@ -37,4 +37,5 @@ test01()
{
std::unique_ptr<B[]> B_from_A(new A[3]); //{ dg-error "invalid conversion from" }
}
//{ dg-excess-errors "initialization" }
// { dg-prune-output "include" }

View File

@ -32,8 +32,7 @@ struct B : A
void test01()
{
std::unique_ptr<B[]> up;
up.reset(new A[3]);
up.reset(new A[3]); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 35 }
// { dg-error "deleted function" "" { target *-*-* } 363 }
// { dg-prune-output "include" }

View File

@ -29,4 +29,4 @@ int main()
}
// { dg-error "ambiguous" "" { target *-*-* } 522 }
// { dg-excess-errors "In member function" }
// { dg-prune-output "include" }

View File

@ -28,19 +28,5 @@ int main()
return 0;
}
// { dg-error "used here" "" { target *-*-* } 561 }
// { dg-error "deleted function" "" { target *-*-* } 229 }
// { dg-error "deleted function" "" { target *-*-* } 247 }
// { dg-error "deleted function" "" { target *-*-* } 265 }
// { dg-error "deleted function" "" { target *-*-* } 283 }
// { dg-error "deleted function" "" { target *-*-* } 301 }
// { dg-error "deleted function" "" { target *-*-* } 319 }
// { dg-error "deleted function" "" { target *-*-* } 337 }
// { dg-error "deleted function" "" { target *-*-* } 355 }
// { dg-error "deleted function" "" { target *-*-* } 373 }
// { dg-error "deleted function" "" { target *-*-* } 391 }
// { dg-error "deleted function" "" { target *-*-* } 409 }
// { dg-error "deleted function" "" { target *-*-* } 427 }
// { dg-error "deleted function" "" { target *-*-* } 445 }
// { dg-error "deleted function" "" { target *-*-* } 463 }
// { dg-error "deleted function" "" { target *-*-* } 481 }
// { dg-error "deleted" "" { target *-*-* } 561 }
// { dg-prune-output "include" }

View File

@ -28,4 +28,4 @@ void test01()
test_type t2;
t1 = t2; // { dg-error "ambiguous" }
}
// { dg-excess-errors "deleted function" }
// { dg-prune-output "include" }

View File

@ -25,7 +25,7 @@ void test01()
// Copy.
typedef std::atomic_address test_type;
test_type t1;
test_type t2(t1);
test_type t2(t1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 28 }
// { dg-excess-errors "deleted function" }
// { dg-prune-output "include" }

View File

@ -26,7 +26,7 @@ void test01()
typedef std::atomic_flag test_type;
test_type t1;
test_type t2;
t1 = t2;
t1 = t2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 29 }
// { dg-excess-errors "deleted function" }
// { dg-prune-output "include" }

View File

@ -25,7 +25,7 @@ void test01()
// Copy.
typedef std::atomic_flag test_type;
test_type t1;
test_type t2(t1);
test_type t2(t1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 28 }
// { dg-excess-errors "deleted function" }
// { dg-prune-output "include" }

View File

@ -30,4 +30,4 @@ int main()
}
// { dg-error "ambiguous" "" { target *-*-* } 522 }
// { dg-excess-errors "In member function" }
// { dg-prune-output "include" }

View File

@ -29,12 +29,5 @@ int main()
return 0;
}
// { dg-error "used here" "" { target *-*-* } 561 }
// { dg-excess-errors "deleted function" }
// { dg-excess-errors "deleted function" }
// { dg-error "instantiated from" "" { target *-*-* } 28 }
// { dg-error "instantiated from" "" { target *-*-* } 567 }
// { dg-error "instantiated from" "" { target *-*-* } 170 }
// { dg-error "instantiated from" "" { target *-*-* } 399 }
// { dg-error "instantiated from" "" { target *-*-* } 168 }
// { dg-excess-errors "In member function" }
// { dg-error "deleted" "" { target *-*-* } 561 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
std::condition_variable c1;
std::condition_variable c2;
c1 = c2;
c1 = c2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 70 }
// { dg-prune-output "include" }

View File

@ -27,8 +27,7 @@ void test01()
{
// copy
std::condition_variable c1;
std::condition_variable c2(c1);
std::condition_variable c2(c1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 69 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
std::condition_variable_any c1;
std::condition_variable_any c2;
c1 = c2;
c1 = c2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 179 }
// { dg-prune-output "include" }

View File

@ -27,8 +27,7 @@ void test01()
{
// copy
std::condition_variable_any c1;
std::condition_variable_any c2(c1);
std::condition_variable_any c2(c1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 178 }
// { dg-prune-output "include" }

View File

@ -31,8 +31,7 @@ void test01()
// assign
std::future<int>& p1 = get();
std::future<int>& p2 = get();
p1 = p2;
p1 = p2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 34 }
// { dg-error "deleted function" "" { target *-*-* } 581 }
// { dg-prune-output "include" }

View File

@ -30,8 +30,7 @@ void test01()
{
// copy
std::future<int>& p1 = get();
std::future<int> p2(p1);
std::future<int> p2(p1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 33 }
// { dg-error "deleted function" "" { target *-*-* } 580 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
typedef std::mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 82 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
typedef std::mutex mutex_type;
mutex_type m1;
mutex_type m2(m1);
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 81 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
// assign
std::packaged_task<int()> p1;
std::packaged_task<int()> p2;
p1 = p2;
p1 = p2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 1228 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
{
// copy
std::packaged_task<int()> p1;
std::packaged_task<int()> p2(p1);
std::packaged_task<int()> p2(p1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 1227 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
// assign
std::promise<int> p1;
std::promise<int> p2;
p1 = p2;
p1 = p2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 871 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
{
// copy
std::promise<int> p1;
std::promise<int> p2(p1);
std::promise<int> p2(p1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 855 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
typedef std::recursive_mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 134 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
typedef std::recursive_mutex mutex_type;
mutex_type m1;
mutex_type m2(m1);
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 133 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
typedef std::recursive_timed_mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 297 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
typedef std::recursive_timed_mutex mutex_type;
mutex_type m1;
mutex_type m2(m1);
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 296 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
typedef std::thread test_type;
test_type t1;
test_type t2;
t1 = t2;
t1 = t2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 148 }
// { dg-prune-output "include" }

View File

@ -27,9 +27,13 @@ void test01()
// copy
typedef std::thread test_type;
test_type t1;
test_type t2(t1); // XXX this is failing for the wrong reason
test_type t2(t1); // { dg-error "deleted" "" { xfail *-*-* } }
}
// { dg-error "here" "" { target *-*-* } 30 }
// { dg-error "deleted function" "" { target *-*-* } 126 }
// { dg-excess-errors "In file included from" }
// This is failing for the wrong reason; it should fail because we're
// trying to call the deleted copy constructor, but instead it fails
// because we try to call the thread(_Callable&&,_Args&&...) constructor
// and fail because thread isn't callable. But that's OK for now.
// { dg-error "" "" { target *-*-* } 30 }
// { dg-prune-output "include" }

View File

@ -29,8 +29,7 @@ void test01()
typedef std::timed_mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 32 }
// { dg-error "deleted function" "" { target *-*-* } 192 }
// { dg-prune-output "include" }

View File

@ -28,8 +28,7 @@ void test01()
// assign
typedef std::timed_mutex mutex_type;
mutex_type m1;
mutex_type m2(m1);
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-error "used here" "" { target *-*-* } 31 }
// { dg-error "deleted function" "" { target *-*-* } 191 }
// { dg-prune-output "include" }

View File

@ -91,8 +91,4 @@ void test01(void) {
aptr5 = __const_pointer_cast<B_pointer>(cbptr); // ok
}
// { dg-error "invalid conversion " "" { target *-*-* } 314 }
// { dg-error "invalid conversion " "" { target *-*-* } 308 }
// { dg-error "invalid conversion " "" { target *-*-* } 331 }
// { dg-error "invalid conversion " "" { target *-*-* } 339 }
// { dg-excess-errors "In constructor" }
// { dg-prune-output "include" }