diff options
author | Joseph Myers <joseph@codesourcery.com> | 2022-09-29 22:59:22 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2022-09-29 22:59:22 +0000 |
commit | 3a3516bc4a0a0307cd48dce044a497e95816c8f5 (patch) | |
tree | dc36354d8478aea7275978397c3f4634444c8358 /libgcc | |
parent | 7ea258a13a115e9e73d60f59369d16892ed07435 (diff) | |
download | gcc-3a3516bc4a0a0307cd48dce044a497e95816c8f5.zip gcc-3a3516bc4a0a0307cd48dce044a497e95816c8f5.tar.gz gcc-3a3516bc4a0a0307cd48dce044a497e95816c8f5.tar.bz2 |
c: C2x noreturn attribute
C2x adds a standard [[noreturn]] attribute (which can also be spelt
[[_Noreturn]] for use with <stdnoreturn.h>), so allowing non-returning
functions to be declared in a manner compatible with C++; the
_Noreturn function specifier remains available but is marked
obsolescent.
Implement this attribute. It's more restricted than GNU
__attribute__ ((noreturn)) - that allows function pointers but using
the standard attribute on a function pointer is a constraint
violation. Thus, the attribute gets its own handler that checks for a
FUNCTION_DECL before calling the handler for the GNU attribute. Tests
for the attribute are based on those for C11 _Noreturn and for other
C2x attributes.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/c-family/
* c-lex.cc (c_common_has_attribute): Handle noreturn attribute for
C.
gcc/c/
* c-decl.cc (handle_std_noreturn_attribute): New function.
(std_attribute_table): Add _Noreturn and noreturn.
gcc/testsuite/
* gcc.dg/c2x-attr-noreturn-1.c, gcc.dg/c2x-attr-noreturn-2.c,
gcc.dg/c2x-attr-noreturn-3.c: New tests.
* gcc.dg/c2x-has-c-attribute-2.c: Also test __has_c_attribute for
noreturn attribute.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions