annotate clang/test/SemaCXX/dr1301.cpp @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++11 -verify %s
anatofuz
parents:
diff changeset
2 struct A { // expected-note 2{{candidate}}
anatofuz
parents:
diff changeset
3 A(int); // expected-note {{candidate}}
anatofuz
parents:
diff changeset
4 int n;
anatofuz
parents:
diff changeset
5 };
anatofuz
parents:
diff changeset
6 int a = A().n; // expected-error {{no matching constructor}}
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 struct B {
anatofuz
parents:
diff changeset
9 B() = delete; // expected-note 4{{here}}
anatofuz
parents:
diff changeset
10 int n;
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12 int b = B().n; // expected-error {{call to deleted}}
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 struct C {
anatofuz
parents:
diff changeset
15 B b; // expected-note {{deleted default constructor}}
anatofuz
parents:
diff changeset
16 };
anatofuz
parents:
diff changeset
17 int c = C().b.n; // expected-error {{call to implicitly-deleted default}}
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 struct D {
anatofuz
parents:
diff changeset
20 D() = default; // expected-note {{here}} expected-warning {{implicitly deleted}}
anatofuz
parents:
diff changeset
21 B b; // expected-note 2{{'b' has a deleted default constructor}}
anatofuz
parents:
diff changeset
22 };
anatofuz
parents:
diff changeset
23 int d = D().b.n; // expected-error {{call to implicitly-deleted default}}
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 struct E {
anatofuz
parents:
diff changeset
26 E() = default;
anatofuz
parents:
diff changeset
27 int n;
anatofuz
parents:
diff changeset
28 };
anatofuz
parents:
diff changeset
29 int e = E().n; // ok
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 struct F {
anatofuz
parents:
diff changeset
32 F();
anatofuz
parents:
diff changeset
33 int n;
anatofuz
parents:
diff changeset
34 };
anatofuz
parents:
diff changeset
35 int f = F().n; // ok
anatofuz
parents:
diff changeset
36
anatofuz
parents:
diff changeset
37 union G {
anatofuz
parents:
diff changeset
38 F f; // expected-note {{non-trivial default constructor}}
anatofuz
parents:
diff changeset
39 };
anatofuz
parents:
diff changeset
40 int g = G().f.n; // expected-error {{call to implicitly-deleted default}}
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 struct H {
anatofuz
parents:
diff changeset
43 int n;
anatofuz
parents:
diff changeset
44 private:
anatofuz
parents:
diff changeset
45 H(); // expected-note {{here}}
anatofuz
parents:
diff changeset
46 };
anatofuz
parents:
diff changeset
47 int h = H().n; // expected-error {{private constructor}}
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 struct I {
anatofuz
parents:
diff changeset
50 H h; // expected-note {{inaccessible default constructor}}
anatofuz
parents:
diff changeset
51 };
anatofuz
parents:
diff changeset
52 int i = I().h.n; // expected-error {{call to implicitly-deleted default}}
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 struct J {
anatofuz
parents:
diff changeset
55 J();
anatofuz
parents:
diff changeset
56 virtual int f();
anatofuz
parents:
diff changeset
57 int n;
anatofuz
parents:
diff changeset
58 };
anatofuz
parents:
diff changeset
59 int j1 = J().n; // ok
anatofuz
parents:
diff changeset
60 int j2 = J().f(); // ok
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 union K {
anatofuz
parents:
diff changeset
63 J j; // expected-note 2{{non-trivial default constructor}}
anatofuz
parents:
diff changeset
64 int m;
anatofuz
parents:
diff changeset
65 };
anatofuz
parents:
diff changeset
66 int k1 = K().j.n; // expected-error {{call to implicitly-deleted default}}
anatofuz
parents:
diff changeset
67 int k2 = K().j.f(); // expected-error {{call to implicitly-deleted default}}