Go to file
Nathan Sidwell ad1a3914ae [PR 80005] Fix __has_include
__has_include is funky in that it is macro-like from the POV of #ifdef and
friends, but lexes its parenthesize argument #include-like.  We were
failing the second part of that, because we used a forwarding macro to an
internal name, and hence always lexed the argument in macro-parameter
context.  We componded that by not setting the right flag when lexing, so
it didn't even know.  Mostly users got lucky.

This reimplements the handline.
1) Remove the forwarding, but declare object-like macros that
expand to themselves.  This satisfies the #ifdef requirement

2) Correctly set angled_brackets when lexing the parameter.  This tells
the lexer (a) <...> is a header name and (b) "..." is too (not a string).

3) Remove the in__has_include lexer state, just tell find_file that that's
what's happenning, so it doesn't emit an error.

We lose the (undocumented) ability to #undef __has_include.  That may well
have been an accident of implementation.  There are no tests for it.

We gain __has_include behaviour for all users of the preprocessors -- not
just the C-family ones that defined a forwarding macro.

	libcpp/
	PR preprocessor/80005
	* include/cpplib.h (BT_HAS_ATTRIBUTE): Fix comment.
	* internal.h (struct lexer_state): Delete in__has_include field.
	(struct spec_nodes): Rename n__has_include{,_next}__ fields.
	(_cpp_defined_macro_p): New.
	(_cpp_find_file): Add has_include parm.
	* directives.c (lex_macro_node): Combine defined,
	__has_inline{,_next} checking.
	(do_ifdef, do_ifndef): Use _cpp_defined_macro_p.
	(_cpp_init_directives): Refactor.
	* expr.c (parse_defined): Use _cpp_defined_macro_p.
	(eval_token): Adjust parse_has_include calls.
	(parse_has_include): Add OP parameter.  Reimplement.
	* files.c (_cpp_find_file): Add HAS_INCLUDE parm.  Use it to
	inhibit error message.
	(_cpp_stack_include): Adjust _cpp_find_file call.
	(_cpp_fake_include, _cpp_compare_file_date): Likewise.
	(open_file_failed): Remove in__has_include check.
	(_cpp_has_header): Adjust _cpp_find_file call.
	* identifiers.c (_cpp_init_hashtable): Don't init
	__has_include{,_next} here ...
	* init.c (cpp_init_builtins): ... init them here.  Define as
	macros.
	(cpp_read_main_file): Adjust _cpp_find_file call.
	* pch.c (cpp_read_state): Adjust __has_include{,_next} access.
	* traditional.c (_cpp_scan_out_locgical_line): Likewise.

	gcc/c-family/
	PR preprocessor/80005
	* c-cppbuiltins.c (c_cpp_builtins): Don't define __has_include{,_next}.

	gcc/testsuite/
	PR preprocessor/80005
	* g++.dg/cpp1y/feat-cxx14.C: Adjust.
	* g++.dg/cpp1z/feat-cxx17.C: Adjust.
	* g++.dg/cpp2a/feat-cxx2a.C: Adjust.
	* g++.dg/cpp/pr80005.C: New.
2020-01-20 05:39:59 -08:00
config
contrib contrib: New remotes structure for vendor and personal refs 2020-01-20 10:37:29 +00:00
fixincludes
gcc [PR 80005] Fix __has_include 2020-01-20 05:39:59 -08:00
gnattools
gotools
include OpenACC 'acc_get_property' cleanup 2020-01-10 23:24:36 +01:00
INSTALL
intl
libada Update copyright years. 2020-01-01 12:51:42 +01:00
libatomic Update copyright years. 2020-01-01 12:51:42 +01:00
libbacktrace Update copyright years. 2020-01-01 12:51:42 +01:00
libcc1 init.c (build_new): Add location_t parameter and use it throughout. 2020-01-07 17:58:18 +00:00
libcpp [PR 80005] Fix __has_include 2020-01-20 05:39:59 -08:00
libdecnumber Update copyright years. 2020-01-01 12:51:42 +01:00
libffi
libgcc libgcc: cris: config/cris/arit.c (DS): Apply attribute __fallthrough__. 2020-01-18 16:38:56 +01:00
libgfortran PR93234 INQUIRE on pre-assigned files of ROUND and SIGN properties 2020-01-17 19:36:03 -08:00
libgo gotest: don't use local 2020-01-10 15:28:20 +00:00
libgomp Rename acc_device_gcn to acc_device_radeon 2020-01-17 18:11:52 +00:00
libhsail-rt Update copyright years. 2020-01-01 12:51:42 +01:00
libiberty [libiberty] Update demangler to handle co_await operator. 2020-01-18 12:15:12 +00:00
libitm Update copyright years. 2020-01-01 12:51:42 +01:00
libobjc Fix windows libobjc build (PR libobjc/93099) 2020-01-01 14:16:35 -08:00
liboffloadmic OpenACC 'acc_get_property' cleanup 2020-01-10 23:24:36 +01:00
libphobos Update copyright years. 2020-01-01 12:51:42 +01:00
libquadmath Update copyright years. 2020-01-01 12:51:42 +01:00
libsanitizer
libssp Update copyright years. 2020-01-01 12:51:42 +01:00
libstdc++-v3 Clean up references to Subversion in documentation sources. 2020-01-19 17:12:29 -08:00
libvtv Update copyright years. 2020-01-01 12:51:42 +01:00
lto-plugin Update copyright years. 2020-01-01 12:51:42 +01:00
maintainer-scripts Replace update_web_docs_libstdcxx_svn with update_web_docs_libstdcxx_git 2020-01-13 21:40:44 +00:00
zlib
.dir-locals.el
.gitattributes Add *.md diff=md. 2020-01-15 14:29:53 +01:00
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Add *.md diff=md. 2020-01-15 14:29:53 +01:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Update my email address. 2020-01-13 22:10:14 +03:00
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
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.