brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 259d1e2 Raw
48 lines · c
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 %s5//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 %s10 11// From https://llvm.org/docs/AMDGPUUsage.html#address-spaces,12// select address space 3 (local), since the pointer size is13// different than Generic.14 15// expected-no-diagnostics16 17#define DEVICE __attribute__((address_space(3)))18 19#if defined(AMDGCN_TRIPLE)20// this crashes21int fn1() {22  int val = 0;23  DEVICE int *dptr = val;24  return dptr == (void *)0;25}26 27// does not crash28int fn2() {29  int val = 0;30  DEVICE int *dptr = val;31  return dptr == (DEVICE void *)0;32}33 34// this crashes35int fn3() {36  int val = 0;37  int *dptr = val;38  return dptr == (DEVICE void *)0;39}40#endif41 42// does not crash43int fn4() {44  int val = 0;45  int *dptr = val;46  return dptr == (void *)0;47}48