[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / implicit-ctor-undef-value.cpp
blob87824c0533a0a36dc7a543c4056a9c08ba81a607
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
3 namespace implicit_constructor {
4 struct S {
5 public:
6 S() {}
7 S(const S &) {}
8 };
10 // Warning is in a weird position because the body of the constructor is
11 // missing. Specify which field is being assigned.
12 class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
13 // expected-note@-1{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
14 int x, y;
15 S s;
17 public:
18 C(): x(0) {}
21 void test() {
22 C c1;
23 C c2(c1); // expected-note{{Calling implicit copy constructor for 'C'}}
25 } // end namespace implicit_constructor
28 namespace explicit_constructor {
29 class C {
30 int x, y;
32 public:
33 C(): x(0) {}
34 // It is not necessary to specify which field is being assigned to.
35 C(const C &c):
36 x(c.x),
37 y(c.y) // expected-warning{{Assigned value is garbage or undefined}}
38 // expected-note@-1{{Assigned value is garbage or undefined}}
42 void test() {
43 C c1;
44 C c2(c1); // expected-note{{Calling copy constructor for 'C'}}
46 } // end namespace explicit_constructor
49 namespace base_class_constructor {
50 struct S {
51 public:
52 S() {}
53 S(const S &) {}
56 class C { // expected-warning{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
57 // expected-note@-1{{Value assigned to field 'y' in implicit constructor is garbage or undefined}}
58 int x, y;
59 S s;
61 public:
62 C(): x(0) {}
65 class D: public C {
66 public:
67 D(): C() {}
70 void test() {
71 D d1;
72 D d2(d1); // expected-note {{Calling implicit copy constructor for 'D'}}
73 // expected-note@-1{{Calling implicit copy constructor for 'C'}}
75 } // end namespace base_class_constructor