From: Anastasia Stulova Date: Tue, 2 Feb 2016 11:29:43 +0000 (+0000) Subject: [OpenCL] Eliminate warning when declaring OpenCL builtin functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb0b4306511810c41e00cfaea23e5f41afef9f4f;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259491 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index f28cd27e85..93d503e20b 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -684,9 +684,9 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) { // 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; diff --git a/test/SemaOpenCL/builtin.cl b/test/SemaOpenCL/builtin.cl new file mode 100644 index 0000000000..e5f56e2577 --- /dev/null +++ b/test/SemaOpenCL/builtin.cl @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +float __attribute__((overloadable)) acos(float); // expected-no-diagnostics