]> granicus.if.org Git - clang/commitdiff
Don't complain about missing return statements for naked
authorDouglas Gregor <dgregor@apple.com>
Mon, 11 Jul 2011 15:24:01 +0000 (15:24 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 11 Jul 2011 15:24:01 +0000 (15:24 +0000)
functions. Fixes <rdar://problem/9731999>.

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

lib/Sema/SemaDecl.cpp
test/Sema/attr-naked.c

index b0e090dff658b2205ecd6e72a3e3602ff1a3c6fc..886df5fc57e4dd8d896a97dc0efb55887a65182f 100644 (file)
@@ -6457,6 +6457,10 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
       // Implements C++ [basic.start.main]p5 and C99 5.1.2.2.3.
       FD->setHasImplicitReturnZero(true);
       WP.disableCheckFallThrough();
+    } else if (FD->hasAttr<NakedAttr>()) {
+      // If the function is marked 'naked', don't complain about missing return
+      // statements.
+      WP.disableCheckFallThrough();
     }
 
     // MSVC permits the use of pure specifier (=0) on function definition,
index 1ebd78438e2f8df185d043e2a97bd5f8e854a0ec..d9fa5423d9ef37acdb31d1d8f717756a753088a9 100644 (file)
@@ -2,6 +2,10 @@
 
 int a __attribute__((naked)); // expected-warning {{'naked' attribute only applies to functions}}
 
+__attribute__((naked)) int t0(void) { 
+  __asm__ volatile("mov r0, #0");
+}
+
 void t1() __attribute__((naked));
 
 void t2() __attribute__((naked(2))); // expected-error {{attribute takes no arguments}}