r359789 - [OpenCL] Deduce static data members to __global addr space.
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Thu May 2 07:40:41 PDT 2019
Author: stulova
Date: Thu May 2 07:40:40 2019
New Revision: 359789
URL: http://llvm.org/viewvc/llvm-project?rev=359789&view=rev
Log:
[OpenCL] Deduce static data members to __global addr space.
Similarly to static variables in OpenCL, static class data
members should be deduced to __global addr space.
Differential Revision: https://reviews.llvm.org/D61304
Added:
cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=359789&r1=359788&r2=359789&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu May 2 07:40:40 2019
@@ -7308,8 +7308,10 @@ static void deduceOpenCLImplicitAddrSpac
// 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.
Added: cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl?rev=359789&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl (added)
+++ cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl Thu May 2 07:40:40 2019
@@ -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;
+};
More information about the cfe-commits
mailing list