echuraev updated this revision to Diff 94032.
echuraev marked an inline comment as done.
https://reviews.llvm.org/D31594
Files:
lib/Sema/SemaInit.cpp
test/CodeGenOpenCL/sampler.cl
test/SemaOpenCL/sampler_t.cl
Index: test/SemaOpenCL/sampler_t.cl
===================================================================
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -30,7 +30,7 @@
constant sampler_t glb_smp9 = 0x100000000LL; // expected-error{{sampler_t
initialization requires 32-bit integer, not 'long long'}}
-void foo(sampler_t);
+void foo(sampler_t); // expected-note{{passing argument to parameter here}}
constant struct sampler_s {
sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to
declare a structure or union field}}
@@ -65,7 +65,8 @@
foo(const_smp5);
foo(const_smp6);
foo(argsmp);
- foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+ foo(5);
+ foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible
type 'sampler_t'}}
sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of
'sampler_t' type is invalid in OpenCL}}
foo(sa[0]);
foo(bad());
Index: test/CodeGenOpenCL/sampler.cl
===================================================================
--- test/CodeGenOpenCL/sampler.cl
+++ test/CodeGenOpenCL/sampler.cl
@@ -54,4 +54,8 @@
fnc4smp(smp_par);
// CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*,
%opencl.sampler_t addrspace(2)** [[smp_par_ptr]]
// CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)*
[[SAMP]])
+
+ fnc4smp(5);
+ // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)*
@__translate_sampler_initializer(i32 5)
+ // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)*
[[SAMP]])
}
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7174,7 +7174,7 @@
QualType SourceType = Init->getType();
// Case 1
if (Entity.isParameterKind()) {
- if (!SourceType->isSamplerT()) {
+ if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
<< SourceType;
break;
Index: test/SemaOpenCL/sampler_t.cl
===================================================================
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -30,7 +30,7 @@
constant sampler_t glb_smp9 = 0x100000000LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}}
-void foo(sampler_t);
+void foo(sampler_t); // expected-note{{passing argument to parameter here}}
constant struct sampler_s {
sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}}
@@ -65,7 +65,8 @@
foo(const_smp5);
foo(const_smp6);
foo(argsmp);
- foo(5); // expected-error{{sampler_t variable required - got 'int'}}
+ foo(5);
+ foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible type 'sampler_t'}}
sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
foo(sa[0]);
foo(bad());
Index: test/CodeGenOpenCL/sampler.cl
===================================================================
--- test/CodeGenOpenCL/sampler.cl
+++ test/CodeGenOpenCL/sampler.cl
@@ -54,4 +54,8 @@
fnc4smp(smp_par);
// CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_par_ptr]]
// CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
+
+ fnc4smp(5);
+ // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5)
+ // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
}
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7174,7 +7174,7 @@
QualType SourceType = Init->getType();
// Case 1
if (Entity.isParameterKind()) {
- if (!SourceType->isSamplerT()) {
+ if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) {
S.Diag(Kind.getLocation(), diag::err_sampler_argument_required)
<< SourceType;
break;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits