diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-11-16 16:22:56 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-11-16 16:22:56 +0000 |
commit | 04307941e2b16cd78347b90418204d84b584c49e (patch) | |
tree | dfb78277dc0ca94755a685eb50a059ddc42731a4 /clang/lib/Sema/SemaDecl.cpp | |
parent | d12531677188252af597fbb2af4646cf2cbe25ed (diff) | |
download | bcm5719-llvm-04307941e2b16cd78347b90418204d84b584c49e.tar.gz bcm5719-llvm-04307941e2b16cd78347b90418204d84b584c49e.zip |
[OpenCL] Enable address spaces for references in C++
Added references to the addr spaces deduction and enabled
CL2.0 features (program scope variables and storage class
qualifiers) to work in C++ mode too.
Fixed several address space conversion issues in CodeGen
for references.
Differential Revision: https://reviews.llvm.org/D53764
llvm-svn: 347059
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0965c3f3473..5c003ed6093 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7352,19 +7352,23 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { return; } } - // OpenCL v1.2 s6.5 - All program scope variables must be declared in the + // OpenCL C v1.2 s6.5 - All program scope variables must be declared in the // __constant address space. - // OpenCL v2.0 s6.5.1 - Variables defined at program scope and static + // OpenCL C v2.0 s6.5.1 - Variables defined at program scope and static // variables inside a function can also be declared in the global // address space. + // OpenCL C++ v1.0 s2.5 inherits rule from OpenCL C v2.0 and allows local + // address space additionally. + // FIXME: Add local AS for OpenCL C++. if (NewVD->isFileVarDecl() || NewVD->isStaticLocal() || NewVD->hasExternalStorage()) { if (!T->isSamplerT() && !(T.getAddressSpace() == LangAS::opencl_constant || (T.getAddressSpace() == LangAS::opencl_global && - getLangOpts().OpenCLVersion == 200))) { + (getLangOpts().OpenCLVersion == 200 || + getLangOpts().OpenCLCPlusPlus)))) { int Scope = NewVD->isStaticLocal() | NewVD->hasExternalStorage() << 1; - if (getLangOpts().OpenCLVersion == 200) + if (getLangOpts().OpenCLVersion == 200 || getLangOpts().OpenCLCPlusPlus) Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space) << Scope << "global or constant"; else |