]> granicus.if.org Git - clang/commitdiff
Disable the warning for missing prototypes for OpenCL kernels. Includes testcase.
authorTanya Lattner <tonic@nondot.org>
Thu, 26 Jul 2012 00:08:28 +0000 (00:08 +0000)
committerTanya Lattner <tonic@nondot.org>
Thu, 26 Jul 2012 00:08:28 +0000 (00:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaOpenCL/warn-missing-prototypes.cl [new file with mode: 0644]

index 12444e555941fa7ddeead7c0c84fde4840d904fd..7233fc7c13e352044d5394a5a1365fca34d71e9a 100644 (file)
@@ -7509,6 +7509,10 @@ static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD) {
   if (FD->isFunctionTemplateSpecialization())
     return false;
 
+  // Don't warn for OpenCL kernels.
+  if (FD->hasAttr<OpenCLKernelAttr>())
+    return false;
+  
   bool MissingPrototype = true;
   for (const FunctionDecl *Prev = FD->getPreviousDecl();
        Prev; Prev = Prev->getPreviousDecl()) {
diff --git a/test/SemaOpenCL/warn-missing-prototypes.cl b/test/SemaOpenCL/warn-missing-prototypes.cl
new file mode 100644 (file)
index 0000000..487cb28
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes %s
+
+void f() { } // expected-warning {{no previous prototype for function 'f'}}
+
+// Don't warn about kernel functions.
+kernel void g() { }