From: Ted Kremenek Date: Mon, 3 Mar 2008 16:52:27 +0000 (+0000) Subject: Only allow a "noreturn" attribute to be affixed to a FunctionDecl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3465fb383163244b0ef6d6de29632d0d352c8b82;p=clang Only allow a "noreturn" attribute to be affixed to a FunctionDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47844 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 6854aacb9e..88225f535d 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1998,6 +1998,14 @@ void Sema::HandleNoReturnAttribute(Decl *d, AttributeList *rawAttr) { return; } + FunctionDecl *Fn = dyn_cast(d); + + if (!Fn) { + Diag(rawAttr->getLoc(), diag::warn_attribute_wrong_decl_type, + "noreturn", "function"); + return; + } + d->addAttr(new NoReturnAttr()); }