cxx0x-default-delete.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Without PCH
  2. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include %s %s
  3. // With PCH
  4. // RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %s
  5. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -include-pch %t %s
  6. #ifndef PASS1
  7. #define PASS1
  8. struct foo {
  9. foo() = default;
  10. void bar() = delete;
  11. };
  12. struct baz {
  13. ~baz() = delete;
  14. };
  15. class quux {
  16. ~quux() = default;
  17. };
  18. struct A {
  19. A(const A&) = default;
  20. template<typename T> A(T&&);
  21. };
  22. #else
  23. foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}}
  24. foo f;
  25. void fn() {
  26. f.bar(); // expected-error{{deleted function}} expected-note@12{{deleted here}}
  27. }
  28. baz bz; // expected-error{{deleted function}} expected-note@16{{deleted here}}
  29. quux qx; // expected-error{{private destructor}} expected-note@20{{private here}}
  30. struct B { A a; };
  31. struct C { mutable A a; };
  32. static_assert(__is_trivially_constructible(B, const B&), "");
  33. static_assert(!__is_trivially_constructible(B, B&&), "");
  34. static_assert(!__is_trivially_constructible(C, const C&), "");
  35. static_assert(!__is_trivially_constructible(C, C&&), "");
  36. #endif