diff options
author | Tanya Lattner <tonic@nondot.org> | 2013-04-04 23:36:11 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2013-04-04 23:36:11 +0000 |
commit | 9812634c5243b124d4c63641dc6d6c9452b957ba (patch) | |
tree | 448b6c8b5f43c2e8872f9dec9db8df30ccd97d97 /clang/lib/Sema/SemaDecl.cpp | |
parent | df6f67ed87c85fe25321da3686881909f38e17a9 (diff) | |
download | bcm5719-llvm-9812634c5243b124d4c63641dc6d6c9452b957ba.tar.gz bcm5719-llvm-9812634c5243b124d4c63641dc6d6c9452b957ba.zip |
Add an error to check that all program scope variables are in the constant address space in OpenCL.
llvm-svn: 178811
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index adf3505633b..e9116bc91a5 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5177,6 +5177,16 @@ bool Sema::CheckVariableDeclaration(VarDecl *NewVD, return false; } + // OpenCL v1.2 s6.5 - All program scope variables must be declared in the + // __constant address space. + if (getLangOpts().OpenCL && NewVD->isFileVarDecl() + && T.getAddressSpace() != LangAS::opencl_constant + && !T->isSamplerT()){ + Diag(NewVD->getLocation(), diag::err_opencl_global_invalid_addr_space); + NewVD->setInvalidDecl(); + return false; + } + // OpenCL v1.2 s6.8 -- The static qualifier is valid only in program // scope. if ((getLangOpts().OpenCLVersion >= 120) |