GCC modified for the FreeChainXenon project
Find a file
Alex Coplan 06280a906c c-family: Implement __has_feature and __has_extension [PR60512]
This patch implements clang's __has_feature and __has_extension in GCC.
Currently the patch aims to implement all documented features (and some
undocumented ones) following the documentation at
https://clang.llvm.org/docs/LanguageExtensions.html with the exception
of the legacy features for C++ type traits.  These are omitted, since as
the clang documentation notes, __has_builtin is the correct "modern" way
to query for these (which GCC already implements).

gcc/c-family/ChangeLog:

	PR c++/60512
	* c-common.cc (struct hf_feature_info): New.
	(c_common_register_feature): New.
	(init_has_feature): New.
	(has_feature_p): New.
	* c-common.h (c_common_has_feature): New.
	(c_family_register_lang_features): New.
	(c_common_register_feature): New.
	(has_feature_p): New.
	* c-lex.cc (init_c_lex): Plumb through has_feature callback.
	(c_common_has_builtin): Generalize and move common part ...
	(c_common_lex_availability_macro): ... here.
	(c_common_has_feature): New.
	* c-ppoutput.cc (init_pp_output): Plumb through has_feature.

gcc/c/ChangeLog:

	PR c++/60512
	* c-lang.cc (c_family_register_lang_features): New.
	* c-objc-common.cc (struct c_feature_info): New.
	(c_register_features): New.
	* c-objc-common.h (c_register_features): New.

gcc/cp/ChangeLog:

	PR c++/60512
	* cp-lang.cc (c_family_register_lang_features): New.
	* cp-objcp-common.cc (struct cp_feature_selector): New.
	(cp_feature_selector::has_feature): New.
	(struct cp_feature_info): New.
	(cp_register_features): New.
	* cp-objcp-common.h (cp_register_features): New.

gcc/ChangeLog:

	PR c++/60512
	* doc/cpp.texi: Document __has_{feature,extension}.

gcc/objc/ChangeLog:

	PR c++/60512
	* objc-act.cc (struct objc_feature_info): New.
	(objc_nonfragile_abi_p): New.
	(objc_common_register_features): New.
	* objc-act.h (objc_common_register_features): New.
	* objc-lang.cc (c_family_register_lang_features): New.

gcc/objcp/ChangeLog:

	PR c++/60512
	* objcp-lang.cc (c_family_register_lang_features): New.

libcpp/ChangeLog:

	PR c++/60512
	* include/cpplib.h (struct cpp_callbacks): Add has_feature.
	(enum cpp_builtin_type): Add BT_HAS_{FEATURE,EXTENSION}.
	* init.cc: Add __has_{feature,extension}.
	* macro.cc (_cpp_builtin_macro_text): Handle
	BT_HAS_{FEATURE,EXTENSION}.

gcc/testsuite/ChangeLog:

	PR c++/60512
	* c-c++-common/has-feature-common.c: New test.
	* c-c++-common/has-feature-pedantic.c: New test.
	* g++.dg/ext/has-feature.C: New test.
	* gcc.dg/asan/has-feature-asan.c: New test.
	* gcc.dg/has-feature.c: New test.
	* gcc.dg/ubsan/has-feature-ubsan.c: New test.
	* obj-c++.dg/has-feature.mm: New test.
	* objc.dg/has-feature.m: New test.

Co-Authored-By: Iain Sandoe <iain@sandoe.co.uk>
2023-11-27 10:42:55 +00:00
.github
c++tools
config
contrib Daily bump. 2023-11-24 00:17:53 +00:00
fixincludes Daily bump. 2023-11-23 00:18:14 +00:00
gcc c-family: Implement __has_feature and __has_extension [PR60512] 2023-11-27 10:42:55 +00:00
gnattools
gotools
include
INSTALL
libada
libatomic
libbacktrace
libcc1 Daily bump. 2023-11-17 00:17:33 +00:00
libcody
libcpp c-family: Implement __has_feature and __has_extension [PR60512] 2023-11-27 10:42:55 +00:00
libdecnumber
libffi
libgcc Daily bump. 2023-11-25 00:17:46 +00:00
libgfortran
libgm2
libgo
libgomp Daily bump. 2023-11-25 00:17:46 +00:00
libiberty Daily bump. 2023-11-16 00:17:42 +00:00
libitm
libobjc
libphobos Daily bump. 2023-11-22 00:17:52 +00:00
libquadmath
libsanitizer Daily bump. 2023-11-22 00:17:52 +00:00
libssp
libstdc++-v3 Daily bump. 2023-11-25 00:17:46 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-11-24 00:17:53 +00:00
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 Build: fix error in fixinclude configure 2023-11-22 11:54:33 +01:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Add myself to write after approval and DCO 2023-11-24 10:43:54 +11:00
Makefile.def
Makefile.in Makefile.tpl: Avoid race condition in generating site.exp from the top level 2023-11-19 11:07:09 -05:00
Makefile.tpl Makefile.tpl: Avoid race condition in generating site.exp from the top level 2023-11-19 11:07:09 -05:00
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.