]> granicus.if.org Git - clang/commitdiff
Fix crash with interrupt attribute on ARM.
authorEli Friedman <efriedma@codeaurora.org>
Tue, 14 Mar 2017 00:18:29 +0000 (00:18 +0000)
committerEli Friedman <efriedma@codeaurora.org>
Tue, 14 Mar 2017 00:18:29 +0000 (00:18 +0000)
An indirect call has no associated function declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297694 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/arm-interrupt-attr.c

index 88f32bb6b3bd74249515b0ce41d96bd311119c11..c5b2e1b3a2596a5690ad0fd7b434d9234b18ef57 100644 (file)
@@ -5387,7 +5387,7 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
   // but can be very challenging to debug.
   if (auto *Caller = getCurFunctionDecl())
     if (Caller->hasAttr<ARMInterruptAttr>())
-      if (!FDecl->hasAttr<ARMInterruptAttr>())
+      if (!FDecl || !FDecl->hasAttr<ARMInterruptAttr>())
         Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
 
   // Promote the function operand.
index cd67278d944e8bd8f3c88b4ecab76e91258d1a74..3a6cdbe0e0725609ba3e9fe140dc5a74c0d252ce 100644 (file)
@@ -28,3 +28,8 @@ __attribute__((interrupt("IRQ"))) void caller2() {
   callee1(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
   callee2();
 }
+
+void (*callee3)();
+__attribute__((interrupt("IRQ"))) void caller3() {
+  callee3(); // expected-warning {{call to function without interrupt attribute could clobber interruptee's VFP registers}}
+}