Changeset View
Changeset View
Standalone View
Standalone View
clang/test/SemaOpenCLCXX/address-space-references.clcpp
Show All 16 Lines | public: | ||||
void glob(__global const short2 &); //expected-note{{passing argument to parameter here}} | void glob(__global const short2 &); //expected-note{{passing argument to parameter here}} | ||||
void nested_list(const short2 (&)[2]); | void nested_list(const short2 (&)[2]); | ||||
}; | }; | ||||
void foo() { | void foo() { | ||||
bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}} | bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}} | ||||
C c; | C c; | ||||
c.gen({1, 2}); | c.gen({1, 2}); | ||||
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}} | c.glob({1, 2}); //expected-error{{binding reference of type 'const __global short2' (vector of 2 'short' values) to value of type '<dependent type>' changes address space}} | ||||
aaronpuchert: Somehow we seem to fail matching the initializer list, but not report that, only on type… | |||||
c.nested_list({{1, 2}, {3, 4}}); | c.nested_list({{1, 2}, {3, 4}}); | ||||
} | } | ||||
// Test addr space conversion with nested pointers | // Test addr space conversion with nested pointers | ||||
extern void nestptr(int *&); // expected-note {{candidate function not viable: no known conversion from '__global int *__private' to '__generic int *__generic &__private' for 1st argument}} | extern void nestptr(int *&); // expected-note {{candidate function not viable: no known conversion from '__global int *__private' to '__generic int *__generic &__private' for 1st argument}} | ||||
extern 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}} | extern 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}} | ||||
int test_nestptr(__global int *glob, __constant int *cons, int* gen) { | int test_nestptr(__global int *glob, __constant int *cons, int* gen) { | ||||
nestptr(glob); // expected-error{{no matching function for call to 'nestptr'}} | nestptr(glob); // expected-error{{no matching function for call to 'nestptr'}} | ||||
// Addr space conversion first occurs on a temporary. | // Addr space conversion first occurs on a temporary. | ||||
nestptr_const(glob); | nestptr_const(glob); | ||||
// No legal conversion between disjoint addr spaces. | // No legal conversion between disjoint addr spaces. | ||||
nestptr_const(cons); // expected-error{{no matching function for call to 'nestptr_const'}} | nestptr_const(cons); // expected-error{{no matching function for call to 'nestptr_const'}} | ||||
return *(*cons ? glob : gen); | return *(*cons ? glob : gen); | ||||
} | } |
Somehow we seem to fail matching the initializer list, but not report that, only on type mismatch later. I think we should either go through with the initialization, then have a short __attribute__((ext_vector_type(2))) and complain that we can't bind the reference to that, or complain when processing the initializer list.
But that's unrelated to this change, void was also not correct.