aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2013-04-05 20:14:50 +0000
committerTanya Lattner <tonic@nondot.org>2013-04-05 20:14:50 +0000
commit8aa86d1155fb99e34fd084d83da3345b1ec2b2e4 (patch)
tree71dad425d0215af9c70fb9037e51327d0e017e75 /lib/Sema/SemaDecl.cpp
parent5238e40f6ea6346b6bc1505e4975c2c4ab7fde09 (diff)
Add an error to check that all program scope variables are in the constant address space in OpenCL.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178906 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index adf3505633..e9116bc91a 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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)