Commit Graph

950 Commits

Author SHA1 Message Date
Nathan Sidwell c9c3d5f28a preprocessor: C++ module-directives
C++20 modules introduces a new kind of preprocessor directive -- a
module directive.  These are directives but without the leading '#'.
We have to detect them by sniffing the start of a logical line.  When
detected we replace the initial identifiers with unspellable tokens
and pass them through to the language parser the same way deferred
pragmas are.  There's a PRAGMA_EOL at the logical end of line too.

One additional complication is that we have to do header-name lexing
after the initial tokens, and that requires changes in the macro-aware
piece of the preprocessor.  The above sniffer sets a counter in the
lexer state, and that triggers at the appropriate point.  We then do
the same header-name lexing that occurs on a #include directive or
has_include pseudo-macro.  Except that the header name ends up in the
token stream.

A couple of token emitters need to deal with the new token possibility.

	gcc/c-family/
	* c-lex.c (c_lex_with_flags): CPP_HEADER_NAMEs can now be seen.
	libcpp/
	* include/cpplib.h (struct cpp_options): Add module_directives
	option.
	(NODE_MODULE): New node flag.
	(struct cpp_hashnode): Make rid-code a bitfield, increase bits in
	flags and swap with type field.
	* init.c (post_options): Create module-directive identifier nodes.
	* internal.h (struct lexer_state): Add directive_file_token &
	n_modules fields.  Add module node enumerator.
	* lex.c (cpp_maybe_module_directive): New.
	(_cpp_lex_token): Call it.
	(cpp_output_token): Add '"' around CPP_HEADER_NAME token.
	(do_peek_ident, do_peek_module): New.
	(cpp_directives_only): Detect module-directive lines.
	* macro.c (cpp_get_token_1): Deal with directive_file_token
	triggering.
2020-11-18 10:24:12 -08:00
Nathan Sidwell 7ceb899e93 preprocessor: Add support for header unit translation
libcpp/
	* files.c (struct _cpp_file): Add header_unit field.
	(_cpp_stack_file): Add header unit support.
	(cpp_find_header_unit): New.
	* include/cpplib.h (cpp_find_header_unit): Declare.
2020-11-18 08:45:46 -08:00
Nathan Sidwell db87f19ae3 preprocessor: Update mkdeps for modules
This is slightly different to the original patch I posted.  This adds
separate module target and dependency functions (rather than a single
bi-modal function).

	libcpp/
	* include/cpplib.h (struct cpp_options): Add modules to
	dep-options.
	* include/mkdeps.h (deps_add_module_target): Declare.
	(deps_add_module_dep): Declare.
	* mkdeps.c (class mkdeps): Add modules, module_name, cmi_name,
	is_header_unit fields.  Adjust cdtors.
	(deps_add_module_target, deps_add_module_dep): New.
	(make_write): Write module dependencies, if enabled.
2020-11-18 08:44:49 -08:00
GCC Administrator 4dabb03719 Daily bump. 2020-11-18 00:16:34 +00:00
Nathan Sidwell b196e76aec preprocessor: new callbacks
These two callbacks are needed for C++ modules.  The first is for
handling macros from header-units.  These are resolved lazily.  The
second is for include-translation -- whether a #include gets turned
into a header-unit import.

	libcpp/
	* include/cpplib.h (struct cpp_callbacks): Add
	user_deferred_macro & translate_include.
2020-11-17 08:22:02 -08:00
Nathan Sidwell 1f8ac75991 preprocessor: module line maps
This patch adds LC_MODULE as a map kind, used to indicate a c++
module.  Unlike a regular source file, it only contains a single
location, and the source locations in that module are represented by
ordinary locations whose 'included_from' location is the module.

It also exposes some entry points that modules will use to create
blocks of line maps.

In the original posting, I'd missed the deletion of the
linemap_enter_macro from internal.h.  That's included here.

	libcpp/
	* include/line-map.h (enum lc_reason): Add LC_MODULE.
	(MAP_MODULE_P): New.
	(line_map_new_raw): Declare.
	(linemap_enter_macro): Move declaration from internal.h
	(linemap_module_loc, linemap_module_reparent)
	(linemap_module_restore): Declare.
	(linemap_lookup_macro_indec): Declare.
	* internal.h (linemap_enter_macro): Moved to line-map.h.
	* line-map.c (linemap_new_raw): New, broken out of ...
	(new_linemap): ... here.  Call it.
	(LAST_SOURCE_LINE_LOCATION): New.
	(liemap_module_loc, linemap_module_reparent)
	(linemap_module_restore): New.
	(linemap_lookup_macro_index): New, broken out of ...
	(linemap_macro_map_lookup): ... here.  Call it.
	(linemap_dump): Add module dump.
