| 1 |
// RUN: %clang_analyze_cc1 -triple amdgcn-unknown-unknown \ |
| 2 |
// RUN: -Wno-incompatible-library-redeclaration \ |
| 3 |
// RUN: -analyzer-checker=core,unix -verify %s |
| 4 |
|
| 5 |
// expected-no-diagnostics |
| 6 |
// |
| 7 |
// By default, pointers are 64-bits. |
| 8 |
#define ADDRESS_SPACE_64BITS __attribute__((address_space(0))) |
| 9 |
#define ADDRESS_SPACE_32BITS __attribute__((address_space(3))) |
| 10 |
|
| 11 |
int test(ADDRESS_SPACE_32BITS int *p, ADDRESS_SPACE_32BITS void *q) { |
| 12 |
return p == q; // no-crash |
| 13 |
} |
| 14 |
|
| 15 |
// Make sure that the cstring checker handles non-default address spaces |
| 16 |
ADDRESS_SPACE_64BITS void * |
| 17 |
memcpy(ADDRESS_SPACE_64BITS void *, |
| 18 |
ADDRESS_SPACE_32BITS const void *, |
| 19 |
long unsigned int); |
| 20 |
|
| 21 |
ADDRESS_SPACE_64BITS struct { |
| 22 |
char m[16]; |
| 23 |
} n; |
| 24 |
|
| 25 |
void avoid_cstring_checker_crash(ADDRESS_SPACE_32BITS char *p) { |
| 26 |
memcpy(&n.m[0], p, 4); // no-crash |
| 27 |
} |