From 885f51439b619bfc42e47c70bd3404ceedcf259f Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 9 Sep 2014 02:49:40 +0000 Subject: [PATCH] Allow empty statements in naked functions in addition to ASM statements Summary: This fixes PR20883. Test Plan: The patch includes an automated test. Reviewers: hansw Differential Revision: http://reviews.llvm.org/D5256 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217413 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 2 +- test/Sema/attr-naked.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 27f69adff5..1f2cf7bc9f 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -10426,7 +10426,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, if (FD && FD->hasAttr()) { for (const Stmt *S : Body->children()) { - if (!isa(S)) { + if (!isa(S) && !isa(S)) { Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function); Diag(FD->getAttr()->getLocation(), diag::note_attribute); FD->setInvalidDecl(); diff --git a/test/Sema/attr-naked.c b/test/Sema/attr-naked.c index f6c26b29fc..fcae842775 100644 --- a/test/Sema/attr-naked.c +++ b/test/Sema/attr-naked.c @@ -23,3 +23,12 @@ __attribute__((naked)) int t5(int x) { asm("movl x, %eax"); asm("retl"); } + +__attribute__((naked)) void t6() { + ; +} + +__attribute__((naked)) void t7() { + asm("movl $42, %eax"); + ; +} -- 2.50.1