2020-11-17 08:10:56 -08:00
Nathan Sidwell d7ab349c44 preprocessor: Fix profiled bootstrap warning [pr97858]
As Jakub points out, we only ever pass a single variadic parm (if at
all), so just an optional arg is fine.

	PR preprocessor/97858
	libcpp/
	* mkdeps.c (munge): Drop varadic args, we only ever use one.
2020-11-17 06:47:16 -08:00
GCC Administrator 77f67db2a4 Daily bump. 2020-11-14 00:16:38 +00:00
Joseph Myers e400a64936 c: C2x binary constants
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  <joseph@codesourcery.com>

	* 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  <joseph@codesourcery.com>

	* 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.
2020-11-13 22:45:22 +00:00
Piotr H. Dabrowski 6f1ae1ecd3 Do not warn about unused macros while processing #pragma GCC optimize
libcpp

	PR c++/91318
	* include/cpplib.h: Added cpp_define_unused(), cpp_define_formatted_unused()
	* directives.c: Likewise.

gcc/c-family

	PR c++/91318
	* c-cppbuiltin.c: c_cpp_builtins_optimize_pragma(): use cpp_define_unused()
2020-11-13 12:28:33 -05:00
GCC Administrator a5a115258a Daily bump. 2020-11-13 00:16:35 +00:00
Joseph Myers 1d00f8c863 c: C2x __has_c_attribute
C2x adds the __has_c_attribute preprocessor operator, similar to C++
__has_cpp_attribute.

GCC implements __has_cpp_attribute as exactly equivalent to
__has_attribute.  (The documentation says they differ regarding the
values returned for standard attributes, but that's actually only a
matter of the particular nonzero value returned not being specified in
the documentation for __has_attribute; the implementation makes no
distinction between the two.)

I don't think having them exactly equivalent is actually correct,
either for __has_cpp_attribute or for __has_c_attribute.
Specifically, I think it is only correct for __has_cpp_attribute or
__has_c_attribute to return nonzero if the given attribute is
supported, with the particular pp-tokens passed to __has_cpp_attribute
or __has_c_attribute, with [[]] syntax, not if it's only accepted in
__attribute__ or with gnu:: added in [[]].  For example, they should
return nonzero for gnu::packed, but zero for plain packed, because
[[gnu::packed]] is accepted but [[packed]] is ignored as not a
standard attribute.

This patch implements that for __has_c_attribute, leaving any changes
to __has_cpp_attribute for the C++ maintainers.  A new
BT_HAS_STD_ATTRIBUTE is added for __has_c_attribute (which I think,
based on the above, would actually be correct to use for
__has_cpp_attribute as well).  The code in c_common_has_attribute that
deals with scopes has its C++ conditional removed; instead, whether
the language is C or C++ is used only to determine the numeric values
returned for standard attributes (and which standard attributes are
handled there at all).  A new argument is passed to
c_common_has_attribute to distinguish BT_HAS_STD_ATTRIBUTE from
BT_HAS_ATTRIBUTE, and that argument is used to stop attributes with no
scope specified from being accepted with __has_c_attribute unless they
are one of the known standard attributes and so handled specially.

Although the standard specify constants ending with 'L' as the values
for the standard attributes, there is no correctness issue with the
lack of code in GCC to add that 'L' to the expansion:
__has_c_attribute and __has_cpp_attribute are expanded in #if after
other macro expansion has occurred, with no semantics being specified
if they occur outside #if, so there is no way for a conforming program
to inspect the exact text of the expansion of those macros, only to
use the resulting pp-number in a #if expression, where long and int
have the same set of values.

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

gcc/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* doc/cpp.texi (__has_attribute): Document when scopes are allowed
	for C.
	(__has_c_attribute): New.

gcc/c-family/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* c-lex.c (c_common_has_attribute): Take argument std_syntax.
	Allow scope for C.  Handle standard attributes for C.  Do not
	accept unscoped attributes if std_syntax and not handled as
	standard attributes.
	* c-common.h (c_common_has_attribute): Update prototype.

gcc/testsuite/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* gcc.dg/c2x-has-c-attribute-1.c, gcc.dg/c2x-has-c-attribute-2.c,
	gcc.dg/c2x-has-c-attribute-3.c, gcc.dg/c2x-has-c-attribute-4.c:
	New tests.

libcpp/
2020-11-12  Joseph Myers  <joseph@codesourcery.com>

	* include/cpplib.h (struct cpp_callbacks): Add bool argument to
	has_attribute.
	(enum cpp_builtin_type): Add BT_HAS_STD_ATTRIBUTE.
	* init.c (builtin_array): Add __has_c_attribute.
	(cpp_init_special_builtins): Handle BT_HAS_STD_ATTRIBUTE.
	* macro.c (_cpp_builtin_macro_text): Handle BT_HAS_STD_ATTRIBUTE.
	Update call to has_attribute for BT_HAS_ATTRIBUTE.
	* traditional.c (fun_like_macro): Handle BT_HAS_STD_ATTRIBUTE.
2020-11-12 21:13:51 +00:00
Nicholas Guriev cb808c583d Specify reason of -Winvalid-pch warning
gcc/c-family
	PR pch/86674
	* c-pch.c (c_common_valid_pch): Use cpp_warning with CPP_W_INVALID_PCH
	reason to fix -Werror=invalid-pch and -Wno-error=invalid-pch switches.

libcpp
	PR pch/86674
	* files.c (_cpp_find_file): Use CPP_DL_NOTE not CPP_DL_ERROR in call to
	cpp_error.
2020-11-12 09:02:12 -05:00
GCC Administrator 2da7ee050c Daily bump. 2020-11-08 00:16:31 +00:00
Lewis Hyatt 497c9f8d4d libcpp: Update cpp_wcwidth() to Unicode 13.0.0
generated_cpp_wcwidth.h was regenerated using Unicode 13.0.0 data files. No
material changes to the parsing scripts (either GCC- or glibc-sourced) were
necessary; glibc's utf8_gen.py was tweaked slightly by glibc and matched here.

contrib/ChangeLog:

	* unicode/EastAsianWidth.txt: Update to Unicode 13.0.0.
	* unicode/PropList.txt: Likewise.
	* unicode/README: Likewise.
	* unicode/UnicodeData.txt: Likewise.
	* unicode/from_glibc/unicode_utils.py: Update to latest glibc version.
	* unicode/from_glibc/utf8_gen.py: Likewise.

libcpp/ChangeLog:

	* generated_cpp_wcwidth.h: Regenerated from Unicode 13.0.0 data.
2020-11-07 09:36:43 -05:00
GCC Administrator 44cab2d8fd Daily bump. 2020-11-07 00:16:39 +00:00
Nathan Sidwell 4b5f564a5d libcpp: Provide date routine
Joseph pointed me at cb_get_source_date_epoch, which allows repeatable
builds and solves a FIXME I had on the modules branch.  Unfortunately
it's used exclusively to generate __DATE__ and __TIME__ values, which
fallback to using a time(2) call.  It'd be nicer if the preprocessor
made whatever time value it determined available to the rest of the
compiler.  So this patch adds a new cpp_get_date function, which
abstracts the call to the get_source_date_epoch hook, or uses time
directly.  The value is cached.  Thus the timestamp I end up putting
on CMI files matches __DATE__ and __TIME__ expansions.  That seems
worthwhile.

	libcpp/
	* include/cpplib.h (enum class CPP_time_kind): New.
	(cpp_get_date): Declare.
	* internal.h (struct cpp_reader): Replace source_date_epoch with
	time_stamp and time_stamp_kind.
	* init.c (cpp_create_reader): Initialize them.
	* macro.c (_cpp_builtin_macro_text): Use cpp_get_date.
	(cpp_get_date): Broken out from _cpp_builtin_macro_text and
	genericized.
2020-11-06 08:59:20 -08:00
GCC Administrator fd2325ea60 Daily bump. 2020-11-04 00:16:41 +00:00
Nathan Sidwell 8bd9a00f43 cpplib: EOF in pragmas
This patch moves the generation of PRAGMA_EOF earlier, to when we set
need_line, rather than when we try and get the next line.  It also
prevents peeking past a PRAGMA token.

	libcpp/
	* lex.c (cpp_peek_token): Do not peek past CPP_PRAGMA.
	(_cpp_lex_direct): Handle EOF in pragma when setting need_line,
	not when needing a line.
2020-11-03 10:07:20 -08:00
Nathan Sidwell 082a7b2390 cpplib: Fix off-by-one error
I noticed a fencepost error in the preprocessor.  We should be
checking if the next char is at the limit, not the current char (which
can't be, because we're looking at it).

	libcpp/
	* lex.c (_cpp_clean_line): Fix DOS off-by-one error.
2020-11-03 08:49:25 -08:00
Nathan Sidwell d8909271a2 libcpp: unbreak bootstrap
This fixes the bootstrap breakage I caused.  Sorry about that.

	libcpp/
	* init.c (cpp_read_main_file): Use cpp_get_deps result.
