1 // RUN: %clang_analyze_cc1 -analyzer-checker=core.NullDereference,core.uninitialized.UndefReturn -std=c++11 %s -verify -o /dev/null
3 void test_static_assert() {
4 static_assert(sizeof(void *) == sizeof(void*), "test_static_assert");
7 void test_analyzer_working() {
9 *p
= 0xDEADBEEF; // expected-warning {{null}}
12 // Test that pointer-to-member functions don't cause the analyzer
18 typedef void (RDar10243398::*RDar10243398MemberFn
)(int x
);
20 void test_rdar10243398(RDar10243398
*p
) {
21 RDar10243398MemberFn q
= &RDar10243398::bar
;
25 // Tests for CXXTemporaryObjectExpr.
30 // Test to see if CXXTemporaryObjectExpr is being handled.
37 return i
; // expected-warning {{Undefined or garbage value returned to caller}}
40 // Test to see if CXXTemporaryObjectExpr invalidates arguments.
46 return j
; // no-warning
50 // Test for correct handling of C++ ForRange statement.
52 int array
[2] = { 1, 2 };
57 *p
= 0xDEADBEEF; // expected-warning {{null}}
61 int array
[2] = { 1, 2 };
68 *p
= 0xDEADBEEF; // no-warning
71 // Do not crash on the following when constructing the
74 ~RDar11178609() = delete;
77 // Tests that dynamic_cast handles references to C++ classes. Previously
79 class rdar11817693_BaseBase
{};
80 class rdar11817693_BaseInterface
{};
81 class rdar11817693_Base
: public rdar11817693_BaseBase
, public rdar11817693_BaseInterface
{};
82 class rdar11817693
: public rdar11817693_Base
{
83 virtual void operator=(const rdar11817693_BaseBase
& src
);
84 void operator=(const rdar11817693
& src
);
86 void rdar11817693::operator=(const rdar11817693
& src
) {
87 operator=(dynamic_cast<const rdar11817693_BaseBase
&>(src
));