[PATCH] rtems: Improve RTEMS_NO_RETURN attribute
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Oct 6 16:36:47 UTC 2020
On 06/10/2020 17:55, Joel Sherrill wrote:
>
>
> On Tue, Oct 6, 2020 at 10:41 AM Sebastian Huber
> <sebastian.huber at embedded-brains.de
> <mailto:sebastian.huber at embedded-brains.de>> wrote:
>
> On 06/10/2020 17:34, Joel Sherrill wrote:
>
> >
> > On Tue, Oct 6, 2020 at 9:46 AM Sebastian Huber
> > <sebastian.huber at embedded-brains.de
> <mailto:sebastian.huber at embedded-brains.de>
> > <mailto:sebastian.huber at embedded-brains.de
> <mailto:sebastian.huber at embedded-brains.de>>> wrote:
> >
> > On 06/10/2020 16:37, Joel Sherrill wrote:
> >
> > > How does it break the API? It looks like a change of
> annotation.
> > > Shouldn't be a big deal unless I am misunderstanding
> something.
> >
> > Please have a look at:
> >
> > https://lists.rtems.org/pipermail/devel/2020-October/062577.html
> >
> >
> > Looks like basically the same code. What does this break? Why
> the concern?
>
> The C11/C++11 attribute syntax is less flexible compared to the GNU
> attributes. For example:
>
> echo "_Noreturn void ok(void);" > test.c
>
> echo "void error(void) _Noreturn;" >> test.c
>
> gcc test.c
>
> test.c: In function ‘error’:
> test.c:2:1: error: ‘_Noreturn’ in empty declaration
> void error(void) _Noreturn;
> ^~~~
> test.c:2:18: warning: empty declaration
> void error(void) _Noreturn;
> ^~~~~~~~~
> test.c:2:1: error: expected ‘{’ at end of input
> void error(void) _Noreturn;
> ^~~~
>
>
> Yuck. I can see why they did the placement kind of. Makes it like const
> or static but it uses an odd keyword with leading _ and capital letter
> which is rather insane.
All new keywords in C are like this. You can include <stdnoreturn.h> to
get something without the underscore.
>
> What's the positive value for doing this? Does llvm or some static
> analyser like it better?
The positive thing is being in line with the standard.
>
> C11 has improvements but it also has more than one thing I
> question if they really thought through. :(
Yes, I guess not every C compiler vendor liked the GNU attribute stuff.
C++11 has a similar issue:
[[noreturn]] void ok(void);
void error(void) [[noreturn]];
g++ test.cc
test.cc:2:29: warning: attribute ignored [-Wattributes]
void error(void) [[noreturn]];
^
test.cc:2:29: note: an attribute that appertains to a type-specifier is
ignored
More information about the devel
mailing list