2020-11-03 06:03:11 -08:00
Nathan Sidwell 918e8b10a7 libcpp: dependency emission tidying
This patch cleans up the interface to the dependency generation a
little.  We now only check the option in one place, and the
cpp_get_deps function returns nullptr if there are no dependencies.  I
also reworded the -MT and -MQ help text to be make agnostic -- as
there are ideas about emitting, say, JSON.

	libcpp/
	* include/mkdeps.h: Include cpplib.h
	(deps_write): Adjust first parm type.
	* mkdeps.c: Include internal.h
	(make_write): Adjust first parm type.  Check phony option
	directly.
	(deps_write): Adjust first parm type.
	* init.c (cpp_read_main_file): Use get_deps.
	* directives.c (cpp_get_deps): Check option before initializing.
	gcc/c-family/
	* c.opt (MQ,MT): Reword description to be make-agnostic.
	gcc/fortran/
	* cpp.c (gfc_cpp_add_dep): Only add dependency if we're recording
	them.
	(gfc_cpp_init): Likewise for target.
2020-11-03 05:16:19 -08:00
GCC Administrator 88ce3d5fbb Daily bump. 2020-11-02 20:53:00 +00:00
Nathan Sidwell e9a2e208dd cpplib: Macro use location and comparison
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.
2020-11-02 08:56:38 -08:00
GCC Administrator e2e0428854 Daily bump. 2020-10-21 00:16:36 +00:00
Nathan Sidwell dbcc6b1577 preprocessor: Further fix for EOF in macro args [PR97471]
My previous attempt at fixing this was incorrect.  The problem occurs
earlier in that _cpp_lex_direct processes the unwinding EOF needs in
collect_args mode.  This patch changes it not to do that, in the same
way as directive parsing works.  Also collect_args shouldn't push_back
such fake EOFs, and neither should funlike_invocation_p.

	libcpp/
	* lex.c (_cpp_lex_direct): Do not complete EOF processing when
	parsing_args.
	* macro.c (collect_args): Do not unwind fake EOF.
	(funlike_invocation_p): Do not unwind fake EOF.
	(cpp_context): Replace abort with gcc_assert.
	gcc/testsuite/
	* gcc.dg/cpp/endif.c: Move to ...
	* c-c++-common/cpp/endif.c: ... here.
	* gcc.dg/cpp/endif.h: Move to ...
	* c-c++-common/cpp/endif.h: ... here.
	* c-c++-common/cpp/eof-2.c: Adjust diagnostic.
	* c-c++-common/cpp/eof-3.c: Adjust diagnostic.
2020-10-20 08:01:34 -07:00
GCC Administrator 970d683f67 Daily bump. 2020-10-20 00:16:29 +00:00
Nathan Sidwell 5abe05b433 preprocessor: Fix non-fn fn-like macro at EOF [PR97471]
We inject EOF tokens between macro argument lists, but had
confused/stale logic in the non-fn invocation.  Renamed the magic
'eof' token, as it's now only used for macro argument termination.
Always rewind the non-OPEN_PAREN token.

	libcpp/
	* internal.h (struct cpp_reader): Rename 'eof' field to 'endarg'.
	* init.c (cpp_create_reader): Adjust.
	* macro.c (collect_args): Use endarg for separator.  Always rewind
	in the not-fn case.
	gcc/testsuite/
	* c-c++-common/cpp/pr97471.c: New.
2020-10-19 08:00:41 -07:00
GCC Administrator da9df69975 Daily bump. 2020-10-09 00:16:27 +00:00
Nathan Sidwell d1c566d72d libcpp: Directly peek for initial line marker
Using the tokenizer to sniff for an initial line marker for
preprocessed input is a little brittle, particularly with
-fdirectives-only.  If there is no marker we'll happily munch initial
comments.  This patch directly sniffs the buffer.  This is safe
because the initial line marker was machine generated and must be
right at the beginning of the file.  Anything else is not such a line
marker.  The same is true for the initial directory marker.  For that
tokenizing the string is simplest, but at that point it's either a
regular line marker or a directory marker.  If it's a regular marker,
unwinding tokens is fine.

	libcpp/
	* internal.h (enum include_type): Rename IT_MAIN_INJECT to
	IT_PRE_MAIN.
	* init.c (cpp_read_main_file): If there is no line marker, adjust
	the initial line marker.
	(read_original_filename): Return bool, peek the buffer directly
	before trying to tokenize.
	(read_original_directory): Likewise.  Directly prod the string
	literal.
	* files.c (_cpp_stack_file): Adjust for IT_PRE_MAIN change.
2020-10-08 12:16:21 -07:00
GCC Administrator 91dd4a3864 Daily bump. 2020-09-27 00:16:24 +00:00
Jakub Jelinek d00b1b023e powerpc, libcpp: Fix gcc build with clang on power8 [PR97163]
libcpp has two specialized altivec implementations of search_line_fast,
one for power8+ and the other one otherwise.
Both use __attribute__((altivec(vector))) and the GCC builtins rather than
altivec.h and the APIs from there, which is fine, but should be restricted
to when libcpp is built with GCC, so that it can be relied on.
The second elif is
and thus e.g. when built with clang it isn't picked, but the first one was
just guarded with
and so according to the bugreporter clang fails miserably on that.

The following patch fixes that by adding the same GCC_VERSION requirement
as the second version.  I don't know where the 4.5 in there comes from and
the exact version doesn't matter that much, as long as it is above 4.2 that
clang pretends to be and smaller or equal to 4.8 as the oldest gcc we
support as bootstrap compiler ATM.
Furthermore, the patch fixes the comment, the version it is talking about is
not pre-GCC 5, but actually the GCC 5+ one.

2020-09-26  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/97163
	* lex.c (search_line_fast): Only use _ARCH_PWR8 Altivec version
	for GCC >= 4.5.
2020-09-26 10:07:41 +02:00
GCC Administrator 2aad20c094 Daily bump. 2020-09-18 00:16:24 +00:00
Patrick Palka 4839de55e2 c-family: Macro support in -Wmisleading-indentation [PR80076]
Currently the -Wmisleading-indentation warning doesn't do any analysis
when the guarded statement or the statement after it is produced by a
macro.  This means we warn for:

  if (flag)
    foo ();
    bar ();

but not for:

  #define BAR bar
  if (flag)
    foo ();
    BAR ();

This patch extends the -Wmisleading-indentation implementation to
support analyzing such statements and their tokens.  This is done in the
"natural" way by resolving the location of each of the three tokens to
the token's macro expansion point.  (Additionally, if the tokens all
resolve to the same macro expansion point then we instead use their
locations within the macro definition.)  When these resolved locations
are all different, then we can proceed with applying the warning
heuristics to them as if no macros were involved.

gcc/c-family/ChangeLog:

	PR c/80076
	* c-indentation.c (should_warn_for_misleading_indentation): Move
	declarations of local variables closer to their first use.
	Handle virtual token locations by resolving them to their
	respective macro expansion points.  If all three tokens are
	produced from the same macro expansion, then instead use their
	loci within the macro definition.

gcc/objc/ChangeLog:

	PR c/80076
	* objc-gnu-runtime-abi-01.c
	(gnu_runtime_abi_01_get_class_super_ref): Reduce indentation of
	misleadingly indented return statements.
	* objc-next-runtime-abi-01.c
	(next_runtime_abi_01_get_class_super_ref): Likewise.

gcc/ChangeLog:

	PR c/80076
	* gensupport.c (alter_attrs_for_subst_insn) <case SET_ATTR>:
	Reduce indentation of misleadingly indented code fragment.
	* lra-constraints.c (multi_block_pseudo_p): Likewise.
	* sel-sched-ir.c (merge_fences): Likewise.

libcpp/ChangeLog:

	PR c/80076
	* include/line-map.h (first_map_in_common): Declare.
	* line-map.c (first_map_in_common): Remove static.

gcc/testsuite/ChangeLog:

	PR c/80076
	* c-c++-common/Wmisleading-indentation-5.c: New test.
2020-09-17 14:27:22 -04:00
GCC Administrator a995c40d03 Daily bump. 2020-09-08 00:16:32 +00:00
Martin Storsjö 3fe3efe5c1 gcc: Make strchr return value pointers const
This fixes compilation of codepaths for dos-like filesystems
with Clang. When built with clang, it treats C input files as C++
when the compiler driver is invoked in C++ mode, triggering errors
when the return value of strchr() on a pointer to const is assigned
to a pointer to non-const variable.

This matches similar variables outside of the ifdefs for dos-like
path handling.

2020-09-07  Martin Storsjö  <martin@martin.st>

gcc/
	* dwarf2out.c (file_name_acquire): Make a strchr return value
	pointer to const.
libcpp/
	* files.c (remap_filename): Make a strchr return value pointer
	to const.
2020-09-07 13:20:21 +02:00
GCC Administrator d48cca8f21 Daily bump. 2020-07-31 00:16:26 +00:00
H.J. Lu 4712bde3ca Require CET support only for the final GCC build
With --enable-cet, require CET support only for the final GCC build.
Don't enable CET without CET support for non-bootstrap build, in stage1
nor for build support.

config/

	PR bootstrap/96202
	* cet.m4 (GCC_CET_HOST_FLAGS): Don't enable CET without CET
	support in stage1 nor for build support.

gcc/

	PR bootstrap/96202
	* configure: Regenerated.

libbacktrace/

	PR bootstrap/96202
	* configure: Regenerated.

libcc1/

	PR bootstrap/96202
	* configure: Regenerated.

libcpp/

	PR bootstrap/96202
	* configure: Regenerated.

libdecnumber/

	PR bootstrap/96202
	* configure: Regenerated.

libiberty/

	PR bootstrap/96202
	* configure: Regenerated.

lto-plugin/

	PR bootstrap/96202
	* configure: Regenerated.
2020-07-30 05:36:24 -07:00
GCC Administrator bea7a39103 Daily bump. 2020-07-30 00:16:24 +00:00
Tiziano Müller f6fe3bbf9f preprocessor: Teach traditional about has_include [PR95889]
Traditional cpp (used by fortran) didn;t know about the new
__has_include__ implementation.  Hey, since when did traditional cpp
grow __has_include__? That wasn't in knr!

	libcpp/
	* init.c (builtin_array): Add xref comment.
	* traditional.c (fun_like_macro): Add HAS_INCLUDE codes.
	gcc/testsuite/
	* c-c++-common/cpp/has-include-1-traditional.c: New.
2020-07-29 07:47:21 -07:00
GCC Administrator 7ebb7d0ce1 Daily bump. 2020-07-29 00:16:24 +00:00
Jakub Jelinek ae49af9485 libcpp: Fix up raw string literal parsing error-recovery [PR96323]
For (invalid) newline inside of the raw string literal delimiter, doing
continue means we skip the needed processing of newlines.  Instead of
duplicating that, this patch just doesn't continue for those.

2020-07-28  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/96323
	* lex.c (lex_raw_string): For c == '\n' don't continue after reporting
	an prefix delimiter error.

	* c-c++-common/cpp/pr96323.c: New test.
2020-07-28 15:40:15 +02:00
Nathan Sidwell 134051f16b preprocessor: Simplify read_main
We can always use the final map to get the return value, rather than
conditionally only when there was an immediate line directive.

	libcpp/
	* init.c (cpp_read_main_file): Always use the last map for
	the return value.
2020-07-28 05:52:44 -07:00
GCC Administrator 0933f50859 Daily bump. 2020-07-21 00:16:28 +00:00
Joseph Myers 3e99ed65cb Regenerate .pot files.
gcc/po/
	* gcc.pot: Regenerate.

libcpp/po/
	* cpplib.pot: Regenerate.
2020-07-20 18:06:29 +00:00
Nathan Sidwell a926eeedf4 preprocessor: line-map cleanups
I found the linemap logic dealing with running out of column numbers
confusing.  There's no need for completely separate code blocks there,
as we can rely on the masking operations working all the way down to
zero bits.  The two binary searches for linemap lookups could do with
modernization of placing the var decls at their initialization point.
(These two searches work in opposite directions, and while lower_bound
would work there, the caching got in the way and I decided to be
conservative.)

	libcpp/
	* line-map.c (linemap_add): Simplify column overflow calculation.
	Add comment about range and column bit init.
	(linemap_ordinary_map_lookup): Refactor for RAII
	(linemap_macro_map_lookup): Likewise.
2020-07-20 05:11:19 -07:00
GCC Administrator 8ca07a3072 Daily bump. 2020-07-15 00:16:35 +00:00
Lewis Hyatt 004bb936d6 diagnostics: Support conversion of tabs to spaces [PR49973] [PR86904]
Supports conversion of tabs to spaces when outputting diagnostics. Also
adds -fdiagnostics-column-unit and -fdiagnostics-column-origin options to
control how the column number is output, thereby resolving the two PRs.

gcc/c-family/ChangeLog:

	PR other/86904
	* c-indentation.c (should_warn_for_misleading_indentation): Get
	global tabstop from the new source.
	* c-opts.c (c_common_handle_option): Remove handling of -ftabstop, which
	is now a common option.
	* c.opt: Likewise.

