1// RUN: %clang_cc1 %s -triple spir-unknown-unknown -pedantic -verify -fsyntax-only 2 3__global const int& f(__global float &ref) { 4 return ref; // expected-error{{reference of type 'const __global int &' cannot bind to a temporary object because of address space mismatch}} 5} 6 7int bar(const __global unsigned int &i); // expected-note{{passing argument to parameter 'i' here}} 8//FIXME: With the overload below the call should be resolved 9// successfully. However, current overload resolution logic 10// can't detect this case and therefore fails. 11int bar(const unsigned int &i); 12 13typedef short short2 __attribute__((ext_vector_type(2))); 14class C { 15public: 16 void gen(const short2 &); 17 void glob(__global const short2 &); //expected-note{{passing argument to parameter here}} 18 void nested_list(const short2 (&)[2]); 19}; 20 21void foo() { 22 bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}} 23 C c; 24 c.gen({1, 2}); 25 c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type 'void' changes address space}} 26 c.nested_list({{1, 2}, {3, 4}}); 27} 28 29// Test addr space conversion with nested pointers 30 31extern void nestptr(int *&); // expected-note {{candidate function not viable: no known conversion from '__global int *__private' to '__generic int *__generic &__private' for 1st argument}} 32extern void nestptr_const(int * const &); // expected-note {{candidate function not viable: cannot pass pointer to address space '__constant' as a pointer to address space '__generic' in 1st argument}} 33int test_nestptr(__global int *glob, __constant int *cons, int* gen) { 34 nestptr(glob); // expected-error{{no matching function for call to 'nestptr'}} 35 // Addr space conversion first occurs on a temporary. 36 nestptr_const(glob); 37 // No legal conversion between disjoint addr spaces. 38 nestptr_const(cons); // expected-error{{no matching function for call to 'nestptr_const'}} 39 return *(*cons ? glob : gen); 40} 41