File: amdgpu-sizeof-alignof.cpp

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (47 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: %clang_cc1 -triple amdgcn---amdgiz -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTPTR_TYPE__ uintptr_t;
typedef __attribute__((address_space(1))) void *global_ptr_t;
typedef __attribute__((address_space(2))) void *constant_ptr_t;
typedef __attribute__((address_space(3))) void *local_ptr_t;
typedef __attribute__((address_space(5))) void *private_ptr_t;

void test() {
  static_assert(sizeof(size_t) == 8, "bad size");
  static_assert(alignof(size_t) == 8, "bad alignment");
  static_assert(sizeof(intptr_t) == 8, "bad size");
  static_assert(alignof(intptr_t) == 8, "bad alignment");
  static_assert(sizeof(uintptr_t) == 8, "bad size");
  static_assert(alignof(uintptr_t) == 8, "bad alignment");
  static_assert(sizeof(ptrdiff_t) == 8, "bad size");
  static_assert(alignof(ptrdiff_t) == 8, "bad alignment");

  static_assert(sizeof(char) == 1, "bad size");
  static_assert(alignof(char) == 1, "bad alignment");
  static_assert(sizeof(short) == 2, "bad size");
  static_assert(alignof(short) == 2, "bad alignment");
  static_assert(sizeof(int) == 4, "bad size");
  static_assert(alignof(int) == 4, "bad alignment");
  static_assert(sizeof(long) == 8, "bad size");
  static_assert(alignof(long) == 8, "bad alignment");
  static_assert(sizeof(long long) == 8, "bad size");
  static_assert(alignof(long long) == 8, "bad alignment");
  static_assert(sizeof(float) == 4, "bad size");
  static_assert(alignof(float) == 4, "bad alignment");
  static_assert(sizeof(double) == 8, "bad size");
  static_assert(alignof(double) == 8, "bad alignment");

  static_assert(sizeof(void*) == 8, "bad size");
  static_assert(alignof(void*) == 8, "bad alignment");
  static_assert(sizeof(global_ptr_t) == 8, "bad size");
  static_assert(alignof(global_ptr_t) == 8, "bad alignment");
  static_assert(sizeof(constant_ptr_t) == 8, "bad size");
  static_assert(alignof(constant_ptr_t) == 8, "bad alignment");
  static_assert(sizeof(local_ptr_t) == 4, "bad size");
  static_assert(alignof(local_ptr_t) == 4, "bad alignment");
  static_assert(sizeof(private_ptr_t) == 4, "bad size");
  static_assert(alignof(private_ptr_t) == 4, "bad alignment");
}