GCC modified for the FreeChainXenon project
Find a file
Lewis Hyatt cb05acdcea libcpp: Improve the diagnostic for poisoned identifiers [PR36887]
The PR requests an enhancement to the diagnostic issued for the use of a
poisoned identifier. Currently, we show the location of the usage, but not
the location which requested the poisoning, which would be helpful for the
user if the decision to poison an identifier was made externally, such as
in a library header.

In order to output this information, we need to remember a location_t for
each identifier that has been poisoned, and that data needs to be preserved
as well in a PCH. One option would be to add a field to struct cpp_hashnode,
but there is no convenient place to add it without increasing the size of
the struct for all identifiers. Given this facility will be needed rarely,
it seemed better to add a second hash map, which is handled PCH-wise the
same as the current one in gcc/stringpool.cc. This hash map associates a new
struct cpp_hashnode_extra with each identifier that needs one. Currently
that struct only contains the new location_t, but it could be extended in
the future if there is other ancillary data that may be convenient to put
there for other purposes.

libcpp/ChangeLog:

	PR preprocessor/36887
	* directives.cc (do_pragma_poison): Store in the extra hash map the
	location from which an identifier has been poisoned.
	* lex.cc (identifier_diagnostics_on_lex): When issuing a diagnostic
	for the use of a poisoned identifier, also add a note indicating the
	location from which it was poisoned.
	* identifiers.cc (alloc_node): Convert to template function.
	(_cpp_init_hashtable): Handle the new extra hash map.
	(_cpp_destroy_hashtable): Likewise.
	* include/cpplib.h (struct cpp_hashnode_extra): New struct.
	(cpp_create_reader): Update prototype to...
	* init.cc (cpp_create_reader): ...accept an argument for the extra
	hash table and pass it to _cpp_init_hashtable.
	* include/symtab.h (ht_lookup): New overload for convenience.
	* internal.h (struct cpp_reader): Add EXTRA_HASH_TABLE member.
	(_cpp_init_hashtable): Adjust prototype.

gcc/c-family/ChangeLog:

	PR preprocessor/36887
	* c-opts.cc (c_common_init_options): Pass new extra hash map
	argument to cpp_create_reader().

gcc/ChangeLog:

	PR preprocessor/36887
	* toplev.h (ident_hash_extra): Declare...
	* stringpool.cc (ident_hash_extra): ...this new global variable.
	(init_stringpool): Handle ident_hash_extra as well as ident_hash.
	(ggc_mark_stringpool): Likewise.
	(ggc_purge_stringpool): Likewise.
	(struct string_pool_data_extra): New struct.
	(spd2): New GC root variable.
	(gt_pch_save_stringpool): Use spd2 to handle ident_hash_extra,
	analogous to how spd is used to handle ident_hash.
	(gt_pch_restore_stringpool): Likewise.

gcc/testsuite/ChangeLog:

	PR preprocessor/36887
	* c-c++-common/cpp/diagnostic-poison.c: New test.
	* g++.dg/pch/pr36887.C: New test.
	* g++.dg/pch/pr36887.Hs: New test.
2023-10-23 18:35:26 -04:00
c++tools Daily bump. 2023-06-23 00:16:38 +00:00
config Daily bump. 2023-09-16 00:17:55 +00:00
contrib Daily bump. 2023-10-06 00:17:37 +00:00
fixincludes Daily bump. 2023-08-18 00:16:52 +00:00
gcc libcpp: Improve the diagnostic for poisoned identifiers [PR36887] 2023-10-23 18:35:26 -04:00
gnattools Daily bump. 2023-04-26 00:17:46 +00:00
gotools Daily bump. 2022-08-31 00:16:45 +00:00
include Daily bump. 2023-10-13 00:18:18 +00:00
INSTALL
intl Daily bump. 2023-08-08 00:17:37 +00:00
libada Daily bump. 2023-08-08 00:17:37 +00:00
libatomic libatomic: drop redundant all-multi command 2023-10-23 10:23:14 +02:00
libbacktrace Daily bump. 2023-10-23 00:16:43 +00:00
libcc1 Daily bump. 2023-10-23 00:16:43 +00:00
libcody Daily bump. 2023-06-16 00:17:18 +00:00
libcpp libcpp: Improve the diagnostic for poisoned identifiers [PR36887] 2023-10-23 18:35:26 -04:00
libdecnumber Daily bump. 2023-06-16 00:17:18 +00:00
libffi Daily bump. 2023-10-23 00:16:43 +00:00
libgcc Daily bump. 2023-10-23 00:16:43 +00:00
libgfortran Daily bump. 2023-10-23 00:16:43 +00:00
libgm2 Daily bump. 2023-10-23 00:16:43 +00:00
libgo syscall: add missing type conversion 2023-10-23 14:03:10 -07:00
libgomp Daily bump. 2023-10-23 00:16:43 +00:00
libiberty Daily bump. 2023-08-23 00:17:59 +00:00
libitm Daily bump. 2023-10-23 00:16:43 +00:00
libobjc Daily bump. 2023-10-23 00:16:43 +00:00
libphobos Daily bump. 2023-10-23 00:16:43 +00:00
libquadmath configure, libquadmath: Remove unintended AC_CHECK_LIBM [PR111928] 2023-10-23 14:14:01 +01:00
libsanitizer Daily bump. 2023-10-23 00:16:43 +00:00
libssp Daily bump. 2023-10-23 00:16:43 +00:00
libstdc++-v3 Daily bump. 2023-10-23 00:16:43 +00:00
libvtv Daily bump. 2023-10-23 00:16:43 +00:00
lto-plugin Daily bump. 2023-10-23 00:16:43 +00:00
maintainer-scripts Daily bump. 2023-07-08 00:16:53 +00:00
zlib Daily bump. 2023-10-23 00:16:43 +00:00
.dir-locals.el
.gitattributes
.gitignore .gitignore: do not ignore config.h 2022-07-19 17:07:04 +03:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2023-10-23 00:16:43 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in LoongArch: Reimplement multilib build option handling. 2023-09-15 10:42:12 +08:00
config.guess
config.rpath
config.sub
configure Config,Darwin: Allow for configuring Darwin to use embedded runpath. 2023-10-22 19:30:02 +01:00
configure.ac Config,Darwin: Allow for configuring Darwin to use embedded runpath. 2023-10-22 19:30:02 +01:00
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
depcomp
install-sh
libtool-ldflags
libtool.m4 Config,Darwin: Allow for configuring Darwin to use embedded runpath. 2023-10-22 19:30:02 +01:00
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
MAINTAINERS MAINTAINERS: Fix write after approval name order 2023-10-11 14:53:44 +02:00
Makefile.def sim: add distclean dep for gnulib 2023-10-15 22:40:42 +05:45
Makefile.in sim: add distclean dep for gnulib 2023-10-15 22:40:42 +05:45
Makefile.tpl Makefile.tpl: disable -Werror for feedback stage [PR111663] 2023-10-06 20:25:20 +01:00
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
SECURITY.txt secpol: consistent indentation 2023-10-05 12:00:39 -04:00
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.