Bug 117362 - target() attribute applied to wrong function, or wrong check order in conjunction with interrupt() attribute
Summary: target() attribute applied to wrong function, or wrong check order in conjunc...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 14.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-30 09:56 UTC by Christian Schmidt
Modified: 2024-10-30 19:17 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: arm-none-eabi
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schmidt 2024-10-30 09:56:34 UTC
This bug exists both in 14.2.1 20240921 and 15.0.0 20241006.

The source code (simplified):

static __attribute__ ((used,target("general-regs-only"),interrupt("IRQ"))) void irqa (void) {}
static __attribute__ ((used,interrupt("IRQ"))) void irqb (void) {}
static __attribute__ ((used,interrupt("IRQ"))) void irqc (void) {}
static void irqd [[gnu::used,gnu::interrupt("IRQ"),gnu::target("general-regs-only")]] (void) {}

The command line:

arm-none-eabi-gcc -std=gnu23 -g -O2 -Wall -Werror -Wextra -Wpedantic -Wshadow -pipe -mcpu=cortex-a5 -mfpu=vfpv4-d16 -mfloat-abi=hard -o t.o -c t.c
t.c:1:1: error: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Werror=attributes]
    1 | static __attribute__ ((used,target("general-regs-only"),interrupt("IRQ"))) void irqa (void) {}
      | ^~~~~~
t.c:3:1: error: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Werror=attributes]
    3 | static __attribute__ ((used,interrupt("IRQ"))) void irqc (void) {}
      | ^~~~~~
t.c:4:1: error: FP registers might be clobbered despite 'interrupt' attribute: compile with '-mgeneral-regs-only' [-Werror=attributes]
    4 | static void irqd [[gnu::used,gnu::interrupt("IRQ"),gnu::target("general-regs-only")]] (void) {}
      | ^~~~~~
cc1: all warnings being treated as errors

The error is only reported on the first and third function, although the first should be correct and the second and third should report the error. It is as though the target attribute is applied to the wrong (second) function, or processing of checks for the interrupt() attribute checks the wrong state. This happens for both C23 and classic attribute syntax. Ordering of the target and interrupt attributes seems to not matter.
Comment 1 Christian Schmidt 2024-10-30 09:58:40 UTC
This bug is related to 115263 which mentions the wrong documentation of the general-regs-only attribute, but does not give any example for reproduction.