freebsd-skq/test/SemaCXX/destructor.cpp

86 lines
1.9 KiB
C++
Raw Normal View History

2010-01-01 10:34:51 +00:00
// RUN: %clang_cc1 -fsyntax-only -verify %s
2009-06-02 17:58:47 +00:00
class A {
public:
~A();
};
class B {
public:
~B() { }
};
class C {
public:
(~C)() { }
};
struct D {
static void ~D(int, ...) const { } // \
// expected-error{{type qualifier is not allowed on this function}} \
// expected-error{{destructor cannot be declared 'static'}} \
// expected-error{{destructor cannot have any parameters}} \
// expected-error{{destructor cannot be variadic}}
};
struct D2 {
void ~D2() { } // \
// expected-error{{destructor cannot have a return type}}
};
struct E;
typedef E E_typedef;
struct E {
2010-03-10 17:45:58 +00:00
~E_typedef(); // expected-error{{destructor cannot be declared using a typedef 'E_typedef' (aka 'E') of the class name}}
2009-06-02 17:58:47 +00:00
};
struct F {
(~F)(); // expected-note {{previous declaration is here}}
~F(); // expected-error {{destructor cannot be redeclared}}
};
2010-03-03 17:28:16 +00:00
~; // expected-error {{expected a class name after '~' to name a destructor}}
2009-10-14 18:03:49 +00:00
~undef(); // expected-error {{expected the class name after '~' to name a destructor}}
2010-03-03 17:28:16 +00:00
~operator+(int, int); // expected-error {{expected a class name after '~' to name a destructor}}
2009-06-02 17:58:47 +00:00
~F(){} // expected-error {{destructor must be a non-static member function}}
struct G {
~G();
};
G::~G() { }
// <rdar://problem/6841210>
struct H {
~H(void) { }
};
2009-10-14 18:03:49 +00:00
struct X {};
struct Y {
~X(); // expected-error {{expected the class name after '~' to name the enclosing class}}
};
2010-03-03 17:28:16 +00:00
namespace PR6421 {
class T; // expected-note{{forward declaration}}
class QGenericArgument
{
template<typename U>
void foo(T t) // expected-error{{variable has incomplete type}}
{ }
void disconnect()
{
T* t;
bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}}
}
};
}
2010-04-02 08:55:10 +00:00
namespace PR6709 {
template<class T> class X { T v; ~X() { ++*v; } };
void a(X<int> x) {}
}