diff options
author | Pekka Jaaskelainen <pekka.jaaskelainen@tut.fi> | 2014-02-20 13:52:08 +0000 |
---|---|---|
committer | Pekka Jaaskelainen <pekka.jaaskelainen@tut.fi> | 2014-02-20 13:52:08 +0000 |
commit | 8690a6860a45ba36e39b4ff0dbe434195e125d11 (patch) | |
tree | 02e81d0b8060ed4b67daa564d2273d26274e2fa9 /clang/lib/Sema/SemaDecl.cpp | |
parent | 8dd548d236e5c85a0da3caadc38574e92729205c (diff) | |
download | bcm5719-llvm-8690a6860a45ba36e39b4ff0dbe434195e125d11.tar.gz bcm5719-llvm-8690a6860a45ba36e39b4ff0dbe434195e125d11.zip |
OpenCL: fix for the restriction on pointers to functions.
Patch from Anastasia Stulova!
llvm-svn: 201788
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c147681f03f..06d4500f77e 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4986,12 +4986,25 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, bool IsLocalExternDecl = SC == SC_Extern && adjustContextForLocalExternDecl(DC); - if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16) { - // OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and - // half array type (unless the cl_khr_fp16 extension is enabled). - if (Context.getBaseElementType(R)->isHalfType()) { - Diag(D.getIdentifierLoc(), diag::err_opencl_half_declaration) << R; - D.setInvalidType(); + if (getLangOpts().OpenCL) { + // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed. + QualType NR = R; + while (NR->isPointerType()) { + if (NR->isFunctionPointerType()) { + Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable); + D.setInvalidType(); + break; + } + NR = NR->getPointeeType(); + } + + if (!getOpenCLOptions().cl_khr_fp16) { + // OpenCL v1.2 s6.1.1.1: reject declaring variables of the half and + // half array type (unless the cl_khr_fp16 extension is enabled). + if (Context.getBaseElementType(R)->isHalfType()) { + Diag(D.getIdentifierLoc(), diag::err_opencl_half_declaration) << R; + D.setInvalidType(); + } } } |