2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
|
2011-05-17 08:19:05 +08:00
|
|
|
|
|
|
|
struct non_trivial {
|
|
|
|
non_trivial();
|
|
|
|
non_trivial(const non_trivial&);
|
|
|
|
non_trivial& operator = (const non_trivial&);
|
|
|
|
~non_trivial();
|
|
|
|
};
|
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
union bad_union {
|
|
|
|
non_trivial nt; // expected-note {{non-trivial default constructor}}
|
2011-05-17 08:19:05 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_union u; // expected-error {{call to implicitly-deleted default constructor}}
|
2012-03-31 04:53:28 +08:00
|
|
|
union bad_union2 { // expected-note {{all data members are const-qualified}}
|
2011-05-17 08:19:05 +08:00
|
|
|
const int i;
|
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-17 08:19:05 +08:00
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_anon {
|
2011-05-17 08:19:05 +08:00
|
|
|
union {
|
2012-03-31 04:53:28 +08:00
|
|
|
non_trivial nt; // expected-note {{non-trivial default constructor}}
|
2011-05-17 08:19:05 +08:00
|
|
|
};
|
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_anon2 {
|
|
|
|
union { // expected-note {{all data members of an anonymous union member are const-qualified}}
|
2011-05-17 08:19:05 +08:00
|
|
|
const int i;
|
|
|
|
};
|
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_anon2 a2; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-17 08:19:05 +08:00
|
|
|
|
|
|
|
// 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;
|
2011-05-18 04:44:39 +08:00
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_const {
|
|
|
|
const good g; // expected-note {{field 'g' of const-qualified type 'const good' would not be initialized}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
|
|
|
struct good_const {
|
|
|
|
const non_trivial nt;
|
|
|
|
};
|
|
|
|
good_const gc;
|
|
|
|
|
|
|
|
struct no_default {
|
2012-04-03 04:59:25 +08:00
|
|
|
no_default() = delete; // expected-note 3{{deleted here}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
|
|
|
struct no_dtor {
|
2012-03-31 04:53:28 +08:00
|
|
|
~no_dtor() = delete; // expected-note 2{{deleted here}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_field_default {
|
|
|
|
no_default nd; // expected-note {{field 'nd' has a deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_base_default : no_default { // expected-note {{base class 'no_default' has a deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_field_dtor {
|
|
|
|
no_dtor nd; // expected-note {{field 'nd' has a deleted destructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}
|
2012-03-31 04:53:28 +08:00
|
|
|
struct bad_base_dtor : no_dtor { // expected-note {{base class 'no_dtor' has a deleted destructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
|
|
|
struct ambiguous_default {
|
|
|
|
ambiguous_default();
|
|
|
|
ambiguous_default(int = 2);
|
|
|
|
};
|
2012-03-31 04:53:28 +08:00
|
|
|
struct has_amb_field {
|
|
|
|
ambiguous_default ad; // expected-note {{field 'ad' has multiple default constructors}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
has_amb_field haf; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
|
|
|
class inaccessible_default {
|
|
|
|
inaccessible_default();
|
|
|
|
};
|
2012-03-31 04:53:28 +08:00
|
|
|
struct has_inacc_field {
|
|
|
|
inaccessible_default id; // expected-note {{field 'id' has an inaccessible default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
|
|
|
class friend_default {
|
|
|
|
friend struct has_friend;
|
|
|
|
friend_default();
|
|
|
|
};
|
|
|
|
struct has_friend {
|
|
|
|
friend_default fd;
|
|
|
|
};
|
|
|
|
has_friend hf;
|
|
|
|
|
2012-03-31 04:53:28 +08:00
|
|
|
struct defaulted_delete {
|
2012-04-03 04:59:25 +08:00
|
|
|
no_default nd; // expected-note {{because field 'nd' has a deleted default constructor}}
|
|
|
|
defaulted_delete() = default; // expected-note{{implicitly deleted here}}
|
2011-05-18 04:44:39 +08:00
|
|
|
};
|
2012-02-16 03:33:52 +08:00
|
|
|
defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}
|
2011-05-18 04:44:39 +08:00
|
|
|
|
|
|
|
struct late_delete {
|
|
|
|
no_default nd;
|
|
|
|
late_delete();
|
|
|
|
};
|
|
|
|
late_delete::late_delete() = default; // expected-error {{would delete it}}
|
2011-09-18 08:06:34 +08:00
|
|
|
|
|
|
|
// See also rdar://problem/8125400.
|
|
|
|
namespace empty {
|
2012-02-25 05:25:53 +08:00
|
|
|
static union {};
|
|
|
|
static union { union {}; };
|
2011-09-18 08:06:34 +08:00
|
|
|
static union { struct {}; };
|
2012-02-25 05:25:53 +08:00
|
|
|
static union { union { union {}; }; };
|
2011-09-18 08:06:34 +08:00
|
|
|
static union { union { struct {}; }; };
|
2012-02-25 05:25:53 +08:00
|
|
|
static union { struct { union {}; }; };
|
2011-09-18 08:06:34 +08:00
|
|
|
static union { struct { struct {}; }; };
|
|
|
|
}
|