blob: 845173934219cf1f3a8fbe331aa2e56e164ef170 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Anders Carlsson5c478cf2009-12-04 22:33:25 +00002
John McCall3d043362010-04-13 07:45:41 +00003struct A { };
Sean Huntf961ea52011-05-10 19:08:14 +00004A::A() { } // expected-error {{definition of implicitly declared default constructor}}
Anders Carlsson5c478cf2009-12-04 22:33:25 +00005
John McCall3d043362010-04-13 07:45:41 +00006struct B { };
Anders Carlsson5c478cf2009-12-04 22:33:25 +00007B::B(const B&) { } // expected-error {{definition of implicitly declared copy constructor}}
8
John McCall3d043362010-04-13 07:45:41 +00009struct C { };
Anders Carlsson5c478cf2009-12-04 22:33:25 +000010C& C::operator=(const C&) { return *this; } // expected-error {{definition of implicitly declared copy assignment operator}}
11
John McCall3d043362010-04-13 07:45:41 +000012struct D { };
Anders Carlsson5c478cf2009-12-04 22:33:25 +000013D::~D() { } // expected-error {{definition of implicitly declared destructor}}
14
Douglas Gregor6275e0c2010-04-12 17:09:20 +000015// Make sure that the special member functions are introduced for
16// name-lookup purposes and overload with user-declared
17// constructors and assignment operators.
18namespace PR6570 {
19 class A { };
20
21 class B {
22 public:
23 B() {}
24
25 B(const A& a) {
26 operator = (CONST);
27 operator = (a);
28 }
29
30 B& operator = (const A& a) {
31 return *this;
32 }
33
34 void f(const A &a) {
35 B b(a);
36 };
37
38 static const B CONST;
39 };
40
41}
Sebastian Redlcddc69f2010-07-08 23:07:34 +000042
43namespace PR7594 {
44 // If the lazy declaration of special member functions is triggered
45 // in an out-of-line initializer, make sure the functions aren't in
46 // the initializer scope. This used to crash Clang:
47 struct C {
48 C();
49 static C *c;
50 };
51 C *C::c = new C();
52}