annotate clang/test/SemaCUDA/inherited-ctor.cu @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children
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 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // Inherit a valid non-default ctor.
anatofuz
parents:
diff changeset
4 namespace NonDefaultCtorValid {
anatofuz
parents:
diff changeset
5 struct A {
anatofuz
parents:
diff changeset
6 A(const int &x) {}
anatofuz
parents:
diff changeset
7 };
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 struct B : A {
anatofuz
parents:
diff changeset
10 using A::A;
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 struct C {
anatofuz
parents:
diff changeset
14 struct B b;
anatofuz
parents:
diff changeset
15 C() : b(0) {}
anatofuz
parents:
diff changeset
16 };
anatofuz
parents:
diff changeset
17
anatofuz
parents:
diff changeset
18 void test() {
anatofuz
parents:
diff changeset
19 B b(0);
anatofuz
parents:
diff changeset
20 C c;
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 // Inherit an invalid non-default ctor.
anatofuz
parents:
diff changeset
25 // The inherited ctor is invalid because it is unable to initialize s.
anatofuz
parents:
diff changeset
26 namespace NonDefaultCtorInvalid {
anatofuz
parents:
diff changeset
27 struct S {
anatofuz
parents:
diff changeset
28 S() = delete;
anatofuz
parents:
diff changeset
29 };
anatofuz
parents:
diff changeset
30 struct A {
anatofuz
parents:
diff changeset
31 A(const int &x) {}
anatofuz
parents:
diff changeset
32 };
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 struct B : A {
anatofuz
parents:
diff changeset
35 using A::A;
anatofuz
parents:
diff changeset
36 S s;
anatofuz
parents:
diff changeset
37 };
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 struct C {
anatofuz
parents:
diff changeset
40 struct B b;
anatofuz
parents:
diff changeset
41 C() : b(0) {} // expected-error{{constructor inherited by 'B' from base class 'A' is implicitly deleted}}
anatofuz
parents:
diff changeset
42 // expected-note@-6{{constructor inherited by 'B' is implicitly deleted because field 's' has a deleted corresponding constructor}}
anatofuz
parents:
diff changeset
43 // expected-note@-15{{'S' has been explicitly marked deleted here}}
anatofuz
parents:
diff changeset
44 };
anatofuz
parents:
diff changeset
45 }
anatofuz
parents:
diff changeset
46
anatofuz
parents:
diff changeset
47 // Inherit a valid default ctor.
anatofuz
parents:
diff changeset
48 namespace DefaultCtorValid {
anatofuz
parents:
diff changeset
49 struct A {
anatofuz
parents:
diff changeset
50 A() {}
anatofuz
parents:
diff changeset
51 };
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 struct B : A {
anatofuz
parents:
diff changeset
54 using A::A;
anatofuz
parents:
diff changeset
55 };
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 struct C {
anatofuz
parents:
diff changeset
58 struct B b;
anatofuz
parents:
diff changeset
59 C() {}
anatofuz
parents:
diff changeset
60 };
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 void test() {
anatofuz
parents:
diff changeset
63 B b;
anatofuz
parents:
diff changeset
64 C c;
anatofuz
parents:
diff changeset
65 }
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 // Inherit an invalid default ctor.
anatofuz
parents:
diff changeset
69 // The inherited ctor is invalid because it is unable to initialize s.
anatofuz
parents:
diff changeset
70 namespace DefaultCtorInvalid {
anatofuz
parents:
diff changeset
71 struct S {
anatofuz
parents:
diff changeset
72 S() = delete;
anatofuz
parents:
diff changeset
73 };
anatofuz
parents:
diff changeset
74 struct A {
anatofuz
parents:
diff changeset
75 A() {}
anatofuz
parents:
diff changeset
76 };
anatofuz
parents:
diff changeset
77
anatofuz
parents:
diff changeset
78 struct B : A {
anatofuz
parents:
diff changeset
79 using A::A;
anatofuz
parents:
diff changeset
80 S s;
anatofuz
parents:
diff changeset
81 };
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 struct C {
anatofuz
parents:
diff changeset
84 struct B b;
anatofuz
parents:
diff changeset
85 C() {} // expected-error{{call to implicitly-deleted default constructor of 'struct B'}}
anatofuz
parents:
diff changeset
86 // expected-note@-6{{default constructor of 'B' is implicitly deleted because field 's' has a deleted default constructor}}
anatofuz
parents:
diff changeset
87 // expected-note@-15{{'S' has been explicitly marked deleted here}}
anatofuz
parents:
diff changeset
88 };
anatofuz
parents:
diff changeset
89 }