Author: stulova Date: Tue Feb 2 05:29:43 2016 New Revision: 259491 URL: http://llvm.org/viewvc/llvm-project?rev=259491&view=rev Log: [OpenCL] Eliminate warning when declaring OpenCL builtin functions.
OpenCL builtin functions are usually declared in header files. Currently clang emits warning for OpenCL builtin functions which have the same name as standard C library functions. This commit eliminates such warnings by not adding the C standard includes following the restriction from OpenCL v1.2 s6.9.f. Patch by Liu Yaxun (Sam)! Review: http://reviews.llvm.org/D16692 Added: cfe/trunk/test/SemaOpenCL/builtin.cl Modified: cfe/trunk/lib/Sema/SemaLookup.cpp Modified: cfe/trunk/lib/Sema/SemaLookup.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=259491&r1=259490&r2=259491&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaLookup.cpp (original) +++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Feb 2 05:29:43 2016 @@ -684,9 +684,9 @@ static bool LookupBuiltin(Sema &S, Looku // If this is a builtin on this (or all) targets, create the decl. if (unsigned BuiltinID = II->getBuiltinID()) { - // In C++, we don't have any predefined library functions like - // 'malloc'. Instead, we'll just error. - if (S.getLangOpts().CPlusPlus && + // In C++ and OpenCL (spec v1.2 s6.9.f), we don't have any predefined + // library functions like 'malloc'. Instead, we'll just error. + if ((S.getLangOpts().CPlusPlus || S.getLangOpts().OpenCL) && S.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) return false; Added: cfe/trunk/test/SemaOpenCL/builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtin.cl?rev=259491&view=auto ============================================================================== --- cfe/trunk/test/SemaOpenCL/builtin.cl (added) +++ cfe/trunk/test/SemaOpenCL/builtin.cl Tue Feb 2 05:29:43 2016 @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +float __attribute__((overloadable)) acos(float); // expected-no-diagnostics _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits