1 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core \
2 // RUN: -analyzer-config suppress-null-return-paths=false \
4 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core \
8 void clang_analyzer_eval(bool);
10 typedef __typeof__(sizeof(int)) size_t;
13 // These are ill-formed. One cannot return nullptr from a throwing version of an
15 void *operator new(size_t size
) {
17 // expected-warning@-1 {{'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}
18 // expected-warning@-2 {{null returned from function that requires a non-null return value}}
20 void *operator new[](size_t size
) {
22 // expected-warning@-1 {{'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}
23 // expected-warning@-2 {{null returned from function that requires a non-null return value}}
30 int getX() const { return x
; }
34 S
*s
= new S
[10]; // no-crash
37 // expected-warning@-2 {{Dereference of null pointer}}
45 // expected-warning@-2 {{Access to field 'x' results in a dereference of a null pointer (loaded from variable 's')}}
51 const int X
= s
->getX();
53 // expected-warning@-2 {{Called C++ object pointer is null}}