Dominic Chen | 184c624 | 2017-03-03 18:02:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s |
Anna Zaks | 3849dea | 2015-06-26 17:42:58 +0000 | [diff] [blame] | 2 | |
| 3 | #include "test-include.h" |
| 4 | #define DIVYX(X,Y) Y/X |
| 5 | |
| 6 | void test_01(int *data) { |
| 7 | data = 0; |
| 8 | *data = 1; // expected-warning{{Dereference of null pointer}} |
| 9 | } |
| 10 | |
| 11 | int test_02() { |
| 12 | int res = DIVXY(1,0); // expected-warning{{Division by zero}} |
| 13 | // expected-warning@-1{{division by zero is undefined}} |
| 14 | return res; |
| 15 | } |
| 16 | |
| 17 | int test_03() { |
| 18 | int res = DIVYX(0,1); // expected-warning{{Division by zero}} |
| 19 | // expected-warning@-1{{division by zero is undefined}} |
| 20 | return res; |
| 21 | } |