Skip to content

Commit 9b357d2

Browse files
committed
[clang][ARM] Emit an error when an interrupt handler is called.
Closes #95359.
1 parent b892c59 commit 9b357d2

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ Improvements to Clang's diagnostics
578578
functions that are called from interrupt handlers to prevent clobbering VFP registers
579579
as part of ``-Wextra`` (#GH34876). Following this suggestion leads to unpredictable
580580
behavior. Instead, a new warning, ``-Warm-interrupt-vfp-clobber`` will trigger for
581-
interrupt handlers with VFP enabled.
581+
interrupt handlers with VFP enabled. Calling an interrupt handler is now an error.
582582

583583
Improvements to Clang's time-trace
584584
----------------------------------

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def warn_arm_interrupt_vfp_clobber : Warning<
340340
"interrupt service routine with vfp enabled may clobber the "
341341
"interruptee's vfp state">,
342342
InGroup<DiagGroup<"arm-interrupt-vfp-clobber">>;
343+
def err_arm_interrupt_called : Error<
344+
"interrupt service routine cannot be called directly">;
343345
def warn_interrupt_attribute_invalid : Warning<
344346
"%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to "
345347
"functions that have %select{no parameters|a 'void' return type}1">,

clang/lib/Sema/SemaExpr.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6755,9 +6755,15 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
67556755
unsigned BuiltinID = (FDecl ? FDecl->getBuiltinID() : 0);
67566756

67576757
// Functions with 'interrupt' attribute cannot be called directly.
6758-
if (FDecl && FDecl->hasAttr<AnyX86InterruptAttr>()) {
6759-
Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
6760-
return ExprError();
6758+
if (FDecl) {
6759+
if (FDecl->hasAttr<AnyX86InterruptAttr>()) {
6760+
Diag(Fn->getExprLoc(), diag::err_anyx86_interrupt_called);
6761+
return ExprError();
6762+
}
6763+
if (FDecl->hasAttr<ARMInterruptAttr>()) {
6764+
Diag(Fn->getExprLoc(), diag::err_arm_interrupt_called);
6765+
return ExprError();
6766+
}
67616767
}
67626768

67636769
// X86 interrupt handlers may only call routines with attribute

0 commit comments

Comments
 (0)