<feed xmlns='http://www.w3.org/2005/Atom'>
<title>gcc.git/libcpp/expr.c, branch basepoints/gcc-12</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/'/>
<entry>
<title>c++, libcpp: Use make_signed_t&lt;size_t&gt; in the 1z diagnostics</title>
<updated>2021-02-04T17:30:45+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2021-02-04T17:30:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=e91f9da57928ab10e2206c64ce490477d3b46ec1'/>
<id>e91f9da57928ab10e2206c64ce490477d3b46ec1</id>
<content type='text'>
The following patch uses make_signed_t&lt;size_t&gt; instead of
make_signed&lt;size_t&gt;::type in the diagnostics, because the former is shorter.
It is true that one can't use make_signed&lt;size_t&gt;::type in C++11 code (which
is why I haven't changed it in the testcase which is c++11 effective
target), but the message talks about C++23 and make_signed_t is a C++14 and
later feature, so I think it is fine.

2021-02-04  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	* expr.c (cpp_classify_number): Use make_signed_t&lt;size_t&gt; instead of
	make_signed&lt;size_t&gt;::type in the diagnostics.

	* g++.dg/warn/Wsize_t-literals.C: Expect make_signed_t&lt;size_t&gt; instead
	of make_signed&lt;size_t&gt;::type in the diagnostics.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The following patch uses make_signed_t&lt;size_t&gt; instead of
make_signed&lt;size_t&gt;::type in the diagnostics, because the former is shorter.
It is true that one can't use make_signed&lt;size_t&gt;::type in C++11 code (which
is why I haven't changed it in the testcase which is c++11 effective
target), but the message talks about C++23 and make_signed_t is a C++14 and
later feature, so I think it is fine.

2021-02-04  Jakub Jelinek  &lt;jakub@redhat.com&gt;

	* expr.c (cpp_classify_number): Use make_signed_t&lt;size_t&gt; instead of
	make_signed&lt;size_t&gt;::type in the diagnostics.

	* g++.dg/warn/Wsize_t-literals.C: Expect make_signed_t&lt;size_t&gt; instead
	of make_signed&lt;size_t&gt;::type in the diagnostics.
</pre>
</div>
</content>
</entry>
<entry>
<title>c++: Implement C++23 P0330 - Literal Suffixes for ptrdiff_t and size_t.</title>
<updated>2021-02-03T17:12:31+00:00</updated>
<author>
<name>Ed Smith-Rowland</name>
<email>3dw4rd@verizon.net</email>
</author>
<published>2021-02-02T21:11:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=1f69e63cfcc664fd7382dd877846007652a01dcf'/>
<id>1f69e63cfcc664fd7382dd877846007652a01dcf</id>
<content type='text'>
Integer literal suffixes for signed size ('z') and unsigned size
(some permutation od 'zu') are provided as a language addition.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_size_t_suffix.
	* c-lex.c (interpret_integer): Set node type for size literal.

libcpp/ChangeLog:

	* expr.c (interpret_int_suffix): Detect 'z' integer suffix.
	(cpp_classify_number): Compat warning for use of 'z' suffix.
	* include/cpplib.h (struct cpp_options): New flag.
	(enum cpp_warning_reason): New flag.
	(CPP_N_USERDEF): Comment C++0x -&gt; C++11.
	(CPP_N_SIZE_T): New flag for cpp_classify_number.
	* init.c (cpp_set_lang): Initialize new flag.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/udlit-shadow-neg.C: Test for 'z' and 'zu' shadowing.
	* g++.dg/cpp23/feat-cxx2b.C: New test.
	* g++.dg/cpp23/size_t-literals.C: New test.
	* g++.dg/warn/Wsize_t-literals.C: New test.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Integer literal suffixes for signed size ('z') and unsigned size
(some permutation od 'zu') are provided as a language addition.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.c (c_cpp_builtins): Define __cpp_size_t_suffix.
	* c-lex.c (interpret_integer): Set node type for size literal.

libcpp/ChangeLog:

	* expr.c (interpret_int_suffix): Detect 'z' integer suffix.
	(cpp_classify_number): Compat warning for use of 'z' suffix.
	* include/cpplib.h (struct cpp_options): New flag.
	(enum cpp_warning_reason): New flag.
	(CPP_N_USERDEF): Comment C++0x -&gt; C++11.
	(CPP_N_SIZE_T): New flag for cpp_classify_number.
	* init.c (cpp_set_lang): Initialize new flag.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/udlit-shadow-neg.C: Test for 'z' and 'zu' shadowing.
	* g++.dg/cpp23/feat-cxx2b.C: New test.
	* g++.dg/cpp23/size_t-literals.C: New test.
	* g++.dg/warn/Wsize_t-literals.C: New test.
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright years.</title>
<updated>2021-01-04T09:26:59+00:00</updated>
<author>
<name>Jakub Jelinek</name>
<email>jakub@redhat.com</email>
</author>
<published>2021-01-04T09:26:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=99dee82307f1e163e150c9c810452979994047ce'/>
<id>99dee82307f1e163e150c9c810452979994047ce</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>preprocessor: Add deferred macros</title>
<updated>2020-11-24T16:31:03+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-11-24T16:23:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=13f93cf5336ec0085277b9a5ef88c02359527170'/>
<id>13f93cf5336ec0085277b9a5ef88c02359527170</id>
<content type='text'>
Deferred macros are needed for C++ modules.  Header units may export
macro definitions and undefinitions.  These are resolved lazily at the
point of (potential) use.  (The language specifies that, it's not just
a useful optimization.)  Thus, identifier nodes grow a 'deferred'
field, which fortunately doesn't expand the structure on 64-bit
systems as there was padding there.  This is non-zero on NT_MACRO
nodes, if the macro is deferred.  When such an identifier is lexed, it
is resolved via a callback that I added recently.  That will either
provide the macro definition, or discover it there was an overriding
undef.  Either way the identifier is no longer a deferred macro.
Notice it is now possible for NT_MACRO nodes to have a NULL macro
expansion.

	libcpp/
	* include/cpplib.h (struct cpp_hashnode): Add deferred field.
	(cpp_set_deferred_macro): Define.
	(cpp_get_deferred_macro): Declare.
	(cpp_macro_definition): Reformat, add overload.
	(cpp_macro_definition_location): Deal with deferred macro.
	(cpp_alloc_token_string, cpp_compare_macro): Declare.
	* internal.h (_cpp_notify_macro_use): Return bool
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (do_undef): Check macro is not undef before
	warning.
	(do_ifdef, do_ifndef): Deal with deferred macro.
	* expr.c (parse_defined): Likewise.
	* lex.c (cpp_allocate_token_string): Break out of ...
	(create_literal): ... here.  Call it.
	(cpp_maybe_module_directive): Deal with deferred macro.
	* macro.c (cpp_get_token_1): Deal with deferred macro.
	(warn_of_redefinition): Deal with deferred macro.
	(compare_macros): Rename to ...
	(cpp_compare_macro): ... here.  Make extern.
	(cpp_get_deferred_macro): New.
	(_cpp_notify_macro_use): Deal with deferred macro, return bool
	indicating definedness.
	(cpp_macro_definition): Deal with deferred macro.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Deferred macros are needed for C++ modules.  Header units may export
macro definitions and undefinitions.  These are resolved lazily at the
point of (potential) use.  (The language specifies that, it's not just
a useful optimization.)  Thus, identifier nodes grow a 'deferred'
field, which fortunately doesn't expand the structure on 64-bit
systems as there was padding there.  This is non-zero on NT_MACRO
nodes, if the macro is deferred.  When such an identifier is lexed, it
is resolved via a callback that I added recently.  That will either
provide the macro definition, or discover it there was an overriding
undef.  Either way the identifier is no longer a deferred macro.
Notice it is now possible for NT_MACRO nodes to have a NULL macro
expansion.

	libcpp/
	* include/cpplib.h (struct cpp_hashnode): Add deferred field.
	(cpp_set_deferred_macro): Define.
	(cpp_get_deferred_macro): Declare.
	(cpp_macro_definition): Reformat, add overload.
	(cpp_macro_definition_location): Deal with deferred macro.
	(cpp_alloc_token_string, cpp_compare_macro): Declare.
	* internal.h (_cpp_notify_macro_use): Return bool
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (do_undef): Check macro is not undef before
	warning.
	(do_ifdef, do_ifndef): Deal with deferred macro.
	* expr.c (parse_defined): Likewise.
	* lex.c (cpp_allocate_token_string): Break out of ...
	(create_literal): ... here.  Call it.
	(cpp_maybe_module_directive): Deal with deferred macro.
	* macro.c (cpp_get_token_1): Deal with deferred macro.
	(warn_of_redefinition): Deal with deferred macro.
	(compare_macros): Rename to ...
	(cpp_compare_macro): ... here.  Make extern.
	(cpp_get_deferred_macro): New.
	(_cpp_notify_macro_use): Deal with deferred macro, return bool
	indicating definedness.
	(cpp_macro_definition): Deal with deferred macro.
</pre>
</div>
</content>
</entry>
<entry>
<title>c: C2x binary constants</title>
<updated>2020-11-13T22:45:22+00:00</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2020-11-13T22:45:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=e400a64936efdc2424044aa74c0424df16242d2d'/>
<id>e400a64936efdc2424044aa74c0424df16242d2d</id>
<content type='text'>
C2x adds binary integer constants (approved at the last WG14 meeting,
though not yet added to the working draft in git).  Configure libcpp
to consider these a standard feature in C2x mode, with appropriate
updates to diagnostics including support for diagnosing them with
-std=c2x -Wc11-c2x-compat.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/testsuite/
2020-11-13  Joseph Myers  &lt;joseph@codesourcery.com&gt;

	* gcc.dg/binary-constants-2.c, gcc.dg/binary-constants-3.c,
	gcc.dg/system-binary-constants-1.c: Update expected diagnostics.
	* gcc.dg/c11-binary-constants-1.c,
	gcc.dg/c11-binary-constants-2.c, gcc.dg/c2x-binary-constants-1.c,
	gcc.dg/c2x-binary-constants-2.c, gcc.dg/c2x-binary-constants-3.c:
	New tests.

libcpp/
2020-11-13  Joseph Myers  &lt;joseph@codesourcery.com&gt;

	* expr.c (cpp_classify_number): Update diagnostic for binary
	constants for C.  Also diagnose binary constants for
	-Wc11-c2x-compat.
	* init.c (lang_defaults): Enable binary constants for GNUC2X and
	STDC2X.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
C2x adds binary integer constants (approved at the last WG14 meeting,
though not yet added to the working draft in git).  Configure libcpp
to consider these a standard feature in C2x mode, with appropriate
updates to diagnostics including support for diagnosing them with
-std=c2x -Wc11-c2x-compat.

Bootstrapped with no regressions for x86_64-pc-linux-gnu.

gcc/testsuite/
2020-11-13  Joseph Myers  &lt;joseph@codesourcery.com&gt;

	* gcc.dg/binary-constants-2.c, gcc.dg/binary-constants-3.c,
	gcc.dg/system-binary-constants-1.c: Update expected diagnostics.
	* gcc.dg/c11-binary-constants-1.c,
	gcc.dg/c11-binary-constants-2.c, gcc.dg/c2x-binary-constants-1.c,
	gcc.dg/c2x-binary-constants-2.c, gcc.dg/c2x-binary-constants-3.c:
	New tests.

libcpp/
2020-11-13  Joseph Myers  &lt;joseph@codesourcery.com&gt;

	* expr.c (cpp_classify_number): Update diagnostic for binary
	constants for C.  Also diagnose binary constants for
	-Wc11-c2x-compat.
	* init.c (lang_defaults): Enable binary constants for GNUC2X and
	STDC2X.
</pre>
</div>
</content>
</entry>
<entry>
<title>cpplib:  Macro use location and comparison</title>
<updated>2020-11-02T16:56:38+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-11-02T16:29:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=e9a2e208dd763bf71b0cc9db8526ef8f47ee289e'/>
<id>e9a2e208dd763bf71b0cc9db8526ef8f47ee289e</id>
<content type='text'>
Our macro use hook passes a location, but doesn't recieve it from the
using location.  This patch adds the extra location_t parameter and
passes it though.

A second cleanup is breaking out the macro comparison code from the
redefinition warning.  That;ll turn out useful for modules.

Finally, there's a filename comparison needed for the location
optimization of rewinding from line 2 (occurs during the emission of
builtin macros).

	libcpp/
	* internal.h (_cpp_notify_macro_use): Add location parm.
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (_cpp_do_file_change): Check we've not changed file
	when optimizing a rewind.
	(do_ifdef): Pass location to _cpp_maybe_notify_macro_use.
	(do_ifndef): Likewise.  Delete obsolete comment about powerpc.
	* expr.c (parse_defined): Pass location to
	_cpp_maybe_notify_macro_use.
	* macro.c (enter_macro_context): Likewise.
	(warn_of_redefinition): Break out helper function.  Call it.
	(compare_macros): New function broken out of warn_of_redefinition.
	(_cpp_new_macro): Zero all fields.
	(_cpp_notify_macro_use): Add location parameter.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Our macro use hook passes a location, but doesn't recieve it from the
using location.  This patch adds the extra location_t parameter and
passes it though.

A second cleanup is breaking out the macro comparison code from the
redefinition warning.  That;ll turn out useful for modules.

Finally, there's a filename comparison needed for the location
optimization of rewinding from line 2 (occurs during the emission of
builtin macros).

	libcpp/
	* internal.h (_cpp_notify_macro_use): Add location parm.
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (_cpp_do_file_change): Check we've not changed file
	when optimizing a rewind.
	(do_ifdef): Pass location to _cpp_maybe_notify_macro_use.
	(do_ifndef): Likewise.  Delete obsolete comment about powerpc.
	* expr.c (parse_defined): Pass location to
	_cpp_maybe_notify_macro_use.
	* macro.c (enter_macro_context): Likewise.
	(warn_of_redefinition): Break out helper function.  Call it.
	(compare_macros): New function broken out of warn_of_redefinition.
	(_cpp_new_macro): Zero all fields.
	(_cpp_notify_macro_use): Add location parameter.
</pre>
</div>
</content>
</entry>
<entry>
<title>preprocessor: Make __has_include a builtin macro [PR93452]</title>
<updated>2020-01-28T16:02:17+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-01-28T15:58:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=3d056cbfb3484f4037b34c908b26e1c6776c86b5'/>
<id>3d056cbfb3484f4037b34c908b26e1c6776c86b5</id>
<content type='text'>
The clever hack of '#define __has_include __has_include' breaks -dD
and -fdirectives-only, because that emits definitions.  This turns
__has_include into a proper builtin macro.  Thus it's never emitted
via -dD, and because use outside of directive processing is undefined,
we can just expand it anywhere.

	PR preprocessor/93452
	* internal.h (struct spec_nodes): Drop n__has_include{,_next}.
	* directives.c (lex_macro_node): Don't check __has_include redef.
	* expr.c (eval_token): Drop __has_include eval.
	(parse_has_include): Move to ...
	* macro.c (builtin_has_include): ... here.
	(_cpp_builtin_macro_text): Eval __has_include{,_next}.
	* include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_INCLUDE{,_NEXT}.
	* init.c (builtin_array): Add them.
	(cpp_init_builtins): Drop __has_include{,_next} init here ...
	* pch.c (cpp_read_state): ... and here.
	* traditional.c (enum ls): Drop has_include states ...
	(_cpp_scan_out_logical_line): ... and here.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The clever hack of '#define __has_include __has_include' breaks -dD
