]> granicus.if.org Git - clang/commitdiff
[OpenCL] Disable C99 standard lib functions
authorAnastasia Stulova <anastasia.stulova@arm.com>
Fri, 12 Feb 2016 12:07:04 +0000 (12:07 +0000)
committerAnastasia Stulova <anastasia.stulova@arm.com>
Fri, 12 Feb 2016 12:07:04 +0000 (12:07 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260671 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/SemaOpenCL/builtin.cl

index ce1b9fac5546b21a8084fb6a62c4421083b889cb..7378c44178bd041858006f6682587a736b244010 100644 (file)
@@ -2732,6 +2732,12 @@ unsigned FunctionDecl::getBuiltinID() const {
   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;
 }
 
index e5f56e2577da22fc342e217827fcf841203faa70..d48a0c449591a3cb336845ac5a9f4b43f6c9419a 100644 (file)
@@ -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);
+}