]> granicus.if.org Git - clang/commitdiff
Only allow a "noreturn" attribute to be affixed to a FunctionDecl.
authorTed Kremenek <kremenek@apple.com>
Mon, 3 Mar 2008 16:52:27 +0000 (16:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 3 Mar 2008 16:52:27 +0000 (16:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47844 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaDecl.cpp

index 6854aacb9e4d84ce405e4e4ab4017afc9cfbfc82..88225f535d4ccd99c59996039a11c6fc6bb373dc 100644 (file)
@@ -1998,6 +1998,14 @@ void Sema::HandleNoReturnAttribute(Decl *d, AttributeList *rawAttr) {
     return;
   }
   
+  FunctionDecl *Fn = dyn_cast<FunctionDecl>(d);
+  
+  if (!Fn) {
+    Diag(rawAttr->getLoc(), diag::warn_attribute_wrong_decl_type,
+         "noreturn", "function");
+    return;
+  }
+  
   d->addAttr(new NoReturnAttr());
 }