diff options
| author | Mike Stump <mrs@apple.com> | 2009-12-15 03:11:10 +0000 |
|---|---|---|
| committer | Mike Stump <mrs@apple.com> | 2009-12-15 03:11:10 +0000 |
| commit | feb1945fee429064f47c4edff45667c036ef01a6 (patch) | |
| tree | c481d279ad332543838922222168fa9b131bd472 | |
| parent | 106c10881ef9231b9073d5fca6288ae600bf340e (diff) | |
| download | bcm5719-llvm-feb1945fee429064f47c4edff45667c036ef01a6.tar.gz bcm5719-llvm-feb1945fee429064f47c4edff45667c036ef01a6.zip | |
This patch should fix PR2461. It allows clang to apply the noreturn
attribute to function pointers. It also fixes Sema to check function
pointers for the noreturn attribute when checking for fallthrough.
Patch by Chip Davis, with a slight fix to pass the testsuite.
llvm-svn: 91408
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 3 |
2 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 64305b443ec..14d2377784d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1265,11 +1265,10 @@ Sema::ControlFlowKind Sema::CheckFallThrough(Stmt *Root) { NoReturnEdge = true; HasFakeEdge = true; } else if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE)) { - if (FunctionDecl *FD = dyn_cast<FunctionDecl>(DRE->getDecl())) { - if (FD->hasAttr<NoReturnAttr>()) { - NoReturnEdge = true; - HasFakeEdge = true; - } + ValueDecl *VD = DRE->getDecl(); + if (VD->hasAttr<NoReturnAttr>()) { + NoReturnEdge = true; + HasFakeEdge = true; } } } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index e219923f6da..84ee2073382 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -376,7 +376,8 @@ static bool HandleCommonNoReturnAttr(Decl *d, const AttributeList &Attr, if (!isFunctionOrMethod(d) && !isa<BlockDecl>(d)) { ValueDecl *VD = dyn_cast<ValueDecl>(d); - if (VD == 0 || !VD->getType()->isBlockPointerType()) { + if (VD == 0 || (!VD->getType()->isBlockPointerType() + && !VD->getType()->isFunctionPointerType())) { S.Diag(Attr.getLoc(), Attr.isCXX0XAttribute() ? diag::err_attribute_wrong_decl_type : diag::warn_attribute_wrong_decl_type) |

