blob: ec0db74554a870fd4d6ff863e35ae741feb88b84 [file] [log] [blame]
Richard Smith1d0c9a82012-02-14 21:14:13 +00001// RUN: %clang_cc1 -std=c++11 -verify %s
2struct A { // expected-note 2{{candidate}}
3 A(int); // expected-note {{candidate}}
4 int n;
5};
6int a = A().n; // expected-error {{no matching constructor}}
7
8struct B {
Richard Smith5bdaac52012-04-02 20:59:25 +00009 B() = delete; // expected-note 3{{here}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000010 int n;
11};
12int b = B().n; // expected-error {{call to deleted}}
13
Richard Smith6c4c36c2012-03-30 20:53:28 +000014struct C {
15 B b; // expected-note {{deleted default constructor}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000016};
Douglas Gregore4e68d42012-02-15 19:33:52 +000017int c = C().b.n; // expected-error {{call to implicitly-deleted default}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000018
Richard Smith6c4c36c2012-03-30 20:53:28 +000019struct D {
20 D() = default; // expected-note {{here}}
Richard Smith5bdaac52012-04-02 20:59:25 +000021 B b; // expected-note {{'b' has a deleted default constructor}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000022};
Douglas Gregore4e68d42012-02-15 19:33:52 +000023int d = D().b.n; // expected-error {{call to implicitly-deleted default}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000024
25struct E {
26 E() = default;
27 int n;
28};
29int e = E().n; // ok
30
31struct F {
32 F();
33 int n;
34};
35int f = F().n; // ok
36
Richard Smith6c4c36c2012-03-30 20:53:28 +000037union G {
38 F f; // expected-note {{non-trivial default constructor}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000039};
Douglas Gregore4e68d42012-02-15 19:33:52 +000040int g = G().f.n; // expected-error {{call to implicitly-deleted default}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000041
42struct H {
43 int n;
44private:
45 H(); // expected-note {{here}}
46};
47int h = H().n; // expected-error {{private constructor}}
48
Richard Smith6c4c36c2012-03-30 20:53:28 +000049struct I {
50 H h; // expected-note {{inaccessible default constructor}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000051};
Douglas Gregore4e68d42012-02-15 19:33:52 +000052int i = I().h.n; // expected-error {{call to implicitly-deleted default}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000053
54struct J {
55 J();
56 virtual int f();
57 int n;
58};
59int j1 = J().n; // ok
60int j2 = J().f(); // ok
61
Richard Smith6c4c36c2012-03-30 20:53:28 +000062union K {
63 J j; // expected-note 2{{non-trivial default constructor}}
Richard Smith1d0c9a82012-02-14 21:14:13 +000064 int m;
65};
Douglas Gregore4e68d42012-02-15 19:33:52 +000066int k1 = K().j.n; // expected-error {{call to implicitly-deleted default}}
67int k2 = K().j.f(); // expected-error {{call to implicitly-deleted default}}