summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@arm.com>2013-01-29 10:54:06 +0000
committerJoey Gouly <joey.gouly@arm.com>2013-01-29 10:54:06 +0000
commit39989dadd3cf3a82602c78a7e9d8ce535ab97017 (patch)
tree940fbdde6e0fed0c515d5cc42467f2b7319e7e6b /clang/lib/Sema/SemaDecl.cpp
parent064697ca065e0babf6cd6586eeff09ff13e9034f (diff)
downloadbcm5719-llvm-39989dadd3cf3a82602c78a7e9d8ce535ab97017.tar.gz
bcm5719-llvm-39989dadd3cf3a82602c78a7e9d8ce535ab97017.zip
Add a diagnostic for an OpenCL kernel with a pointer pointer argument.
Also refactor the surrounding code a little. llvm-svn: 173791
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9c3666413ba..56db548aa6d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6211,7 +6211,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
}
if (NewFD->hasAttr<OpenCLKernelAttr>()) {
-
// OpenCL v1.2 s6.8 static is invalid for kernel functions.
if ((getLangOpts().OpenCLVersion >= 120)
&& (SC == SC_Static)) {
@@ -6219,17 +6218,27 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
D.setInvalidType();
}
- // OpenCL v1.2 s6.8 n:
- // Arguments to kernel functions in a program cannot be declared to be of
- // type event_t.
for (FunctionDecl::param_iterator PI = NewFD->param_begin(),
PE = NewFD->param_end(); PI != PE; ++PI) {
- if ((*PI)->getType()->isEventT()) {
- Diag((*PI)->getLocation(), diag::err_event_t_kernel_arg);
+ ParmVarDecl *Param = *PI;
+ QualType PT = Param->getType();
+
+ // OpenCL v1.2 s6.9.a:
+ // A kernel function argument cannot be declared as a
+ // pointer to a pointer type.
+ if (PT->isPointerType() && PT->getPointeeType()->isPointerType()) {
+ Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_arg);
+ D.setInvalidType();
+ }
+
+ // OpenCL v1.2 s6.8 n:
+ // A kernel function argument cannot be declared
+ // of event_t type.
+ if (PT->isEventT()) {
+ Diag(Param->getLocation(), diag::err_event_t_kernel_arg);
D.setInvalidType();
}
}
-
}
MarkUnusedFileScopedDecl(NewFD);
OpenPOWER on IntegriCloud