File: addrspace-constructors.clcpp

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (58 lines) | stat: -rw-r--r-- 1,945 bytes parent folder | download | duplicates (9)
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
48
49
50
51
52
53
54
55
56
57
58
// RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s

__constant int g1; // expected-error {{variable in constant address space must be initialized}}
__constant int g2 = 0;

struct X {
  int x;
//CHECK:  CXXConstructorDecl
//CHECK-NOT:  used
//CHECK-SAME: X 'void (){{.*}} __generic'
  X() /*__generic*/ : x(0) {}
//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __private'
  X() __private : x(0) {}
//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __global'
  X() __global : x(0) {}
  constexpr X() __constant : x(0) {}
  constexpr X(int x) __constant : x(x) {}
};

__global X gx;

//expected-note@+2{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const __generic Y' for 1st argument}}
//expected-note@+1{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to '__generic Y' for 1st argument}}
struct Y {
  int y;
  Y() __generic = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
};

kernel void k() {
  __constant X cx1;
  __constant X cx2(1);
  __local X lx;
  __private X x;

  __private X tx = X();

  __private Y py;
  __constant Y cy1; // expected-error{{variable in constant address space must be initialized}}
  __constant Y cy2(1); // expected-error{{no matching constructor for initialization of '__constant Y'}}
}

struct Z {
  int z;
  // The address space is deduced to be __generic if omitted
  Z() = default; // expected-note{{previous definition is here}}
  Z() __generic = default; // expected-error {{constructor cannot be redeclared}}

  Z() __private = default;
  Z() __local = default;
  Z() __global = default;
  // Can't default constexpr constructors
  constexpr Z() __constant : z(0) {}
};

struct W {
  int w;
  constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
};