]> granicus.if.org Git - clang/commitdiff
[OpenCL] Eliminate warning when declaring OpenCL builtin functions.
authorAnastasia Stulova <anastasia.stulova@arm.com>
Tue, 2 Feb 2016 11:29:43 +0000 (11:29 +0000)
committerAnastasia Stulova <anastasia.stulova@arm.com>
Tue, 2 Feb 2016 11:29:43 +0000 (11:29 +0000)
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

lib/Sema/SemaLookup.cpp
test/SemaOpenCL/builtin.cl [new file with mode: 0644]

index f28cd27e85cc95488153cd3dc514417d5d043bc7..93d503e20b5b45feab2d2ee7484d36f96cb2e097 100644 (file)
@@ -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 (file)
index 0000000..e5f56e2
--- /dev/null
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+
+float __attribute__((overloadable)) acos(float); // expected-no-diagnostics