[PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator

Igor Chesnokov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 08:01:09 PST 2016


ichesnokov removed rL LLVM as the repository for this revision.
ichesnokov updated this revision to Diff 46655.
ichesnokov added a comment.

Test cases moved to single file.
Please review and accept.


http://reviews.llvm.org/D16682

Files:
  test/SemaOpenCL/ternary-implicit-casts.cl

Index: test/SemaOpenCL/ternary-implicit-casts.cl
===================================================================
--- test/SemaOpenCL/ternary-implicit-casts.cl
+++ test/SemaOpenCL/ternary-implicit-casts.cl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+kernel void implicit_cast_local(global int* gint, local int* lint, int cond)
+{
+	// will not compile, ptr is not generic but local
+  local int *ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} expected-error {{initializing '__local int *' with an expression of type 'void *' changes address space of pointer}}
+}
+
+kernel void implicit_cast_generic(global int* gint, local int* lint, int cond) {
+	// will compile, ptr is generic and can accept global and local
+	int* ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}}
+} 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16682.46655.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160202/594ff604/attachment.bin>


More information about the cfe-commits mailing list