diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-05-02 14:40:40 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2019-05-02 14:40:40 +0000 |
commit | 44bb0aa99414db7e24fca8b1238eb4e189db8f3c (patch) | |
tree | c40c1e114583261e687abcd6ad0ff79f118aa5dc | |
parent | 0178cff279ade2761f9b6e3504cbd34d3f73aae5 (diff) | |
download | bcm5719-llvm-44bb0aa99414db7e24fca8b1238eb4e189db8f3c.tar.gz bcm5719-llvm-44bb0aa99414db7e24fca8b1238eb4e189db8f3c.zip |
[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
llvm-svn: 359789
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaOpenCLCXX/address-space-deduction.cl | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 32e57eb925c..3b25595a33a 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -7308,8 +7308,10 @@ static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State, // 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. diff --git a/clang/test/SemaOpenCLCXX/address-space-deduction.cl b/clang/test/SemaOpenCLCXX/address-space-deduction.cl new file mode 100644 index 00000000000..d6dcc853a60 --- /dev/null +++ b/clang/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; +}; |