erroneous "no return" warning on naked static function

Bug #1836547 reported by Ling LI
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Fix Committed
Undecided
Richard Sandiford

Bug Description

To be clear, it happens only to static naked functions; externs are not affected. Test case:

gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)

static int __attribute__((naked)) fn(int a, int b)
{
   asm("bx lr");
}

And the message reads:
warning: no return statement in function returning non-void [-Wreturn-type]

A fake C return statement removes this warning, but may add dead code. More importantly, armclang doesn't allow return in naked functions, extern or static; it treats it as an error.

It might worth fixing for reduced annoyance and better consistency between static/extern and also gcc-arm/armclang.

Revision history for this message
Ramana Radhakrishnan (ramana) wrote :

Again invalid, I don't see an easy route to fix this as the compiler cannot reason about code inside an inline assembler block.

Changed in gcc-arm-embedded:
status: New → Invalid
Revision history for this message
Richard Sandiford (rsandifo-arm) wrote :

The C++ compiler handles this correctly, but the C compiler doesn't.

Changed in gcc-arm-embedded:
status: Invalid → Confirmed
assignee: nobody → Richard Sandiford (rsandifo-arm)
status: Confirmed → In Progress
Revision history for this message
Richard Sandiford (rsandifo-arm) wrote :

Thanks for the report. This is now fixed in GCC 8 branch and later. The fix should be in the next release of the GNU Arm Embedded Toolchain.

Changed in gcc-arm-embedded:
status: In Progress → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.