| 1 | // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s |
| 2 | |
| 3 | void clang_analyzer_eval(bool); |
| 4 | |
| 5 | typedef __typeof__(sizeof(int)) size_t; |
| 6 | |
| 7 | |
| 8 | // These are ill-formed. One cannot return nullptr from a throwing version of an |
| 9 | // operator new. |
| 10 | void *operator new(size_t size) { |
| 11 | return nullptr; |
| 12 | } |
| 13 | void *operator new[](size_t size) { |
| 14 | return nullptr; |
| 15 | } |
| 16 | |
| 17 | struct S { |
| 18 | int x; |
| 19 | S() : x(1) {} |
| 20 | ~S() {} |
| 21 | }; |
| 22 | |
| 23 | void testArrays() { |
| 24 | S *s = new S[10]; // no-crash |
| 25 | s[0].x = 2; // expected-warning{{Dereference of null pointer}} |
| 26 | } |
| 27 | |