[PATCH] D61304: [OpenCL][PR41609] Deduce static data members to __global addr space

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 30 04:40:55 PDT 2019


Anastasia created this revision.
Anastasia added reviewers: svenvh, rjmccall.
Herald added subscribers: ebevhan, yaxunl.

Similarly to static variables in OpenCL, static class data members should be deduced to `__global` addr space.


https://reviews.llvm.org/D61304

Files:
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/address-space-deduction.cl


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -0,0 +1,12 @@
+//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
+
+//expected-no-diagnostics
+
+//CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
+constexpr int foo = 0;
+
+class c {
+public:
+  //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
+  static constexpr int foo2 = 0;
+};
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7308,8 +7308,10 @@
        // otherwise it will fail some sema check.
       IsFuncReturnType || IsFuncType ||
       // Do not deduce addr space for member types of struct, except the pointee
-      // type of a pointer member type.
-      (D.getContext() == DeclaratorContext::MemberContext && !IsPointee) ||
+      // type of a pointer member type or static data members.
+      (D.getContext() == DeclaratorContext::MemberContext &&
+       (!IsPointee &&
+        D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
       // Do not deduce addr space for types used to define a typedef and the
       // typedef itself, except the pointee type of a pointer type which is used
       // to define the typedef.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61304.197299.patch
Type: text/x-patch
Size: 1408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190430/e1a4f0e7/attachment.bin>


More information about the cfe-commits mailing list