PageRenderTime 49ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/test/SemaCXX/destructor.cpp

https://bitbucket.org/danchr/clang
C++ | 85 lines | 60 code | 18 blank | 7 comment | 0 complexity | 7257e1aa6b9d11a9cd5c7be37d051af8 MD5 | raw file
Possible License(s): JSON
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. class A {
  3. public:
  4. ~A();
  5. };
  6. class B {
  7. public:
  8. ~B() { }
  9. };
  10. class C {
  11. public:
  12. (~C)() { }
  13. };
  14. struct D {
  15. static void ~D(int, ...) const { } // \
  16. // expected-error{{type qualifier is not allowed on this function}} \
  17. // expected-error{{destructor cannot be declared 'static'}} \
  18. // expected-error{{destructor cannot have any parameters}} \
  19. // expected-error{{destructor cannot be variadic}}
  20. };
  21. struct D2 {
  22. void ~D2() { } // \
  23. // expected-error{{destructor cannot have a return type}}
  24. };
  25. struct E;
  26. typedef E E_typedef;
  27. struct E {
  28. ~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'E') of the class name}}
  29. };
  30. struct F {
  31. (~F)(); // expected-note {{previous declaration is here}}
  32. ~F(); // expected-error {{destructor cannot be redeclared}}
  33. };
  34. ~; // expected-error {{expected a class name after '~' to name a destructor}}
  35. ~undef(); // expected-error {{expected the class name after '~' to name a destructor}}
  36. ~operator+(int, int); // expected-error {{expected a class name after '~' to name a destructor}}
  37. ~F(){} // expected-error {{destructor must be a non-static member function}}
  38. struct G {
  39. ~G();
  40. };
  41. G::~G() { }
  42. // <rdar://problem/6841210>
  43. struct H {
  44. ~H(void) { }
  45. };
  46. struct X {};
  47. struct Y {
  48. ~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
  49. };
  50. namespace PR6421 {
  51. class T; // expected-note{{forward declaration}}
  52. class QGenericArgument
  53. {
  54. template<typename U>
  55. void foo(T t) // expected-error{{variable has incomplete type}}
  56. { }
  57. void disconnect()
  58. {
  59. T* t;
  60. bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}}
  61. }
  62. };
  63. }
  64. namespace PR6709 {
  65. template<class T> class X { T v; ~X() { ++*v; } };
  66. void a(X<int> x) {}
  67. }