1 // RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \ 2 // RUN: -analyzer-checker=core -DAMDGCN_TRIPLE \ 3 // RUN: -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: -analyzer-checker=core -DDEFAULT_TRIPLE \ 8 // RUN: -analyzer-checker=debug.ExprInspection \ 9 // RUN: -Wno-implicit-int -Wno-int-conversion -verify %s 10 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. 14 15 // expected-no-diagnostics 16 17 #define DEVICE __attribute__((address_space(3))) 18 19 #if defined(AMDGCN_TRIPLE) 20 // this crashes fn1()21int fn1() { 22 int val = 0; 23 DEVICE int *dptr = val; 24 return dptr == (void *)0; 25 } 26 27 // does not crash fn2()28int fn2() { 29 int val = 0; 30 DEVICE int *dptr = val; 31 return dptr == (DEVICE void *)0; 32 } 33 34 // this crashes fn3()35int fn3() { 36 int val = 0; 37 int *dptr = val; 38 return dptr == (DEVICE void *)0; 39 } 40 #endif 41 42 // does not crash fn4()43int fn4() { 44 int val = 0; 45 int *dptr = val; 46 return dptr == (void *)0; 47 } 48