1 // RUN: %clang_cc1 -fsyntax-only -analyze \
2 // RUN: -analyzer-checker=core,debug.ExprInspection %s -verify
4 // These test cases demonstrate lack of Static Analyzer features.
5 // The FIXME: tags indicate where we expect different output.
7 // Handle constructors within new[].
9 // When an array of objects is allocated using the operator new[],
10 // constructors for all elements of the array are called.
11 // We should model (potentially some of) such evaluations,
12 // and the same applies for destructors called from operator delete[].
14 void clang_analyzer_eval(bool);
16 struct init_with_list
{
18 init_with_list() : a(1) {}
23 init_in_body() { a
= 1; }
26 struct init_default_member
{
30 void test_automatic() {
34 init_default_member a3
;
36 clang_analyzer_eval(a1
.a
== 1); // expected-warning {{TRUE}}
37 clang_analyzer_eval(a2
.a
== 1); // expected-warning {{TRUE}}
38 clang_analyzer_eval(a3
.a
== 1); // expected-warning {{TRUE}}
43 auto *a1
= new init_with_list
;
44 auto *a2
= new init_in_body
;
45 auto *a3
= new init_default_member
;
47 clang_analyzer_eval(a1
->a
== 1); // expected-warning {{TRUE}}
48 clang_analyzer_eval(a2
->a
== 1); // expected-warning {{TRUE}}
49 clang_analyzer_eval(a3
->a
== 1); // expected-warning {{TRUE}}
56 void test_automatic_aggregate() {
60 init_default_member a3
[1];
62 // FIXME: Should be TRUE, not FALSE.
63 clang_analyzer_eval(a1
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}
64 // FIXME: Should be TRUE, not FALSE.
65 clang_analyzer_eval(a2
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}
66 // FIXME: Should be TRUE, not FALSE.
67 clang_analyzer_eval(a3
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}
70 void test_dynamic_aggregate() {
72 auto *a1
= new init_with_list
[1];
73 auto *a2
= new init_in_body
[1];
74 auto *a3
= new init_default_member
[1];
76 // FIXME: Should be TRUE, not FALSE.
77 clang_analyzer_eval(a1
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}
78 // FIXME: Should be TRUE, not FALSE.
79 clang_analyzer_eval(a2
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}
80 // FIXME: Should be TRUE, not FALSE.
81 clang_analyzer_eval(a3
[0].a
== 1); // expected-warning {{TRUE}} expected-warning {{FALSE}}