1// RUN: %clang_cc1 %s -pedantic -ast-dump -verify | FileCheck %s
2
3__constant int g1; // expected-error {{variable in constant address space must be initialized}}
4__constant int g2 = 0;
5
6struct X {
7  int x;
8//CHECK:  CXXConstructorDecl
9//CHECK-NOT:  used
10//CHECK-SAME: X 'void (){{.*}} __generic'
11  X() /*__generic*/ : x(0) {}
12//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __private'
13  X() __private : x(0) {}
14//CHECK: CXXConstructorDecl {{.*}} used X 'void (){{.*}} __global'
15  X() __global : x(0) {}
16  constexpr X() __constant : x(0) {}
17  constexpr X(int x) __constant : x(x) {}
18};
19
20__global X gx;
21
22//expected-note@+2{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const __generic Y' for 1st argument}}
23//expected-note@+1{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to '__generic Y' for 1st argument}}
24struct Y {
25  int y;
26  Y() __generic = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
27};
28
29kernel void k() {
30  __constant X cx1;
31  __constant X cx2(1);
32  __local X lx;
33  __private X x;
34
35  __private Y py;
36  __constant Y cy1; // expected-error{{variable in constant address space must be initialized}}
37  __constant Y cy2(1); // expected-error{{no matching constructor for initialization of '__constant Y'}}
38}
39
40struct Z {
41  int z;
42  // The address space is deduced to be __generic if omitted
43  Z() = default; // expected-note{{previous definition is here}}
44  Z() __generic = default; // expected-error {{constructor cannot be redeclared}}
45
46  Z() __private = default;
47  Z() __local = default;
48  Z() __global = default;
49  // Can't default constexpr constructors
50  constexpr Z() __constant : z(0) {}
51};
52
53struct W {
54  int w;
55  constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
56};
57