Author: stulova Date: Fri Feb 12 06:07:04 2016 New Revision: 260671 URL: http://llvm.org/viewvc/llvm-project?rev=260671&view=rev Log: [OpenCL] Disable C99 standard lib functions
The library functions defined in the C99 standard headers are not available (OpenCL v1.2 s6.9.f). This change stops treating OpenCL builtin functions as standard C lib functions to eliminate warning messages about printf format string. Patch by Liu Yaxun (Sam)! Differential Revision: http://reviews.llvm.org/D16812 Modified: cfe/trunk/lib/AST/Decl.cpp cfe/trunk/test/SemaOpenCL/builtin.cl Modified: cfe/trunk/lib/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=260671&r1=260670&r2=260671&view=diff ============================================================================== --- cfe/trunk/lib/AST/Decl.cpp (original) +++ cfe/trunk/lib/AST/Decl.cpp Fri Feb 12 06:07:04 2016 @@ -2732,6 +2732,12 @@ unsigned FunctionDecl::getBuiltinID() co if (getStorageClass() == SC_Static) return 0; + // OpenCL v1.2 s6.9.f - The library functions defined in + // the C99 standard headers are not available. + if (Context.getLangOpts().OpenCL && + Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) + return 0; + return BuiltinID; } Modified: cfe/trunk/test/SemaOpenCL/builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtin.cl?rev=260671&r1=260670&r2=260671&view=diff ============================================================================== --- cfe/trunk/test/SemaOpenCL/builtin.cl (original) +++ cfe/trunk/test/SemaOpenCL/builtin.cl Fri Feb 12 06:07:04 2016 @@ -1,3 +1,14 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -float __attribute__((overloadable)) acos(float); // expected-no-diagnostics +// expected-no-diagnostics + +float __attribute__((overloadable)) acos(float); + +typedef float float4 __attribute__((ext_vector_type(4))); +int printf(__constant const char* st, ...); + +void test(void) +{ + float4 a; + printf("%8.4v4hlf\n", a); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits