summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
blob: f6e5593d850f88396aef5e62f498dd6133764b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s

struct non_trivial {
  non_trivial();
  non_trivial(const non_trivial&);
  non_trivial& operator = (const non_trivial&);
  ~non_trivial();
};

union bad_union { // expected-note {{defined here}}
  non_trivial nt;
};
bad_union u; // expected-error {{call to implicitly-deleted default constructor}}
union bad_union2 { // expected-note {{defined here}}
  const int i;
};
bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}

struct bad_anon { // expected-note {{defined here}}
  union {
    non_trivial nt;
  };
};
bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}
struct bad_anon2 { // expected-note {{defined here}}
  union {
    const int i;
  };
};
bad_anon2 a2; // expected-error {{call to implicitly-deleted default constructor}}

// This would be great except that we implement
union good_union {
  const int i;
  float f;
};
good_union gu;
struct good_anon {
  union {
    const int i;
    float f;
  };
};
good_anon ga;

struct good : non_trivial {
  non_trivial nt;
};
good g;

struct bad_const { // expected-note {{defined here}}
  const good g;
};
bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}

struct good_const {
  const non_trivial nt;
};
good_const gc;

struct no_default {
  no_default() = delete;
};
struct no_dtor {
  ~no_dtor() = delete;
};

struct bad_field_default { // expected-note {{defined here}}
  no_default nd;
};
bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}
struct bad_base_default : no_default { // expected-note {{defined here}}
};
bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}

struct bad_field_dtor { // expected-note {{defined here}}
  no_dtor nd;
};
bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}
struct bad_base_dtor : no_dtor { // expected-note {{defined here}}
};
bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}

struct ambiguous_default {
  ambiguous_default();
  ambiguous_default(int = 2);
};
struct has_amb_field { // expected-note {{defined here}}
  ambiguous_default ad;
};
has_amb_field haf; // expected-error {{call to implicitly-deleted default constructor}}

class inaccessible_default {
  inaccessible_default();
};
struct has_inacc_field { // expected-note {{defined here}}
  inaccessible_default id;
};
has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}

class friend_default {
  friend struct has_friend;
  friend_default();
};
struct has_friend {
  friend_default fd;
};
has_friend hf;

struct defaulted_delete { // expected-note {{defined here}}
  no_default nd;
  defaulted_delete() = default; // expected-note{{declared here}}
};
defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}

struct late_delete {
  no_default nd;
  late_delete();
};
late_delete::late_delete() = default; // expected-error {{would delete it}}

// See also rdar://problem/8125400.
namespace empty {
  static union {};
  static union { union {}; };
  static union { struct {}; };
  static union { union { union {}; }; };
  static union { union { struct {}; }; };
  static union { struct { union {}; }; };
  static union { struct { struct {}; }; };
}
OpenPOWER on IntegriCloud