1*67e74705SXin Li// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only 2*67e74705SXin Li 3*67e74705SXin Li__constant int ci = 1; 4*67e74705SXin Li 5*67e74705SXin Li__kernel void foo(__global int *gip) { 6*67e74705SXin Li __local int li; 7*67e74705SXin Li __local int lj = 2; // expected-error {{'__local' variable cannot have an initializer}} 8*67e74705SXin Li 9*67e74705SXin Li int *ip; 10*67e74705SXin Li ip = gip; // expected-error {{assigning '__global int *' to 'int *' changes address space of pointer}} 11*67e74705SXin Li ip = &li; // expected-error {{assigning '__local int *' to 'int *' changes address space of pointer}} 12*67e74705SXin Li ip = &ci; // expected-error {{assigning '__constant int *' to 'int *' changes address space of pointer}} 13*67e74705SXin Li} 14*67e74705SXin Li 15*67e74705SXin Livoid explicit_cast(global int* g, local int* l, constant int* c, private int* p, const constant int *cc) 16*67e74705SXin Li{ 17*67e74705SXin Li g = (global int*) l; // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}} 18*67e74705SXin Li g = (global int*) c; // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}} 19*67e74705SXin Li g = (global int*) cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}} 20*67e74705SXin Li g = (global int*) p; // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}} 21*67e74705SXin Li 22*67e74705SXin Li l = (local int*) g; // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}} 23*67e74705SXin Li l = (local int*) c; // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}} 24*67e74705SXin Li l = (local int*) cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}} 25*67e74705SXin Li l = (local int*) p; // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}} 26*67e74705SXin Li 27*67e74705SXin Li c = (constant int*) g; // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}} 28*67e74705SXin Li c = (constant int*) l; // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}} 29*67e74705SXin Li c = (constant int*) p; // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}} 30*67e74705SXin Li 31*67e74705SXin Li p = (private int*) g; // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}} 32*67e74705SXin Li p = (private int*) l; // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}} 33*67e74705SXin Li p = (private int*) c; // expected-error {{casting '__constant int *' to type 'int *' changes address space of pointer}} 34*67e74705SXin Li p = (private int*) cc; // expected-error {{casting 'const __constant int *' to type 'int *' changes address space of pointer}} 35*67e74705SXin Li} 36*67e74705SXin Li 37*67e74705SXin Livoid ok_explicit_casts(global int *g, global int* g2, local int* l, local int* l2, private int* p, private int* p2) 38*67e74705SXin Li{ 39*67e74705SXin Li g = (global int*) g2; 40*67e74705SXin Li l = (local int*) l2; 41*67e74705SXin Li p = (private int*) p2; 42*67e74705SXin Li} 43