gcc/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* common.opt: Handle -ftabstop here instead of in c-family
	options.  Add -fdiagnostics-column-unit= and
	-fdiagnostics-column-origin= options.
	* opts.c (common_handle_option): Handle the new options.
	* diagnostic-format-json.cc (json_from_expanded_location): Add
	diagnostic_context argument.  Use it to convert column numbers as per
	the new options.
	(json_from_location_range): Likewise.
	(json_from_fixit_hint): Likewise.
	(json_end_diagnostic): Pass the new context argument to helper
	functions above.  Add "column-origin" field to the output.
	(test_unknown_location): Add the new context argument to calls to
	helper functions.
	(test_bad_endpoints): Likewise.
	* diagnostic-show-locus.c
	(exploc_with_display_col::exploc_with_display_col): Support
	tabstop parameter.
	(layout_point::layout_point): Make use of class
	exploc_with_display_col.
	(layout_range::layout_range): Likewise.
	(struct line_bounds): Clarify that the units are now always
	display columns.  Rename members accordingly.  Add constructor.
	(layout::print_source_line): Add support for tab expansion.
	(make_range): Adapt to class layout_range changes.
	(layout::maybe_add_location_range): Likewise.
	(layout::layout): Adapt to class exploc_with_display_col changes.
	(layout::calculate_x_offset_display): Support tabstop parameter.
	(layout::print_annotation_line): Adapt to struct line_bounds changes.
	(layout::print_line): Likewise.
	(line_label::line_label): Add diagnostic_context argument.
	(get_affected_range): Likewise.
	(get_printed_columns): Likewise.
	(layout::print_any_labels): Adapt to struct line_label changes.
	(class correction): Add m_tabstop member.
	(correction::correction): Add tabstop argument.
	(correction::compute_display_cols): Use m_tabstop.
	(class line_corrections): Add m_context member.
	(line_corrections::line_corrections): Add diagnostic_context argument.
	(line_corrections::add_hint): Use m_context to handle tabstops.
	(layout::print_trailing_fixits): Adapt to class line_corrections
	changes.
	(test_layout_x_offset_display_utf8): Support tabstop parameter.
	(test_layout_x_offset_display_tab): New selftest.
	(test_one_liner_colorized_utf8): Likewise.
	(test_tab_expansion): Likewise.
	(test_diagnostic_show_locus_one_liner_utf8): Call the new tests.
	(diagnostic_show_locus_c_tests): Likewise.
	(test_overlapped_fixit_printing): Adapt to helper class and
	function changes.
	(test_overlapped_fixit_printing_utf8): Likewise.
	(test_overlapped_fixit_printing_2): Likewise.
	* diagnostic.h (enum diagnostics_column_unit): New enum.
	(struct diagnostic_context): Add members for the new options.
	(diagnostic_converted_column): Declare.
	(json_from_expanded_location): Add new context argument.
	* diagnostic.c (diagnostic_initialize): Initialize new members.
	(diagnostic_converted_column): New function.
	(maybe_line_and_column): Be willing to output a column of 0.
	(diagnostic_get_location_text): Convert column number as per the new
	options.
	(diagnostic_report_current_module): Likewise.
	(assert_location_text): Add origin and column_unit arguments for
	testing the new functionality.
	(test_diagnostic_get_location_text): Test the new functionality.
	* doc/invoke.texi: Document the new options and behavior.
	* input.h (location_compute_display_column): Add tabstop argument.
	* input.c (location_compute_display_column): Likewise.
	(test_cpp_utf8): Add selftests for tab expansion.
	* tree-diagnostic-path.cc (default_tree_make_json_for_path): Pass the
	new context argument to json_from_expanded_location().

libcpp/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* include/cpplib.h (struct cpp_options):  Removed support for -ftabstop,
	which is now handled by diagnostic_context.
	(class cpp_display_width_computation): New class.
	(cpp_byte_column_to_display_column): Add optional tabstop argument.
	(cpp_display_width): Likewise.
	(cpp_display_column_to_byte_column): Likewise.
	* charset.c
	(cpp_display_width_computation::cpp_display_width_computation): New
	function.
	(cpp_display_width_computation::advance_display_cols): Likewise.
	(compute_next_display_width): Removed and implemented this
	functionality in a new function...
	(cpp_display_width_computation::process_next_codepoint): ...here.
	(cpp_byte_column_to_display_column): Added tabstop argument.
	Reimplemented in terms of class cpp_display_width_computation.
	(cpp_display_column_to_byte_column): Likewise.
	* init.c (cpp_create_reader): Remove handling of -ftabstop, which is now
	handled by diagnostic_context.

