1// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0 2// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0 3// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0 4// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++ 5// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++ 6// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++ 7// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space 8// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space 9// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space 10 11/* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to 12* different address spaces, mainly described in Sections 6.5.5 and 6.5.6. 13* 14* It adds notion of overlapping address spaces. The main differention is that 15* an unnamed address space is added, called '__generic'. Pointers to the 16* generic address space can be interchangabley used with pointers to any 17* other address space except for __constant address space (Section 6.5.5). 18* 19* Based on this there are 3 sets of tests: __generic, named (__global in this 20* case), and __constant, that should cover all program paths for CL address 21* space conversions used in initialisations, assignments, casts, comparisons 22* and arithmetic operations. 23* 24* OpenCLC v3.0 supports generic address if __opencl_c_generic_address_space feature is supported 25*/ 26 27#ifdef GENERIC 28#define AS __generic 29#define AS_COMP __local 30#define AS_INCOMP __constant 31#endif 32 33#ifdef GLOBAL 34#define AS __global 35#define AS_COMP __global 36#define AS_INCOMP __local 37#endif 38 39#ifdef CONSTANT 40#define AS __constant 41#define AS_COMP __constant 42#define AS_INCOMP __global 43#endif 44 45void f_glob(__global int *arg_glob) {} 46#ifndef GLOBAL 47#if !__OPENCL_CPP_VERSION__ 48// expected-note@-3{{passing argument to parameter 'arg_glob' here}} 49#else 50// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{generic|constant}}' as a pointer to address space '__global' in 1st argument}} 51#endif 52#endif 53 54void f_loc(__local int *arg_loc) {} 55#if !__OPENCL_CPP_VERSION__ 56// expected-note@-2{{passing argument to parameter 'arg_loc' here}} 57#else 58// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space '__{{global|generic|constant}}' as a pointer to address space '__local' in 1st argument}} 59#endif 60 61void f_const(__constant int *arg_const) {} 62#ifndef CONSTANT 63#if !__OPENCL_CPP_VERSION__ 64// expected-note@-3{{passing argument to parameter 'arg_const' here}} 65#else 66// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{global|generic}}' as a pointer to address space '__constant' in 1st argument}} 67#endif 68#endif 69 70void f_priv(__private int *arg_priv) {} 71#if !__OPENCL_CPP_VERSION__ 72// expected-note@-2{{passing argument to parameter 'arg_priv' here}} 73#else 74// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space '__{{global|generic|constant}}' as a pointer to address space '__private' in 1st argument}} 75#endif 76 77void f_gen(__generic int *arg_gen) {} 78#ifdef CONSTANT 79#if !__OPENCL_CPP_VERSION__ 80// expected-note@-3{{passing argument to parameter 'arg_gen' here}} 81#else 82// expected-note@-5{{candidate function not viable: cannot pass pointer to address space '__constant' as a pointer to address space '__generic' in 1st argument}} 83#endif 84#endif 85 86void test_conversion(__global int *arg_glob, __local int *arg_loc, 87 __constant int *arg_const, __private int *arg_priv, 88 __generic int *arg_gen) { 89 90 AS int *var_init1 = arg_glob; 91#ifdef CONSTANT 92#if !__OPENCL_CPP_VERSION__ 93// expected-error@-3{{initializing '__constant int *__private' with an expression of type '__global int *__private' changes address space of pointer}} 94#else 95// expected-error@-5{{cannot initialize a variable of type '__constant int *__private' with an lvalue of type '__global int *__private'}} 96#endif 97#endif 98 99 AS int *var_init2 = arg_loc; 100#ifndef GENERIC 101#if !__OPENCL_CPP_VERSION__ 102// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__local int *__private' changes address space of pointer}} 103#else 104// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__local int *__private'}} 105#endif 106#endif 107 108 AS int *var_init3 = arg_const; 109#ifndef CONSTANT 110#if !__OPENCL_CPP_VERSION__ 111// expected-error-re@-3{{initializing '__{{global|generic}} int *__private' with an expression of type '__constant int *__private' changes address space of pointer}} 112#else 113// expected-error-re@-5{{cannot initialize a variable of type '__{{global|generic}} int *__private' with an lvalue of type '__constant int *__private'}} 114#endif 115#endif 116 117 AS int *var_init4 = arg_priv; 118#ifndef GENERIC 119#if !__OPENCL_CPP_VERSION__ 120// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__private int *__private' changes address space of pointer}} 121#else 122// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__private int *__private'}} 123#endif 124#endif 125 126 AS int *var_init5 = arg_gen; 127#ifndef GENERIC 128#if !__OPENCL_CPP_VERSION__ 129// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__generic int *__private' changes address space of pointer}} 130#else 131// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__generic int *__private'}} 132#endif 133#endif 134 135 AS int *var_cast1 = (AS int *)arg_glob; 136#ifdef CONSTANT 137#if !__OPENCL_CPP_VERSION__ 138// expected-error@-3{{casting '__global int *' to type '__constant int *' changes address space of pointer}} 139#else 140// expected-error@-5{{C-style cast from '__global int *' to '__constant int *' converts between mismatching address spaces}} 141#endif 142#endif 143 144 AS int *var_cast2 = (AS int *)arg_loc; 145#ifndef GENERIC 146#if !__OPENCL_CPP_VERSION__ 147// expected-error-re@-3{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}} 148#else 149// expected-error-re@-5{{C-style cast from '__local int *' to '__{{global|constant}} int *' converts between mismatching address spaces}} 150#endif 151#endif 152 153 AS int *var_cast3 = (AS int *)arg_const; 154#ifndef CONSTANT 155#if !__OPENCL_CPP_VERSION__ 156// expected-error-re@-3{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}} 157#else 158// expected-error-re@-5{{C-style cast from '__constant int *' to '__{{global|generic}} int *' converts between mismatching address spaces}} 159#endif 160#endif 161 162 AS int *var_cast4 = (AS int *)arg_priv; 163#ifndef GENERIC 164#if !__OPENCL_CPP_VERSION__ 165// expected-error-re@-3{{casting '__private int *' to type '__{{global|constant}} int *' changes address space of pointer}} 166#else 167// expected-error-re@-5{{C-style cast from '__private int *' to '__{{global|constant}} int *' converts between mismatching address spaces}} 168#endif 169#endif 170 171 AS int *var_cast5 = (AS int *)arg_gen; 172#ifdef CONSTANT 173#if !__OPENCL_CPP_VERSION__ 174// expected-error@-3{{casting '__generic int *' to type '__constant int *' changes address space of pointer}} 175#else 176// expected-error@-5{{C-style cast from '__generic int *' to '__constant int *' converts between mismatching address spaces}} 177#endif 178#endif 179 180 AS int *var_impl; 181 var_impl = arg_glob; 182#ifdef CONSTANT 183#if !__OPENCL_CPP_VERSION__ 184// expected-error@-3{{assigning '__global int *__private' to '__constant int *__private' changes address space of pointer}} 185#else 186// expected-error@-5{{assigning '__global int *__private' to '__constant int *' changes address space of pointer}} 187#endif 188#endif 189 190 var_impl = arg_loc; 191#ifndef GENERIC 192#if !__OPENCL_CPP_VERSION__ 193// expected-error-re@-3{{assigning '__local int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}} 194#else 195// expected-error-re@-5{{assigning '__local int *__private' to '__{{global|constant}} int *' changes address space of pointer}} 196#endif 197#endif 198 199 var_impl = arg_const; 200#ifndef CONSTANT 201#if !__OPENCL_CPP_VERSION__ 202// expected-error-re@-3{{assigning '__constant int *__private' to '__{{global|generic}} int *__private' changes address space of pointer}} 203#else 204// expected-error-re@-5{{assigning '__constant int *__private' to '__{{global|generic}} int *' changes address space of pointer}} 205#endif 206#endif 207 208 var_impl = arg_priv; 209#ifndef GENERIC 210#if !__OPENCL_CPP_VERSION__ 211// expected-error-re@-3{{assigning '__private int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}} 212#else 213// expected-error-re@-5{{assigning '__private int *__private' to '__{{global|constant}} int *' changes address space of pointer}} 214#endif 215#endif 216 217 var_impl = arg_gen; 218#ifndef GENERIC 219#if !__OPENCL_CPP_VERSION__ 220// expected-error-re@-3{{assigning '__generic int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}} 221#else 222// expected-error-re@-5{{assigning '__generic int *__private' to '__{{global|constant}} int *' changes address space of pointer}} 223#endif 224#endif 225 226 var_cast1 = (AS int *)arg_glob; 227#ifdef CONSTANT 228#if !__OPENCL_CPP_VERSION__ 229// expected-error@-3{{casting '__global int *' to type '__constant int *' changes address space of pointer}} 230#else 231// expected-error@-5{{C-style cast from '__global int *' to '__constant int *' converts between mismatching address spaces}} 232#endif 233#endif 234 235 var_cast2 = (AS int *)arg_loc; 236#ifndef GENERIC 237#if !__OPENCL_CPP_VERSION__ 238// expected-error-re@-3{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}} 239#else 240// expected-error-re@-5{{C-style cast from '__local int *' to '__{{global|constant}} int *' converts between mismatching address spaces}} 241#endif 242#endif 243 244 var_cast3 = (AS int *)arg_const; 245#ifndef CONSTANT 246#if !__OPENCL_CPP_VERSION__ 247// expected-error-re@-3{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}} 248#else 249// expected-error-re@-5{{C-style cast from '__constant int *' to '__{{global|generic}} int *' converts between mismatching address spaces}} 250#endif 251#endif 252 253 var_cast4 = (AS int *)arg_priv; 254#ifndef GENERIC 255#if !__OPENCL_CPP_VERSION__ 256// expected-error-re@-3{{casting '__private int *' to type '__{{global|constant}} int *' changes address space of pointer}} 257#else 258// expected-error-re@-5{{C-style cast from '__private int *' to '__{{global|constant}} int *' converts between mismatching address spaces}} 259#endif 260#endif 261 262 var_cast5 = (AS int *)arg_gen; 263#ifdef CONSTANT 264#if !__OPENCL_CPP_VERSION__ 265// expected-error@-3{{casting '__generic int *' to type '__constant int *' changes address space of pointer}} 266#else 267// expected-error@-5{{C-style cast from '__generic int *' to '__constant int *' converts between mismatching address spaces}} 268#endif 269#endif 270 271 AS int *var_cmp; 272 int b = var_cmp != arg_glob; 273#ifdef CONSTANT 274#if !__OPENCL_CPP_VERSION__ 275// expected-error@-3{{comparison between ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}} 276#else 277// expected-error@-5{{comparison of distinct pointer types ('__constant int *' and '__global int *')}} 278#endif 279#endif 280 281 b = var_cmp != arg_loc; 282#ifndef GENERIC 283#if !__OPENCL_CPP_VERSION__ 284// expected-error-re@-3{{comparison between ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}} 285#else 286// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|constant}} int *' and '__local int *')}} 287#endif 288#endif 289 290 b = var_cmp == arg_const; 291#ifndef CONSTANT 292#if !__OPENCL_CPP_VERSION__ 293// expected-error-re@-3{{comparison between ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}} 294#else 295// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|generic}} int *' and '__constant int *')}} 296#endif 297#endif 298 299 b = var_cmp <= arg_priv; 300#ifndef GENERIC 301#if !__OPENCL_CPP_VERSION__ 302// expected-error-re@-3{{comparison between ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}} 303#else 304// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|constant}} int *' and '__private int *')}} 305#endif 306#endif 307 308 b = var_cmp >= arg_gen; 309#ifdef CONSTANT 310#if !__OPENCL_CPP_VERSION__ 311// expected-error@-3{{comparison between ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}} 312#else 313// expected-error@-5{{comparison of distinct pointer types ('__constant int *' and '__generic int *')}} 314#endif 315#endif 316 317 AS int *var_sub; 318 b = var_sub - arg_glob; 319#ifdef CONSTANT 320// expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}} 321#endif 322 323 b = var_sub - arg_loc; 324#ifndef GENERIC 325// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}} 326#endif 327 328 b = var_sub - arg_const; 329#ifndef CONSTANT 330// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}} 331#endif 332 333 b = var_sub - arg_priv; 334#ifndef GENERIC 335// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}} 336#endif 337 338 b = var_sub - arg_gen; 339#ifdef CONSTANT 340// expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}} 341#endif 342 343 f_glob(var_sub); 344#ifndef GLOBAL 345#if !__OPENCL_CPP_VERSION__ 346// expected-error-re@-3{{passing '__{{constant|generic}} int *__private' to parameter of type '__global int *' changes address space of pointer}} 347#else 348// expected-error@-5{{no matching function for call to 'f_glob'}} 349#endif 350#endif 351 352 f_loc(var_sub); 353#if !__OPENCL_CPP_VERSION__ 354// expected-error-re@-2{{passing '__{{global|constant|generic}} int *__private' to parameter of type '__local int *' changes address space of pointer}} 355#else 356// expected-error@-4{{no matching function for call to 'f_loc'}} 357#endif 358 359 f_const(var_sub); 360#ifndef CONSTANT 361#if !__OPENCL_CPP_VERSION__ 362// expected-error-re@-3{{passing '__{{global|generic}} int *__private' to parameter of type '__constant int *' changes address space of pointer}} 363#else 364// expected-error@-5{{no matching function for call to 'f_const'}} 365#endif 366#endif 367 368 f_priv(var_sub); 369#if !__OPENCL_CPP_VERSION__ 370// expected-error-re@-2{{passing '__{{global|constant|generic}} int *__private' to parameter of type '__private int *' changes address space of pointer}} 371#else 372// expected-error@-4{{no matching function for call to 'f_priv'}} 373#endif 374 375 f_gen(var_sub); 376#ifdef CONSTANT 377#if !__OPENCL_CPP_VERSION__ 378// expected-error@-3{{passing '__constant int *__private' to parameter of type '__generic int *' changes address space of pointer}} 379#else 380// expected-error@-5{{no matching function for call to 'f_gen'}} 381#endif 382#endif 383} 384 385void test_ternary() { 386 AS int *var_cond; 387 __generic int *var_gen; 388 __global int *var_glob; 389 var_gen = 0 ? var_cond : var_glob; 390#ifdef CONSTANT 391#if !__OPENCL_CPP_VERSION__ 392// expected-error@-3{{conditional operator with the second and third operands of type ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}} 393#else 394// expected-error@-5{{incompatible operand types ('__constant int *' and '__global int *')}} 395#endif 396#endif 397 398 __local int *var_loc; 399 var_gen = 0 ? var_cond : var_loc; 400#ifndef GENERIC 401#if !__OPENCL_CPP_VERSION__ 402// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}} 403#else 404// expected-error-re@-5{{incompatible operand types ('__{{global|constant}} int *' and '__local int *')}} 405#endif 406#endif 407 408 __constant int *var_const; 409 var_cond = 0 ? var_cond : var_const; 410#ifndef CONSTANT 411#if !__OPENCL_CPP_VERSION__ 412// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}} 413#else 414// expected-error-re@-5{{incompatible operand types ('__{{global|generic}} int *' and '__constant int *')}} 415#endif 416#endif 417 418 __private int *var_priv; 419 var_gen = 0 ? var_cond : var_priv; 420#ifndef GENERIC 421#if !__OPENCL_CPP_VERSION__ 422// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}} 423#else 424// expected-error-re@-5{{incompatible operand types ('__{{global|constant}} int *' and '__private int *')}} 425#endif 426#endif 427 428 var_gen = 0 ? var_cond : var_gen; 429#ifdef CONSTANT 430#if !__OPENCL_CPP_VERSION__ 431// expected-error@-3{{conditional operator with the second and third operands of type ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}} 432#else 433// expected-error@-5{{incompatible operand types ('__constant int *' and '__generic int *')}} 434#endif 435#endif 436 437 void *var_void_gen; 438 __global char *var_glob_ch; 439 var_void_gen = 0 ? var_cond : var_glob_ch; 440#if __OPENCL_CPP_VERSION__ 441// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__global char *')}} 442#else 443#ifdef CONSTANT 444// expected-error@-5{{conditional operator with the second and third operands of type ('__constant int *' and '__global char *') which are pointers to non-overlapping address spaces}} 445#else 446// expected-warning-re@-7{{pointer type mismatch ('__{{global|generic}} int *' and '__global char *')}} 447#endif 448#endif 449 450 __local char *var_loc_ch; 451 var_void_gen = 0 ? var_cond : var_loc_ch; 452#if __OPENCL_CPP_VERSION__ 453// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__local char *')}} 454#else 455#ifndef GENERIC 456// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__local char *') which are pointers to non-overlapping address spaces}} 457#else 458// expected-warning@-7{{pointer type mismatch ('__generic int *' and '__local char *')}} 459#endif 460#endif 461 462 __constant void *var_void_const; 463 __constant char *var_const_ch; 464 var_void_const = 0 ? var_cond : var_const_ch; 465#if __OPENCL_CPP_VERSION__ 466// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__constant char *')}} 467#else 468#ifndef CONSTANT 469// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|generic}} int *' and '__constant char *') which are pointers to non-overlapping address spaces}} 470#else 471// expected-warning@-7{{pointer type mismatch ('__constant int *' and '__constant char *')}} 472#endif 473#endif 474 475 __private char *var_priv_ch; 476 var_void_gen = 0 ? var_cond : var_priv_ch; 477#if __OPENCL_CPP_VERSION__ 478// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__private char *')}} 479#else 480#ifndef GENERIC 481// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__private char *') which are pointers to non-overlapping address spaces}} 482#else 483// expected-warning@-7{{pointer type mismatch ('__generic int *' and '__private char *')}} 484#endif 485#endif 486 487 __generic char *var_gen_ch; 488 var_void_gen = 0 ? var_cond : var_gen_ch; 489#if __OPENCL_CPP_VERSION__ 490// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__generic char *')}} 491#else 492#ifdef CONSTANT 493// expected-error@-5{{conditional operator with the second and third operands of type ('__constant int *' and '__generic char *') which are pointers to non-overlapping address spaces}} 494#else 495// expected-warning-re@-7{{pointer type mismatch ('__{{global|generic}} int *' and '__generic char *')}} 496#endif 497#endif 498} 499 500void test_pointer_chains() { 501 AS int *AS *var_as_as_int; 502 AS int *AS_COMP *var_asc_as_int; 503 AS_INCOMP int *AS_COMP *var_asc_asn_int; 504 AS_COMP int *AS_COMP *var_asc_asc_int; 505 506 // Case 1: 507 // * address spaces of corresponded most outer pointees overlaps, their canonical types are equal 508 // * CVR, address spaces and canonical types of the rest of pointees are equivalent. 509 var_as_as_int = var_asc_as_int; 510 var_as_as_int = 0 ? var_as_as_int : var_asc_as_int; 511 512 // Case 2: Corresponded inner pointees has non-overlapping address spaces. 513 var_as_as_int = 0 ? var_as_as_int : var_asc_asn_int; 514#if !__OPENCL_CPP_VERSION__ 515// expected-warning-re@-2{{pointer type mismatch ('__{{(generic|global|constant)}} int *__{{(generic|global|constant)}} *' and '__{{(local|global|constant)}} int *__{{(constant|local|global)}} *')}} 516#else 517// expected-error-re@-4{{incompatible operand types ('__{{(generic|global|constant)}} int *__{{(generic|global|constant)}} *' and '__{{(local|global|constant)}} int *__{{(constant|local|global)}} *')}} 518#endif 519 520 // Case 3: Corresponded inner pointees has overlapping but not equivalent address spaces. 521 var_as_as_int = var_asc_asc_int; 522#ifdef GENERIC 523#if !__OPENCL_CPP_VERSION__ 524// expected-error@-3 {{assigning '__local int *__local *__private' to '__generic int *__generic *__private' changes address space of nested pointer}} 525#else 526// expected-error@-5 {{assigning '__local int *__local *__private' to '__generic int *__generic *' changes address space of nested pointer}} 527#endif 528#endif 529 530 var_as_as_int = (AS int *AS *)var_asc_asc_int; 531#ifdef GENERIC 532#if !__OPENCL_CPP_VERSION__ 533// expected-warning@-3 {{casting '__local int *__local *' to type '__generic int *__generic *' discards qualifiers in nested pointer types}} 534#else 535// expected-warning@-5 {{C-style cast from '__local int *__local *' to '__generic int *__generic *' changes address space of nested pointers}} 536#endif 537#endif 538 539 var_as_as_int = (AS int *AS *)var_asc_asn_int; 540#if !__OPENCL_CPP_VERSION__ 541// expected-warning-re@-2 {{casting '__{{global|local|constant}} int *__{{local|constant|global}} *' to type '__{{global|constant|generic}} int *__{{global|constant|generic}} *' discards qualifiers in nested pointer types}} 542#else 543// expected-warning-re@-4 {{C-style cast from '__{{global|local|constant}} int *__{{local|constant|global}} *' to '__{{global|constant|generic}} int *__{{global|constant|generic}} *' changes address space of nested pointers}} 544#endif 545 546 var_as_as_int = 0 ? var_as_as_int : var_asc_asc_int; 547#ifdef GENERIC 548#if !__OPENCL_CPP_VERSION__ 549// expected-warning@-3{{pointer type mismatch ('__generic int *__generic *' and '__local int *__local *')}} 550#else 551// expected-error@-5 {{incompatible operand types ('__generic int *__generic *' and '__local int *__local *')}} 552#endif 553#endif 554} 555