aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2019-08-14 12:53:30 +0000
committerHans Wennborg <hans@hanshq.net>2019-08-14 12:53:30 +0000
commit58f7938ba52bb7ed982a3846ab3a7c467d56537e (patch)
treeeb36bd90dafd846893da52a8a3d68c6efbecbbeb
parent63e5b5db918f0594491f854fd74b41c813030175 (diff)
Merging r368561:
------------------------------------------------------------------------ r368561 | svenvh | 2019-08-12 14:44:26 +0200 (Mon, 12 Aug 2019) | 9 lines [OpenCL] Ignore parentheses for sampler initialization The sampler handling logic in SemaInit.cpp would inadvertently treat parentheses around sampler arguments as an implicit cast, leading to an unreachable "can't implicitly cast lvalue to rvalue with this cast kind". Fix by ignoring parentheses once we are in the sampler initializer case. Differential Revision: https://reviews.llvm.org/D66080 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_90@368843 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaInit.cpp2
-rw-r--r--test/SemaOpenCL/sampler_t.cl7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 85af4bc492..60f34775c6 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -8116,7 +8116,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
// argument passing.
assert(Step->Type->isSamplerT() &&
"Sampler initialization on non-sampler type.");
- Expr *Init = CurInit.get();
+ Expr *Init = CurInit.get()->IgnoreParens();
QualType SourceType = Init->getType();
// Case 1
if (Entity.isParameterKind()) {
diff --git a/test/SemaOpenCL/sampler_t.cl b/test/SemaOpenCL/sampler_t.cl
index 28e7a0ad27..fe9d997c89 100644
--- a/test/SemaOpenCL/sampler_t.cl
+++ b/test/SemaOpenCL/sampler_t.cl
@@ -10,6 +10,9 @@
#define CLK_FILTER_NEAREST 0x10
#define CLK_FILTER_LINEAR 0x20
+typedef float float4 __attribute__((ext_vector_type(4)));
+float4 read_imagef(read_only image1d_t, sampler_t, float);
+
constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}} expected-error {{global sampler requires a const or constant address space qualifier}}
@@ -74,3 +77,7 @@ void bar() {
foo(smp1+1); //expected-error{{invalid operands to binary expression ('sampler_t' and 'int')}}
}
+void smp_args(read_only image1d_t image) {
+ // Test that parentheses around sampler arguments are ignored.
+ float4 res = read_imagef(image, (glb_smp10), 0.0f);
+}