gcc/testsuite/ChangeLog:

	PR preprocessor/49973
	PR other/86904
	* c-c++-common/Wmisleading-indentation-3.c: Adjust expected output
	for new defaults.
	* c-c++-common/Wmisleading-indentation.c: Likewise.
	* c-c++-common/diagnostic-format-json-1.c: Likewise.
	* c-c++-common/diagnostic-format-json-2.c: Likewise.
	* c-c++-common/diagnostic-format-json-3.c: Likewise.
	* c-c++-common/diagnostic-format-json-4.c: Likewise.
	* c-c++-common/diagnostic-format-json-5.c: Likewise.
	* c-c++-common/missing-close-symbol.c: Likewise.
	* g++.dg/diagnostic/bad-binary-ops.C: Likewise.
	* g++.dg/parse/error4.C: Likewise.
	* g++.old-deja/g++.brendan/crash11.C: Likewise.
	* g++.old-deja/g++.pt/overload2.C: Likewise.
	* g++.old-deja/g++.robertl/eb109.C: Likewise.
	* gcc.dg/analyzer/malloc-paths-9.c: Likewise.
	* gcc.dg/bad-binary-ops.c: Likewise.
	* gcc.dg/format/branch-1.c: Likewise.
	* gcc.dg/format/pr79210.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-expressions-1.c: Likewise.
	* gcc.dg/plugin/diagnostic-test-string-literals-1.c: Likewise.
	* gcc.dg/redecl-4.c: Likewise.
	* gfortran.dg/diagnostic-format-json-1.F90: Likewise.
	* gfortran.dg/diagnostic-format-json-2.F90: Likewise.
	* gfortran.dg/diagnostic-format-json-3.F90: Likewise.
	* go.dg/arrayclear.go: Add a comment explaining why adding a
	comment was necessary to work around a dejagnu bug.
	* c-c++-common/diagnostic-units-1.c: New test.
	* c-c++-common/diagnostic-units-2.c: New test.
	* c-c++-common/diagnostic-units-3.c: New test.
	* c-c++-common/diagnostic-units-4.c: New test.
	* c-c++-common/diagnostic-units-5.c: New test.
	* c-c++-common/diagnostic-units-6.c: New test.
	* c-c++-common/diagnostic-units-7.c: New test.
	* c-c++-common/diagnostic-units-8.c: New test.
2020-07-14 12:05:56 -04:00
GCC Administrator f60ee68de3 Daily bump. 2020-07-08 00:16:40 +00:00
Nathan Sidwell 6bf2ff0d52 preprocessor: Better line info for <builtin> & <command-line>
With C++ module header units it becomes important to distinguish
between macros defined in forced headers (& commandline & builtins)
from those defined in the header file being processed.  We weren't
making that easy because we treated the builtins and command-line
locations somewhat file-like, with incrementing line numbers, and
showing them as included from line 1 of the main file.  This patch does
3 things:

0) extend the idiom that 'line 0' of a file means 'the file as a whole'

1) builtins and command-line macros are shown as-if included from line zero.

2) when emitting preprocessed output we keep resetting the line number
so that re-reading that preprocessed output will get the same set of
locations for the command line etc.

For instance the new c-c++-common/cpp/line-2.c test, now emits

In file included from <command-line>:
./line-2.h:4:2: error: #error wrong
    4 | #error wrong
      |  ^~~~~
line-2.c:3:11: error: macro "bill" passed 1 arguments, but takes just 0
    3 | int bill(1);
      |           ^
In file included from <command-line>:
./line-2.h:3: note: macro "bill" defined here
    3 | #define bill() 2
      |

Before it told you about including from <command-line>:31.

the preprocessed output looks like:
...

(There's a new optimization in do_line_marker to stop each of these
line markers causing a new line map.  We can simply rewind the
location, and keep using the same line map.)

	libcpp/
	* directives.c (do_linemarker): Optimize rewinding to line zero.
	* files.c (_cpp_stack_file): Start on line zero when about to inject
	headers.
	(cpp_push_include, cpp_push_default_include): Use highest_line as
	the location.
	* include/cpplib.h (cpp_read_main_file): Add injecting parm.
	* init.c (cpp_read_main_file): Likewise, inform _cpp_stack_file.
	* internal.h (enum include_type): Add IT_MAIN_INJECT.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Add 'injecting' arg to
	cpp_read_main_file.
	(c_finish_options): Add linemap_line_start calls for builtin and cmd
	maps.  Force token position to line_table's highest line.
	* c-ppoutput.c (print_line_1): Refactor, print line zero.
	(cb_define): Always increment source line.
	gcc/testsuite/
	* c-c++-common/cpp/line-2.c: New.
	* c-c++-common/cpp/line-2.h: New.
	* c-c++-common/cpp/line-3.c: New.
	* c-c++-common/cpp/line-4.c: New.
	* c-c++-common/cpp/line-4.h: New.
2020-07-07 11:40:04 -07:00