diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-12-05 17:02:22 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-12-05 17:02:22 +0000 |
commit | 12e3a8af81da5f55381a47fada6f76a63ca735ce (patch) | |
tree | f5f746686518c16a19617550fc097056c4c12f55 /clang/test | |
parent | 4ead99b3ac2a0ccd5174c35bcf339eb080dd9697 (diff) | |
download | bcm5719-llvm-12e3a8af81da5f55381a47fada6f76a63ca735ce.tar.gz bcm5719-llvm-12e3a8af81da5f55381a47fada6f76a63ca735ce.zip |
[OpenCL] Diagnose conflicting address spaces in templates.
Added new diagnostic when templates are instantiated with
different address space from the one provided in its definition.
This also prevents deducing generic address space in pointer
type of templates to allow giving them concrete address space
during instantiation.
Differential Revision: https://reviews.llvm.org/D55127
llvm-svn: 348382
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaOpenCLCXX/address-space-templates.cl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/SemaOpenCLCXX/address-space-templates.cl b/clang/test/SemaOpenCLCXX/address-space-templates.cl index 780175bf2b9..48fbdc7642d 100644 --- a/clang/test/SemaOpenCLCXX/address-space-templates.cl +++ b/clang/test/SemaOpenCLCXX/address-space-templates.cl @@ -7,6 +7,25 @@ struct S { void f2(T); // expected-error{{parameter may not be qualified with an address space}} }; +template <typename T> +T foo1(__global T *i) { // expected-note{{candidate template ignored: substitution failure [with T = __local int]: conflicting address space qualifiers are provided between types '__global T' and '__local int'}} + return *i; +} + +template <typename T> +T *foo2(T *i) { + return i; +} + +template <typename T> +void foo3() { + __private T ii; // expected-error{{conflicting address space qualifiers are provided between types 'T' and '__global int'}} +} + void bar() { S<const __global int> sintgl; // expected-note{{in instantiation of template class 'S<const __global int>' requested here}} + + foo1<__local int>(1); // expected-error{{no matching function for call to 'foo1'}} + foo2<__global int>(0); + foo3<__global int>(); // expected-note{{in instantiation of function template specialization 'foo3<__global int>' requested here}} } |