If something is static, we can remove it at compile time if unused. This is an important feature for inline functions: static inline functions are meant to be a better replacement for many macros. But sdcc currently does generate function definitions for them even if all uses are inlined. This makes them very inefficient in sdcc.
Philipp
P.S.: This might also make it easier to implement __func__, since it could be just added early in compilation and would then be removed if unused.
P.P.S.: This feature will also be useful for static const variables: When we can replace all uses by immediates, we would not need storage space for them (making them as effient as macros).
The way SDCC currently parses the source is to generate code immediately in the first and only pass. This means that the static (inline) function is generated while parsing the definition. At that point it is still unknown if the function will be unused at the end of the source file. If we keep this behavior the only option is to suppress the actual output to the .asm file at the end.
Another consequence of this behavior is that we cannot generate the external linkage variant of an inline function if the extern inline declaration appears after the inline definition. This is not completely C99 compliant.
E.g.
Maybe we can detect that bar is not yet generated at the last line and start generating it at that point still.
Diff:
__func__ has since been implemented, so that part of the feature request is no longer relevant.
Philipp