__attribute__((naked)) with C code

Joseph Sible <[email protected]> Fri, 2 Jun 2017 21:27:41 -0400
Newsgroups gmane.comp.hardware.avr.gcc
Message-ID <CABpewhH04Y8osNOpfObw0zCXVS4c8DPtbr+zCXGs=aLJTcmuiw@mail.gmail.com>
I notice that GCC's documentation [1] says "Only basic asm statements
can safely be included in naked functions (see Basic Asm). While using
extended asm or a mixture of basic asm and C code may appear to work,
they cannot be depended upon to work reliably and are not supported."
However, a lot of our example code contains naked functions with C
code, such as [2], [3], and [4], as well as indirectly via ISR_NAKED,
such as [5] and [6]. Is there a reason that GCC's documentation
doesn't apply to us here, or is it only by sheer luck that none of
these have resulted in problems in practice?

[1] https://gcc.gnu.org/onlinedocs/gcc/AVR-Function-Attributes.html
[2] http://www.nongnu.org/avr-libc/user-manual/mem_sections.html#c_sections
[3] http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset
[4] http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html#details
[5] http://www.nongnu.org/avr-libc/user-manual/group__avr__time.html#ga15aea81a8985a4c3cc9c8b00a06f5d31
[6] http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html#attr_interrupt