diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -6749,8 +6749,8 @@ // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed. QualType NR = R; - while (NR->isPointerType()) { - if (NR->isFunctionPointerType()) { + while (NR->isPointerType() || NR->isMemberFunctionPointerType()) { + if (NR->isFunctionPointerType() || NR->isMemberFunctionPointerType()) { Se.Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer); D.setInvalidType(); return false; diff --git a/clang/test/SemaOpenCLCXX/members.cl b/clang/test/SemaOpenCLCXX/members.cl new file mode 100644 --- /dev/null +++ b/clang/test/SemaOpenCLCXX/members.cl @@ -0,0 +1,22 @@ +//RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -verify -fsyntax-only + +// Check that pointer to member functions are diagnosed +struct C { + void f(int n); +}; + +typedef void (C::*p_t)(int); + +template struct remove_reference { typedef T type; }; +template struct remove_reference { typedef T type; }; + +template +void templ_test() { + typename remove_reference::type *ptr; //expected-error{{pointers to functions are not allowed}} +} + +void test() { + void (C::*p)(int); //expected-error{{pointers to functions are not allowed}} + p_t p1; //expected-error{{pointers to functions are not allowed}} + templ_test(); //expected-note{{in instantiation of function template specialization}} +}