[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Analysis / pointer-arithmetic.c
blob3851701e10cc3b126c919672fd4dfa6890c67bf1
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
3 int test1(void) {
4 int *p = (int *)sizeof(int);
5 p -= 1;
6 return *p; // expected-warning {{Dereference of null pointer}}
9 int test2(void) {
10 int *p = (int *)sizeof(int);
11 p -= 2;
12 p += 1;
13 return *p; // expected-warning {{Dereference of null pointer}}
16 int test3(void) {
17 int *p = (int *)sizeof(int);
18 p++;
19 p--;
20 p--;
21 return *p; // expected-warning {{Dereference of null pointer}}
24 int test4(void) {
25 // This is a special case where pointer arithmetic is not calculated to
26 // preserve useful warnings on dereferences of null pointers.
27 int *p = 0;
28 p += 1;
29 return *p; // expected-warning {{Dereference of null pointer}}