[cfe-commits] r134897 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/attr-naked.c
Douglas Gregor
dgregor at apple.com
Mon Jul 11 08:24:01 PDT 2011
Author: dgregor
Date: Mon Jul 11 10:24:01 2011
New Revision: 134897
URL: http://llvm.org/viewvc/llvm-project?rev=134897&view=rev
Log:
Don't complain about missing return statements for naked
functions. Fixes <rdar://problem/9731999>.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/attr-naked.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=134897&r1=134896&r2=134897&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 11 10:24:01 2011
@@ -6457,6 +6457,10 @@
// 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,
Modified: cfe/trunk/test/Sema/attr-naked.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-naked.c?rev=134897&r1=134896&r2=134897&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-naked.c (original)
+++ cfe/trunk/test/Sema/attr-naked.c Mon Jul 11 10:24:01 2011
@@ -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}}
More information about the cfe-commits
mailing list