Home | History | Annotate | Download | only in SemaOpenCL
      1 // RUN: %clang_cc1 -verify %s
      2 // RUN: %clang_cc1 -cl-std=CL2.0 -DCL20 -verify %s
      3 
      4 #define NULL ((void*)0)
      5 
      6 void foo(){
      7 
      8 global int* ptr1 = NULL;
      9 
     10 global int* ptr2 = (global void*)0;
     11 
     12 constant int* ptr3 = NULL;
     13 
     14 constant int* ptr4 = (global void*)0; // expected-error{{initializing '__constant int *' with an expression of type '__global void *' changes address space of pointer}}
     15 
     16 #ifdef CL20
     17 // Accept explicitly pointer to generic address space in OpenCL v2.0.
     18 global int* ptr5 = (generic void*)0;
     19 #endif
     20 
     21 global int* ptr6 = (local void*)0; // expected-error{{initializing '__global int *' with an expression of type '__local void *' changes address space of pointer}}
     22 
     23 bool cmp = ptr1 == NULL;
     24 
     25 cmp = ptr1 == (local void*)0; // expected-error{{comparison between  ('__global int *' and '__local void *') which are pointers to non-overlapping address spaces}}
     26 
     27 cmp = ptr3 == NULL;
     28 
     29 }
     30