Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / addrspace-null.c
blob54d96b277db04ff119c3da020fd0525724283d61
1 // RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
2 // RUN: -analyze -analyzer-checker=core -DAMDGCN_TRIPLE \
3 // RUN: -analyze -analyzer-checker=debug.ExprInspection \
4 // RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
5 //
6 // RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \
7 // RUN: -analyze -analyzer-checker=core -DDEFAULT_TRIPLE \
8 // RUN: -analyze -analyzer-checker=debug.ExprInspection \
9 // RUN: -Wno-implicit-int -Wno-int-conversion -verify %s
11 // From https://llvm.org/docs/AMDGPUUsage.html#address-spaces,
12 // select address space 3 (local), since the pointer size is
13 // different than Generic.
15 // expected-no-diagnostics
17 #define DEVICE __attribute__((address_space(3)))
19 #if defined(AMDGCN_TRIPLE)
20 // this crashes
21 int fn1() {
22 int val = 0;
23 DEVICE int *dptr = val;
24 return dptr == (void *)0;
27 // does not crash
28 int fn2() {
29 int val = 0;
30 DEVICE int *dptr = val;
31 return dptr == (DEVICE void *)0;
34 // this crashes
35 int fn3() {
36 int val = 0;
37 int *dptr = val;
38 return dptr == (DEVICE void *)0;
40 #endif
42 // does not crash
43 int fn4() {
44 int val = 0;
45 int *dptr = val;
46 return dptr == (void *)0;