Skip to content

Commit

Permalink
Allow empty statements in naked functions in addition to ASM statements
Browse files Browse the repository at this point in the history
Summary: This fixes PR20883.

Test Plan: The patch includes an automated test.

Reviewers: hansw

Differential Revision: http://reviews.llvm.org/D5256

llvm-svn: 217413
  • Loading branch information
ehsan committed Sep 9, 2014
1 parent 8a8c3ba commit 5c00c31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Expand Up @@ -10426,7 +10426,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,

if (FD && FD->hasAttr<NakedAttr>()) {
for (const Stmt *S : Body->children()) {
if (!isa<AsmStmt>(S)) {
if (!isa<AsmStmt>(S) && !isa<NullStmt>(S)) {
Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
Diag(FD->getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
FD->setInvalidDecl();
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Sema/attr-naked.c
Expand Up @@ -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");
;
}

0 comments on commit 5c00c31

Please sign in to comment.