1// RUN: %clang_cc1 %s -pedantic -verify -fsyntax-only 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 constexpr X() __constant : x(0) {} 9 constexpr X(int x) __constant : x(x) {} 10}; 11 12//expected-note@+2{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const __generic Y' for 1st argument}} 13//expected-note@+1{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to '__generic Y' for 1st argument}} 14struct Y { 15 int y; 16 Y() __generic = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}} 17}; 18 19kernel void k() { 20 __constant X cx1; 21 __constant X cx2(1); 22 __local X lx; 23 24 __private Y py; 25 __constant Y cy1; // expected-error{{variable in constant address space must be initialized}} 26 __constant Y cy2(1); // expected-error{{no matching constructor for initialization of '__constant Y'}} 27} 28 29struct Z { 30 int z; 31 // The address space is deduced to be __generic if omitted 32 Z() = default; // expected-note{{previous definition is here}} 33 Z() __generic = default; // expected-error {{constructor cannot be redeclared}} 34 35 Z() __private = default; 36 Z() __local = default; 37 Z() __global = default; 38 // Can't default constexpr constructors 39 constexpr Z() __constant : z(0) {} 40}; 41 42struct W { 43 int w; 44 constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}} 45}; 46