[PATCH] D103191: [OpenCL] Add support of __opencl_c_program_scope_global_variables feature macro

Anton Zabaznov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 1 05:04:15 PDT 2021


azabaznov added inline comments.


================
Comment at: clang/test/SemaOpenCL/storageclass.cl:22
+extern generic float g_generic_extern_var;
+#ifndef __opencl_c_program_scope_global_variables
+// expected-error at -17 {{program scope variable must reside in constant address space}}
----------------
svenvh wrote:
> Not sure if this is the best way to restructure this test?  Now the diagnostics are quite far away from the declarations, and it is harder to see which diagnostic belongs to which declaration.
> 
> I wonder if the following would be a better structure instead:
> ```
> int G3 = 0;
> #ifndef __opencl_c_program_scope_global_variables
> // expected-error at -2 {{program scope variable must reside in constant address space}}
> #endif
> 
> global int G4 = 0;
> #ifndef __opencl_c_program_scope_global_variables
> // expected-error at -2 {{program scope variable must reside in constant address space}}
> #endif
> 
> ... etc. ...
> ```
> 
> The downside is that it is a bit more verbose due to the repetition of the `#if` guards, but it makes the test more readable/maintainable in my opinion.
Yeah, that's reasonable. I'll change that in the following patch. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103191/new/

https://reviews.llvm.org/D103191



More information about the cfe-commits mailing list