Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -7268,7 +7268,7 @@ "invalid conversion between vector type %0 and integer type %1 " "of different size">; -def err_opencl_function_pointer_variable : Error< +def err_opencl_function_pointer : Error< "pointers to functions are not allowed">; def err_opencl_taking_function_address : Error< Index: cfe/trunk/lib/Sema/SemaDecl.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -6160,7 +6160,7 @@ QualType NR = R; while (NR->isPointerType()) { if (NR->isFunctionPointerType()) { - Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable); + Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer); D.setInvalidType(); break; } Index: cfe/trunk/lib/Sema/SemaType.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaType.cpp +++ cfe/trunk/lib/Sema/SemaType.cpp @@ -1881,6 +1881,11 @@ return QualType(); } + if (T->isFunctionType() && getLangOpts().OpenCL) { + Diag(Loc, diag::err_opencl_function_pointer); + return QualType(); + } + if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer)) return QualType(); Index: cfe/trunk/test/SemaOpenCL/func.cl =================================================================== --- cfe/trunk/test/SemaOpenCL/func.cl +++ cfe/trunk/test/SemaOpenCL/func.cl @@ -4,8 +4,15 @@ void vararg_f(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} void __vararg_f(int, ...); typedef void (*vararg_fptr_t)(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} + // expected-error@-1{{pointers to functions are not allowed}} int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} +// Struct type with function pointer field +typedef struct s +{ + void (*f)(struct s *self, int *i); // expected-error{{pointers to functions are not allowed}} +} s_t; + //Function pointer void foo(void*);