[cfe-commits] r91408 - in /cfe/trunk/lib/Sema: SemaDecl.cpp SemaDeclAttr.cpp

Mike Stump mrs at apple.com
Mon Dec 14 19:11:10 PST 2009


Author: mrs
Date: Mon Dec 14 21:11:10 2009
New Revision: 91408

URL: http://llvm.org/viewvc/llvm-project?rev=91408&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=91408&r1=91407&r2=91408&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Dec 14 21:11:10 2009
@@ -1265,11 +1265,10 @@
         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;
         }
       }
     }

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=91408&r1=91407&r2=91408&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Dec 14 21:11:10 2009
@@ -376,7 +376,8 @@
 
   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)





More information about the cfe-commits mailing list