Skip to content

Commit 6b86a04

Browse files
committed
add user defined new test cpp
1 parent e590bfc commit 6b86a04

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// RUN: %clang_analyze_cc1 -w -verify %s\
2+
// RUN: -analyzer-checker=core\
3+
// RUN: -analyzer-checker=debug.ExprInspection -std=c++17
4+
// RUN: %clang_analyze_cc1 -w -verify %s\
5+
// RUN: -analyzer-checker=core\
6+
// RUN: -analyzer-checker=debug.ExprInspection -std=c++11\
7+
// RUN: -DTEST_INLINABLE_ALLOCATORS
8+
// RUN: %clang_analyze_cc1 -w -verify %s\
9+
// RUN: -analyzer-checker=core,\
10+
// RUN: -analyzer-checker=debug.ExprInspection -std=c++17\
11+
// RUN: -DTEST_INLINABLE_ALLOCATORS
12+
13+
void clang_analyzer_eval(bool);
14+
15+
typedef __typeof(sizeof(int)) size_t;
16+
17+
namespace CustomClassType {
18+
struct S {
19+
int x;
20+
static void* operator new(size_t size) {
21+
return ::operator new(size);
22+
}
23+
};
24+
void F() {
25+
S *s = new S;
26+
clang_analyzer_eval(s->x); // expected-warning{{UNKNOWN}} FIXME: should be an undefined warning
27+
28+
S *s2 = new S{};
29+
clang_analyzer_eval(0 == s2->x); // expected-warning{{TRUE}}
30+
31+
S *s3 = new S{1};
32+
clang_analyzer_eval(1 == s3->x); // expected-warning{{TRUE}}
33+
}
34+
35+
struct WithPlacementNew {
36+
};
37+
38+
} // namespace CustomClassType

0 commit comments

Comments
 (0)