![]() Apparently some programs in the wild use #if __has_attribute(musttail) __attribute__((musttail)) return foo (); #else return foo (); #endif clang supports musttail both as a standard attribute ([[clang::musttail]] which we also support for compatibility) and the above worked just fine with GCC 14 which had __has_attribute(musttail) 0. Now that it is 0, this doesn't compile anymore. So, either we need to ensure that __has_attribute(musttail) is 0 and just __has_c{,pp}_attribute({gnu,clang}::musttail) are non-zero, or IMHO better we just make it work in the attribute form, especially for C < C23 I can see why some projects would prefer that form. While [[gnu::musttail]] is rejected as an error in C11 etc. before GCC 15, rather than just handled as an unknown attribute. I view this as both a regression and compatibility issue. The patch handles it in similar spots to fallthrough/assume attributes inside of __attribute__ for C, and for C++ enables mixing of standard [[]] and GNU __attribute__(()) attributes at the start of statements in any order. While working on it, I've noticed we weren't diagnosing arguments to the clang::musttail attribute (fixed by the c-attribs.cc hunk) and newly on the __attribute__ form attribute (in that case the arguments aren't just skipped, they are always parsed and because we don't call decl_attributes etc., it wouldn't be diagnosed without a manual check). 2025-03-18 Jakub Jelinek <jakub@redhat.com> PR c/116545 gcc/ * doc/extend.texi (musttail statement attribute): Document that musttail GNU attribute can be used as well. gcc/c-family/ * c-attribs.cc (c_common_clang_attributes): Add musttail. gcc/c/ * c-parser.cc (c_parser_declaration_or_fndef): Parse __attribute__((musttail)) return. (c_parser_handle_musttail): Diagnose attribute arguments. (c_parser_statement_after_labels): Parse __attribute__((musttail)) return. gcc/cp/ * parser.cc (cp_parser_statement): Call cp_parser_attributes_opt rather than cp_parser_std_attribute_spec_seq. (cp_parser_jump_statement): Diagnose gnu::musttail attributes with no arguments. gcc/testsuite/ * c-c++-common/attr-fallthrough-2.c: Adjust expected diagnostics for C++. * c-c++-common/musttail15.c: New test. * c-c++-common/musttail16.c: New test. * c-c++-common/musttail17.c: New test. * c-c++-common/musttail18.c: New test. * c-c++-common/musttail19.c: New test. * c-c++-common/musttail20.c: New test. * c-c++-common/musttail21.c: New test. * c-c++-common/musttail22.c: New test. * c-c++-common/musttail23.c: New test. * c-c++-common/musttail24.c: New test. * g++.dg/musttail7.C: New test. * g++.dg/musttail8.C: New test. * g++.dg/musttail12.C: New test. * g++.dg/musttail13.C: New test. * g++.dg/musttail14.C: New test. * g++.dg/ext/pr116545.C: New test. |
||
---|---|---|
.forgejo | ||
.github | ||
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgcobol | ||
libgfortran | ||
libgm2 | ||
libgo | ||
libgomp | ||
libgrust | ||
libiberty | ||
libitm | ||
libobjc | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.b4-config | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
COPYING3 | ||
COPYING3.LIB | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
lt~obsolete.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
SECURITY.txt | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.