and -fdirectives-only, because that emits definitions.  This turns
__has_include into a proper builtin macro.  Thus it's never emitted
via -dD, and because use outside of directive processing is undefined,
we can just expand it anywhere.

	PR preprocessor/93452
	* internal.h (struct spec_nodes): Drop n__has_include{,_next}.
	* directives.c (lex_macro_node): Don't check __has_include redef.
	* expr.c (eval_token): Drop __has_include eval.
	(parse_has_include): Move to ...
	* macro.c (builtin_has_include): ... here.
	(_cpp_builtin_macro_text): Eval __has_include{,_next}.
	* include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_INCLUDE{,_NEXT}.
	* init.c (builtin_array): Add them.
	(cpp_init_builtins): Drop __has_include{,_next} init here ...
	* pch.c (cpp_read_state): ... and here.
	* traditional.c (enum ls): Drop has_include states ...
	(_cpp_scan_out_logical_line): ... and here.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove bogus __has_include controlling macro</title>
<updated>2020-01-24T12:19:36+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-01-24T12:19:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=a1f6eff20e3bb32c5051e77093ee28faec2abca0'/>
<id>a1f6eff20e3bb32c5051e77093ee28faec2abca0</id>
<content type='text'>
I noticed, but ignored this code when addressing p80005, but having
fixed up defined(X) on the modules branch, I could see where it came
from, and it's obviously wrong as we've just pulled out a string
contant from the token.

	* expr.c (parse_has_include): Remove bogus controlling macro code.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I noticed, but ignored this code when addressing p80005, but having
fixed up defined(X) on the modules branch, I could see where it came
from, and it's obviously wrong as we've just pulled out a string
contant from the token.

	* expr.c (parse_has_include): Remove bogus controlling macro code.
</pre>
</div>
</content>
</entry>
<entry>
<title>[PR 80005]  Fix __has_include</title>
<updated>2020-01-20T13:39:59+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-01-20T13:39:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=ad1a3914ae8d67c94b0d2428e3f9672e7db491a1'/>
<id>ad1a3914ae8d67c94b0d2428e3f9672e7db491a1</id>
<content type='text'>
__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) &lt;...&gt; 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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
__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) &lt;...&gt; 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.
</pre>
</div>
</content>
</entry>
<entry>
<title>[PR93306] Short-circuit has_include</title>
<updated>2020-01-17T13:44:30+00:00</updated>
<author>
<name>Nathan Sidwell</name>
<email>nathan@acm.org</email>
</author>
<published>2020-01-17T13:39:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/gcc.git/commit/?id=bf09d886a4be1031f7003073115af6cbc5575353'/>
<id>bf09d886a4be1031f7003073115af6cbc5575353</id>
<content type='text'>
the preprocessor evaluator has a skip_eval counter, but we weren't
checking it after parsing has_include(foo), but before looking for
foo.  Resulting in unnecessary io for 'FALSE_COND &amp;&amp; has_include &lt;foo&gt;'

	PR preprocessor/93306
	* expr.c (parse_has_include): Refactor.  Check skip_eval before
	looking.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the preprocessor evaluator has a skip_eval counter, but we weren't
checking it after parsing has_include(foo), but before looking for
foo.  Resulting in unnecessary io for 'FALSE_COND &amp;&amp; has_include &lt;foo&gt;'

	PR preprocessor/93306
	* expr.c (parse_has_include): Refactor.  Check skip_eval before
	looking.
</pre>
</div>
</content>
</entry>
</feed>
