File: nvptx-address-spaces.c

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (21 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -fsyntax-only -verify

#define _AS0 __attribute__((address_space(0)))
#define _AS1 __attribute__((address_space(1)))
#define _AS2 __attribute__((address_space(2)))
#define _AS3 __attribute__((address_space(3)))
#define _AS4 __attribute__((address_space(4)))
#define _AS5 __attribute__((address_space(5)))
#define _AS999 __attribute__((address_space(999)))

void *p1(void _AS1 *p) { return p; }
void *p2(void _AS2 *p) { return p; } // expected-error {{returning '_AS2 void *' from a function with result type 'void *' changes address space of pointer}}
void *p3(void _AS3 *p) { return p; }
void *p4(void _AS4 *p) { return p; }
void *p5(void _AS5 *p) { return p; }
void *pi(void _AS999 *p) { return p; } // expected-error {{returning '_AS999 void *' from a function with result type 'void *' changes address space of pointer}}
void *pc(void __attribute__((opencl_local)) *p) { return p; } // expected-error {{returning '__local void *' from a function with result type 'void *' changes address space of pointer}}
void _AS1 *r0(void _AS1 *p) { return p; }
void _AS1 *r1(void *p) { return p; } // expected-error {{returning 'void *' from a function with result type '_AS1 void *' changes address space of pointer}}
void _AS1 *r2(void *p) { return (void _AS1 *)p; }