summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-30 20:53:28 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-30 20:53:28 +0000
commit6c4c36c4ed1007143f5b8655eb68b313a7e12e76 (patch)
tree0a912935dcb75afa09172e2aabf7b40a71653f2e /test/SemaCXX
parent0f30a12ce7b3d4d86c9ca9072f587da77c8eef34 (diff)
PR10217: Provide diagnostics explaining why an implicitly-deleted special
member function is deleted. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/cxx0x-deleted-default-ctor.cpp46
-rw-r--r--test/SemaCXX/cxx98-compat-flags.cpp6
-rw-r--r--test/SemaCXX/cxx98-compat.cpp6
-rw-r--r--test/SemaCXX/defaulted-private-dtor.cpp6
-rw-r--r--test/SemaCXX/dr1301.cpp22
-rw-r--r--test/SemaCXX/implicit-exception-spec.cpp4
-rw-r--r--test/SemaCXX/value-initialization.cpp5
7 files changed, 45 insertions, 50 deletions
diff --git a/test/SemaCXX/cxx0x-deleted-default-ctor.cpp b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
index f6e5593d85..a5eaa352e4 100644
--- a/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
+++ b/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
@@ -7,23 +7,23 @@ struct non_trivial {
~non_trivial();
};
-union bad_union { // expected-note {{defined here}}
- non_trivial nt;
+union bad_union {
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
};
bad_union u; // expected-error {{call to implicitly-deleted default constructor}}
-union bad_union2 { // expected-note {{defined here}}
+union bad_union2 { // expected-note {{all data members are const-qualified}}
const int i;
};
bad_union2 u2; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_anon { // expected-note {{defined here}}
+struct bad_anon {
union {
- non_trivial nt;
+ non_trivial nt; // expected-note {{non-trivial default constructor}}
};
};
bad_anon a; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_anon2 { // expected-note {{defined here}}
- union {
+struct bad_anon2 {
+ union { // expected-note {{all data members of an anonymous union member are const-qualified}}
const int i;
};
};
@@ -48,8 +48,8 @@ struct good : non_trivial {
};
good g;
-struct bad_const { // expected-note {{defined here}}
- const good g;
+struct bad_const {
+ const good g; // expected-note {{field 'g' of const-qualified type 'const good' would not be initialized}}
};
bad_const bc; // expected-error {{call to implicitly-deleted default constructor}}
@@ -59,25 +59,25 @@ struct good_const {
good_const gc;
struct no_default {
- no_default() = delete;
+ no_default() = delete; // expected-note 2{{deleted here}}
};
struct no_dtor {
- ~no_dtor() = delete;
+ ~no_dtor() = delete; // expected-note 2{{deleted here}}
};
-struct bad_field_default { // expected-note {{defined here}}
- no_default nd;
+struct bad_field_default {
+ no_default nd; // expected-note {{field 'nd' has a deleted default constructor}}
};
bad_field_default bfd; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_base_default : no_default { // expected-note {{defined here}}
+struct bad_base_default : no_default { // expected-note {{base class 'no_default' has a deleted default constructor}}
};
bad_base_default bbd; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_field_dtor { // expected-note {{defined here}}
- no_dtor nd;
+struct bad_field_dtor {
+ no_dtor nd; // expected-note {{field 'nd' has a deleted destructor}}
};
bad_field_dtor bfx; // expected-error {{call to implicitly-deleted default constructor}}
-struct bad_base_dtor : no_dtor { // expected-note {{defined here}}
+struct bad_base_dtor : no_dtor { // expected-note {{base class 'no_dtor' has a deleted destructor}}
};
bad_base_dtor bbx; // expected-error {{call to implicitly-deleted default constructor}}
@@ -85,16 +85,16 @@ struct ambiguous_default {
ambiguous_default();
ambiguous_default(int = 2);
};
-struct has_amb_field { // expected-note {{defined here}}
- ambiguous_default ad;
+struct has_amb_field {
+ ambiguous_default ad; // expected-note {{field 'ad' has multiple default constructors}}
};
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;
+struct has_inacc_field {
+ inaccessible_default id; // expected-note {{field 'id' has an inaccessible default constructor}}
};
has_inacc_field hif; // expected-error {{call to implicitly-deleted default constructor}}
@@ -107,9 +107,9 @@ struct has_friend {
};
has_friend hf;
-struct defaulted_delete { // expected-note {{defined here}}
+struct defaulted_delete {
no_default nd;
- defaulted_delete() = default; // expected-note{{declared here}}
+ defaulted_delete() = default; // expected-note{{deleted here}}
};
defaulted_delete dd; // expected-error {{call to implicitly-deleted default constructor}}
diff --git a/test/SemaCXX/cxx98-compat-flags.cpp b/test/SemaCXX/cxx98-compat-flags.cpp
index fcc048a36d..6dc24be6bb 100644
--- a/test/SemaCXX/cxx98-compat-flags.cpp
+++ b/test/SemaCXX/cxx98-compat-flags.cpp
@@ -24,10 +24,8 @@ namespace CopyCtorIssues {
Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
};
- struct Deleted { // expected-note {{here}}
- // Copy ctor implicitly defined as deleted because Private's copy ctor is
- // inaccessible.
- Private p;
+ struct Deleted {
+ Private p; // expected-note {{copy constructor of 'Deleted' is implicitly deleted because field 'p' has an inaccessible copy constructor}}
};
const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp
index fd70875fc8..70cac8d54e 100644
--- a/test/SemaCXX/cxx98-compat.cpp
+++ b/test/SemaCXX/cxx98-compat.cpp
@@ -214,10 +214,8 @@ namespace CopyCtorIssues {
Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}}
Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}}
};
- struct Deleted { // expected-note {{here}}
- // Copy ctor implicitly defined as deleted because Private's copy ctor is
- // inaccessible.
- Private p;
+ struct Deleted {
+ Private p; // expected-note {{implicitly deleted}}
};
const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
diff --git a/test/SemaCXX/defaulted-private-dtor.cpp b/test/SemaCXX/defaulted-private-dtor.cpp
index 600dc3ca61..e6f955501a 100644
--- a/test/SemaCXX/defaulted-private-dtor.cpp
+++ b/test/SemaCXX/defaulted-private-dtor.cpp
@@ -12,12 +12,12 @@ void f() {
BadDtor dd; // expected-error {{private destructor}}
throw dd; // expected-error {{private destructor}}
}
-struct V { // expected-note {{here}}
+struct V {
V();
- BadDtor bd;
+ BadDtor bd; // expected-note {{inaccessible destructor}}
};
V v; // expected-error {{deleted function}}
-struct W : BadDtor { // expected-note {{here}}
+struct W : BadDtor { // expected-note {{inaccessible destructor}}
W();
};
W w; // expected-error {{deleted function}}
diff --git a/test/SemaCXX/dr1301.cpp b/test/SemaCXX/dr1301.cpp
index a348977f50..c92ff9b714 100644
--- a/test/SemaCXX/dr1301.cpp
+++ b/test/SemaCXX/dr1301.cpp
@@ -6,18 +6,18 @@ struct A { // expected-note 2{{candidate}}
int a = A().n; // expected-error {{no matching constructor}}
struct B {
- B() = delete; // expected-note {{here}}
+ B() = delete; // expected-note 2{{here}}
int n;
};
int b = B().n; // expected-error {{call to deleted}}
-struct C { // expected-note {{here}}
- B b;
+struct C {
+ B b; // expected-note {{deleted default constructor}}
};
int c = C().b.n; // expected-error {{call to implicitly-deleted default}}
-struct D { // expected-note {{defined here}}
- D() = default; // expected-note {{declared here}}
+struct D {
+ D() = default; // expected-note {{here}}
B b;
};
int d = D().b.n; // expected-error {{call to implicitly-deleted default}}
@@ -34,8 +34,8 @@ struct F {
};
int f = F().n; // ok
-union G { // expected-note {{here}}
- F f;
+union G {
+ F f; // expected-note {{non-trivial default constructor}}
};
int g = G().f.n; // expected-error {{call to implicitly-deleted default}}
@@ -46,8 +46,8 @@ private:
};
int h = H().n; // expected-error {{private constructor}}
-struct I { // expected-note {{here}}
- H h;
+struct I {
+ H h; // expected-note {{inaccessible default constructor}}
};
int i = I().h.n; // expected-error {{call to implicitly-deleted default}}
@@ -59,8 +59,8 @@ struct J {
int j1 = J().n; // ok
int j2 = J().f(); // ok
-union K { // expected-note 2{{here}}
- J j;
+union K {
+ J j; // expected-note 2{{non-trivial default constructor}}
int m;
};
int k1 = K().j.n; // expected-error {{call to implicitly-deleted default}}
diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp
index f8ee76727e..786e8f4a14 100644
--- a/test/SemaCXX/implicit-exception-spec.cpp
+++ b/test/SemaCXX/implicit-exception-spec.cpp
@@ -54,9 +54,9 @@ namespace ExceptionSpecification {
// The same problem arises in delayed parsing of default arguments,
// which clang does not yet support.
namespace DefaultArgument {
- struct Default { // expected-note {{defined here}}
+ struct Default {
struct T {
T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to implicitly-deleted default constructor}}
- } t;
+ } t; // expected-note {{has no default constructor}}
};
}
diff --git a/test/SemaCXX/value-initialization.cpp b/test/SemaCXX/value-initialization.cpp
index 3b552e2a42..4e3acbb767 100644
--- a/test/SemaCXX/value-initialization.cpp
+++ b/test/SemaCXX/value-initialization.cpp
@@ -1,8 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-struct A { //expected-note {{defined here}} \
- // expected-warning {{does not declare any constructor to initialize}}
- const int i; // expected-note{{const member 'i' will never be initialized}}
+struct A { // expected-warning {{does not declare any constructor to initialize}}
+ const int i; // expected-note{{const member 'i' will never be initialized}} expected-note {{implicitly deleted}}
virtual void f() { }
};