gcc.git
6 years ago* testsuite/18_support/new_nothrow.cc: XFAIL on AIX.
David Edelsohn [Tue, 21 Aug 2018 14:03:16 +0000 (14:03 +0000)]
* testsuite/18_support/new_nothrow.cc: XFAIL on AIX.

From-SVN: r263703

6 years agoUpdate global reviewers list
Richard Sandiford [Tue, 21 Aug 2018 13:49:30 +0000 (13:49 +0000)]
Update global reviewers list

2018-08-21  Richard Sandiford  <richard.sandiford@arm.com>

* MAINTAINERS: Add self to global reviewers list.

From-SVN: r263702

6 years agotree.c (find_decls_types_r): Do not check for redundant typedefs.
Jan Hubicka [Tue, 21 Aug 2018 12:32:53 +0000 (14:32 +0200)]
tree.c (find_decls_types_r): Do not check for redundant typedefs.

* tree.c (find_decls_types_r): Do not check for redundant typedefs.
* tree.h (is_redundant_typedef): Remove.
* dwarf2out.c (is_redundant_typedef): Turn into static function.

From-SVN: r263699

6 years ago[Ada] Bump copyright notices to 2018
Pierre-Marie de Rodat [Tue, 21 Aug 2018 11:59:28 +0000 (11:59 +0000)]
[Ada] Bump copyright notices to 2018

2018-08-21  Pierre-Marie de Rodat  <derodat@adacore.com>

gcc/ada/

* libgnarl/a-intnam__dragonfly.ads,
libgnarl/s-osinte__dragonfly.adb,
libgnarl/s-osinte__dragonfly.ads, libgnarl/s-osinte__gnu.adb,
libgnarl/s-osinte__gnu.ads, libgnarl/s-osinte__hpux-dce.adb,
libgnarl/s-osinte__hpux-dce.ads,
libgnarl/s-taprop__hpux-dce.adb,
libgnarl/s-taspri__hpux-dce.ads: Bump copyright notices to 2018.

From-SVN: r263698

6 years agotree.c (free_lang_data_in_decl): Remove types from DECL_CONTEXT when possible.
Jan Hubicka [Tue, 21 Aug 2018 10:36:37 +0000 (12:36 +0200)]
tree.c (free_lang_data_in_decl): Remove types from DECL_CONTEXT when possible.

* tree.c (free_lang_data_in_decl): Remove types from DECL_CONTEXT
when possible.

From-SVN: r263697

6 years agoFix DSE big-endian subreg crash on AArch64.
Tamar Christina [Tue, 21 Aug 2018 09:55:07 +0000 (09:55 +0000)]
Fix DSE big-endian subreg crash on AArch64.

This patch fixes an ICE that would happen when extract_low_bits
is called with modes for which you can't extract a valid subreg.
e.g. taking a 32 bytes subreg from a 48 byte mode.

The ICE happens because convert_modes which eventually calls
simplify_gen_subreg does not expect the convertion to fail.

The assert in gen_lowpart_general would then be hit.  The patch
changes it to validate the subreg before trying to convert the
modes.  If the subreg is not possible we return NULL_RTX and bail
out early.

gcc/ChangeLog:

2018-08-21  Tamar Christina  <tamar.christina@arm.com>

* expmed.c (extract_low_bits): Reject invalid subregs early.

gcc/testsuite/ChangeLog:

2018-08-21  Tamar Christina  <tamar.christina@arm.com>

* gcc.target/aarch64/large_struct_copy.c: New test.

From-SVN: r263696

6 years agoRemove redundant { dg-do run } directives in tests
Jonathan Wakely [Tue, 21 Aug 2018 09:34:26 +0000 (10:34 +0100)]
Remove redundant { dg-do run } directives in tests

These tests accidentally had two dg-do directives. Only the second one
is needed.

* testsuite/26_numerics/bit/bitops.count/countl_one.cc: Remove
redundant dg-do directive.
* testsuite/26_numerics/bit/bitops.count/countl_zero.cc: Likewise.
* testsuite/26_numerics/bit/bitops.count/countr_one.cc: Likewise.
* testsuite/26_numerics/bit/bitops.count/countr_zero.cc: Likewise.
* testsuite/26_numerics/bit/bitops.count/popcount.cc: Likewise.

From-SVN: r263695

6 years agoRestrict the pr86763 test to *-*-linux* targets
Szabolcs Nagy [Tue, 21 Aug 2018 09:22:14 +0000 (09:22 +0000)]
Restrict the pr86763 test to *-*-linux* targets

clock_gettime is not available on some baremetal targets
and may require -lrt on some non-linux targets.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr86763.C: Restrict to *-*-linux*.

From-SVN: r263694

6 years agore PR middle-end/86121 (missing -Wstringop-overflow on strcpy followed by strcat)
Bernd Edlinger [Tue, 21 Aug 2018 08:56:11 +0000 (08:56 +0000)]
re PR middle-end/86121 (missing -Wstringop-overflow on strcpy followed by strcat)

2018-08-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR middle-end/86121
        * tree-ssa-strlen.c (adjust_last_stmt): Avoid folding away undefined
        behaviour.

testsuite:
2018-08-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR middle-end/86121
        * gcc.dg/Wstringop-overflow-6.c: Remove xfail.

From-SVN: r263693

6 years agovxworks: don't define vxworks_asm_out_constructor when using .init_array
Rasmus Villemoes [Tue, 21 Aug 2018 08:52:40 +0000 (10:52 +0200)]
vxworks: don't define vxworks_asm_out_constructor when using .init_array

When the compiler is configured with --enable-initfini-array,
config/initfini-array.h gets included after config/vxworks.h by tm.h, so
the definitions of TARGET_ASM_CONSTRUTOR/TARGET_ASM_DESTRUCTOR in
vxworks.h get undone in initfini-array.h. Hence, we might as well not
define the vxworks_asm_out_* functions.

From-SVN: r263692

6 years agovxworks: enable use of .init_array/.fini_array for cdtors
Rasmus Villemoes [Tue, 21 Aug 2018 08:50:27 +0000 (10:50 +0200)]
vxworks: enable use of .init_array/.fini_array for cdtors

The target OS actually runs all function pointers found in the _ctors
array when the module is loaded. So it is not that hard to make use of
the "modern" .init_array/.fini_array mechanism - it mostly just requires
a linker script adding the _ctors and _dtors symbols and terminating
LONG(0) entries.

Assume that if the user passed --enable-initfini-array when building
gcc, the rest of the toolchain (including the link spec and linker
script) is set up appropriately.

Note that configuring with --enable-initfini-array may prevent the -mrtp
mode from working, due to the (unconditional) use of .init_array.*
sections instead of .ctors.* - however, that is the case regardless of this
patch.

From-SVN: r263691

6 years agolibgcc: add crt{begin,end} for powerpc-wrs-vxworks target
Rasmus Villemoes [Tue, 21 Aug 2018 08:49:15 +0000 (10:49 +0200)]
libgcc: add crt{begin,end} for powerpc-wrs-vxworks target

In order to allow ZCX on VxWorks, we need the frame_dummy function to do
the register_frame_info(). So make sure crtbegin.o and crtend.o are
available for use with a custom spec file.

From-SVN: r263690

6 years agovxworks: add target/h/wrn/coreip to the set of system include paths
Rasmus Villemoes [Tue, 21 Aug 2018 08:47:41 +0000 (10:47 +0200)]
vxworks: add target/h/wrn/coreip to the set of system include paths

In order to build crtstuff.c, I need to ensure the headers in
target/h/wrn/coreip are also searched. Of course, that can be done
similar to how wrn/coreip gets manually added for libgcc, e.g. by adding

  CRTSTUFF_T_CFLAGS += -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip

But without target/h/wrn/coreip in the default search path, all
user-code that include <unistd.h> (crtstuff.c just being one such
example) will have to manually add an -isystem
flag adding the wrn/coreip directory: unistd.h include ioLib.h, which
has

#include "net/uio.h"

and that header is found in target/h/wrn/coreip. In other words, the
VxWorks system headers (at least for VxWorks 5.5) are written in a way
that assumes wrn/coreip is in the search path, so I think it makes sense
to have that by default.

It will change the search order for existing setups that pass
-I.../target/h/wrn/coreip (without -nostdinc), since that flag will now
be ignored. I can't know whether that will break anything, but I do
believe it makes sense to have the defaults actually usable without
expecting all invocations to add -I/-isystem flags.

From-SVN: r263689

6 years agogimple-ssa-sprintf.c (decl_constant_value): Remove.
Bernd Edlinger [Tue, 21 Aug 2018 08:16:19 +0000 (08:16 +0000)]
gimple-ssa-sprintf.c (decl_constant_value): Remove.

2018-08-21  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        * gimple-ssa-sprintf.c (decl_constant_value): Remove.
        (get_format_string): Refer to c_getstr.

From-SVN: r263688

6 years ago[debug] Add debug and earlydebug dumps
Tom de Vries [Tue, 21 Aug 2018 07:39:29 +0000 (07:39 +0000)]
[debug] Add debug and earlydebug dumps

With the introduction of early debug, we've added a phase in the compiler which
produces information which is not visible, unless we run the compiler in the
debugger and call debug_dwarf from dwarf2out_early_finish or some such.

This patch adds dumping of "early" and "final" debug info, into .earlydebug
and .debug dump files, enabled by -fdump-earlydebug and -fdumpdebug, such that
we can follow f.i. the upper bound of a vla type from early debug:
...
          DW_AT_upper_bound: location descriptor:
            (0x7f0d645b7550) DW_OP_GNU_variable_value , 0
...
to final debug:
...
          DW_AT_upper_bound: location descriptor:
            (0x7f0d645b7550) DW_OP_fbreg 18446744073709551592, 0
            (0x7f0d645b7a00) DW_OP_deref 8, 0
...
to -dA annotated assembly file:
...
        .uleb128 0x3    # DW_AT_upper_bound
        .byte   0x91    # DW_OP_fbreg
        .sleb128 -24
        .byte   0x6     # DW_OP_deref
...

The .debug file shows the same information as the annotated assembly, but in
the same format as the "early" debug info.

Bootstrapped and reg-tested on x86_64.

2018-08-21  Tom de Vries  <tdevries@suse.de>

* cgraph.h (debuginfo_early_init, debuginfo_init, debuginfo_fini)
(debuginfo_start, debuginfo_stop, debuginfo_early_start)
(debuginfo_early_stop): Declare.
* cgraphunit.c (debuginfo_early_init, debuginfo_init, debuginfo_fini)
(debuginfo_start, debuginfo_stop, debuginfo_early_start)
(debuginfo_early_stop): New function.
(symbol_table::finalize_compilation_unit): Call debuginfo_early_start
and debuginfo_early_stop.
* dwarf2out.c (dwarf2out_finish, dwarf2out_early_finish): Dump dwarf.
* toplev.c (compile_file): Call debuginfo_start and debuginfo_stop.
(general_init): Call debuginfo_early_init.
(finalize): Call debuginfo_fini.
(do_compile): Call debuginfo_init.
* doc/invoke.texi (@gccoptlist): Add -fdump-debug and
-fdump-early-debug.
(@item -fdump-debug, @item -fdump-earlydebug): Add.

* lto.c (lto_main):  Call debuginfo_early_start and
debuginfo_early_stop.

* gcc.c-torture/unsorted/dump-noaddr.x: Use -gno-record-gcc-switches
to avoid mismatch in .debug and .earlydebug dump files.

From-SVN: r263687

6 years ago[debug] Respect fdump-noaddr and fdump-unnumbered in print_die
Tom de Vries [Tue, 21 Aug 2018 07:39:17 +0000 (07:39 +0000)]
[debug] Respect fdump-noaddr and fdump-unnumbered in print_die

2018-08-21  Tom de Vries  <tdevries@suse.de>

* dwarf2out.c (print_dw_val, print_loc_descr, print_die): Handle
flag_dump_noaddr and flag_dump_unnumbered.

From-SVN: r263686

6 years agowide-int-range.cc (wide_int_range_abs): New.
Aldy Hernandez [Tue, 21 Aug 2018 06:27:14 +0000 (06:27 +0000)]
wide-int-range.cc (wide_int_range_abs): New.

* wide-int-range.cc (wide_int_range_abs): New.
(wide_int_range_order_set): Rename from wide_int_range_min_max.
* wide-int-range.h (wide_int_range_abs): New.
(wide_int_range_min_max): New.
* tree-vrp.c (extract_range_from_unary_expr): Rewrite ABS_EXPR
case to call wide_int_range_abs.
Rewrite MIN/MAX_EXPR to call wide_int_range_min_max.
(extract_range_from_abs_expr): Delete.

From-SVN: r263685

6 years agoDaily bump.
GCC Administrator [Tue, 21 Aug 2018 00:16:17 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263683

6 years ago[libiberty patch] PEX-unix forking
Nathan Sidwell [Tue, 21 Aug 2018 00:01:50 +0000 (00:01 +0000)]
[libiberty patch] PEX-unix forking

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01170.html
* pex-unix.c (pex_child_error): Delete.
(pex_unix_exec_child): Commonize error paths to single message &
exit.

From-SVN: r263679

6 years agore PR target/87033 (The compiler does not generate the LWAX instruction)
Michael Meissner [Mon, 20 Aug 2018 23:46:37 +0000 (23:46 +0000)]
re PR target/87033 (The compiler does not generate the LWAX instruction)

[gcc]
2018-08-20  Michael Meissner  <meissner@linux.ibm.com>

PR target/87033
* config/rs6000/rs6000.md (extendsi<mode>2): Change constraints
from 'Y' to 'YZ' to enable the LWAX instruction to be generated
for indexed loads.

[gcc/testsuite]
2018-08-20  Michael Meissner  <meissner@linux.ibm.com>

PR target/87033
* gcc.target/powerpc/pr87033.c: New test.

From-SVN: r263678

6 years ago[PATCH] fix some build breakage
Nathan Sidwell [Mon, 20 Aug 2018 23:31:18 +0000 (23:31 +0000)]
[PATCH] fix some build breakage

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01214.html
* config/s390/s390-c (s390_macro_to_expand): Use cpp_macro_p.
* config/spu/spu-c.c (spu_macro_to_expand): Likewise.

Co-Authored-By: Jeff Law <law@redhat.com>
From-SVN: r263677

6 years agoPR tree-optimization/87034 - missing -Wformat-overflow on a sprintf %s with a wide...
Martin Sebor [Mon, 20 Aug 2018 23:03:55 +0000 (23:03 +0000)]
PR tree-optimization/87034 - missing -Wformat-overflow on a sprintf %s with a wide string

gcc/testsuite/ChangeLog:
* gcc.dg/builtin-sprintf-warn-20.c: New test.

From-SVN: r263676

6 years agoAdd support for grouping of related diagnostics (PR other/84889)
David Malcolm [Mon, 20 Aug 2018 21:06:46 +0000 (21:06 +0000)]
Add support for grouping of related diagnostics (PR other/84889)

We often emit logically-related groups of diagnostics.

A relatively simple case is this:

  if (warning_at (body_loc, OPT_Wmultistatement_macros,
                  "macro expands to multiple statements"))
    inform (guard_loc, "some parts of macro expansion are not guarded by "
            "this %qs clause", guard_tinfo_to_string (keyword));

where the "note" diagnostic issued by the "inform" call
is guarded by the -Wmultistatement_macros warning.

More complicated examples can be seen in the C++ frontend,
where e.g. print_z_candidates can lead to numerous "note"
diagnostics being emitted.

I'm looking at various ways to improve how we handle such related
diagnostics, but, prior to this patch, there was no explicit
relationship between these diagnostics: the diagnostics subsystem
had no way of "knowing" that these were related.

This patch introduces a simple way to group the diagnostics:
an auto_diagnostic_group class: all diagnostics emitted within
the lifetime of an auto_diagnostic_group instance are logically
grouped.

Hence in the above example, the two diagnostics can be grouped
by simply adding an auto_diagnostic_group instance:

  auto_diagnostic_group d;
  if (warning_at (body_loc, OPT_Wmultistatement_macros,
                  "macro expands to multiple statements"))
    inform (guard_loc, "some parts of macro expansion are not guarded by "
            "this %qs clause", guard_tinfo_to_string (keyword));

Some more awkard cases are of the form:

  if (some_condition
      && warning_at (...)
      && more_conditions)
    inform (...);

which thus need restructuring to:

  if (some_condition)
    {
      auto_diagnostic_group d;
      warning_at (...);
      if (more_conditions)
        inform (...);
    }

so that the lifetime of the auto_diagnostic_group groups the
warning_at and the inform call.

Nesting is handled by simply tracking a nesting depth within the
diagnostic_context.: all diagnostics are treated as grouped until the
final auto_diagnostic_group is popped.

diagnostic.c uses this internally, so that all diagnostics are part of
a group - those that are "by themselves" are treated as being part of
a group with one element.

The diagnostic_context gains optional callbacks for displaying the
start of a group (when the first diagnostic is emitted within it), and
the end of a group (for when the group was non-empty); these callbacks
are unused by default, but a test plugin demonstrates them (and verifies
that the machinery is working).

As noted above, I'm looking at various ways to use the grouping to
improve how we output the diagnostics.

FWIW, I experimented with a more involved implementation, of the form:

  diagnostic_group d;
  if (d.warning_at (body_loc, OPT_Wmultistatement_macros,
                    "macro expands to multiple statements"))
    d.inform (guard_loc, "some parts of macro expansion are not guarded by "
              "this %qs clause", guard_tinfo_to_string (keyword));

which had the advantage of allowing auto-detection of the places where
groups were needed (by converting ::warning_at's return type to bool),
but it was a much more invasive patch, especially when dealing with
the places in the C++ frontend that can emit numerous notes after
an error or warning (and thus having to pass the group around)
Hence I went with this simpler approach.

gcc/c-family/ChangeLog:
PR other/84889
* c-attribs.c (common_handle_aligned_attribute): Add
auto_diagnostic_group instance.
* c-indentation.c (warn_for_misleading_indentation): Likewise.
* c-opts.c (c_common_post_options): Likewise.
* c-warn.c (warn_logical_not_parentheses): Likewise.
(warn_duplicated_cond_add_or_warn): Likewise.
(warn_for_multistatement_macros): Likewise.

gcc/c/ChangeLog:
PR other/84889
* c-decl.c (pushtag): Add auto_diagnostic_group instance.
(diagnose_mismatched_decls): Likewise, in various places.
(warn_if_shadowing): Likewise.
(implicit_decl_warning): Likewise.
(implicitly_declare): Likewise.
(undeclared_variable): Likewise.
(declare_label): Likewise.
(grokdeclarator): Likewise.
(start_function): Likewise.
* c-parser.c (c_parser_declaration_or_fndef): Likewise.
(c_parser_parameter_declaration): Likewise.
(c_parser_binary_expression): Likewise.
* c-typeck.c (c_expr_sizeof_expr): Likewise.
(parser_build_binary_op): Likewise.
(build_unary_op): Likewise.
(error_init): Likewise.
(pedwarn_init): Likewise.
(warning_init): Likewise.
(convert_for_assignment): Likewise.

gcc/cp/ChangeLog:
PR other/84889
* call.c (build_user_type_conversion_1): Add auto_diagnostic_group
instance(s).
(print_error_for_call_failure): Likewise.
(build_op_call_1): Likewise.
(build_conditional_expr_1): Likewise.
(build_new_op_1): Likewise.
(build_op_delete_call): Likewise.
(convert_like_real): Likewise.
(build_over_call): Likewise.
(build_new_method_call_1): Likewise.
(joust): Likewise.
* class.c (check_tag): Likewise.
(finish_struct_anon_r): Likewise.
(one_inherited_ctor): Likewise.
(finalize_literal_type_property): Likewise.
(explain_non_literal_class): Likewise.
(find_flexarrays): Likewise.
(resolve_address_of_overloaded_function): Likewise.
* constexpr.c (ensure_literal_type_for_constexpr_object): Likewise.
(is_valid_constexpr_fn): Likewise.
(cx_check_missing_mem_inits): Likewise.
* cp-gimplify.c (cp_genericize_r): Likewise.
* cvt.c (maybe_warn_nodiscard): Likewise.
* decl.c (warn_extern_redeclared_static): Likewise.
(check_redeclaration_exception_specification): Likewise.
(check_no_redeclaration_friend_default_args): Likewise.
(duplicate_decls): Likewise.
(redeclaration_error_message): Likewise.
(warn_misplaced_attr_for_class_type): Likewise.
* decl2.c (finish_static_data_member_decl): Likewise.
(no_linkage_error): Likewise.
(cp_warn_deprecated_use): Likewise.
* error.c (qualified_name_lookup_error): Likewise.
* friend.c (make_friend_class): Likewise.
(do_friend): Likewise.
* init.c (perform_member_init): Likewise.
(build_new_1): Likewise.
(build_vec_delete_1): Likewise.
(build_delete): Likewise.
* lex.c (unqualified_name_lookup_error): Likewise.
* name-lookup.c (check_extern_c_conflict): Likewise.
(inform_shadowed): New function.
(check_local_shadow): Add auto_diagnostic_group instances,
replacing goto "inform_shadowed" label with call to subroutine.
(set_local_extern_decl_linkage): Add auto_diagnostic_group
instance(s).
* parser.c (cp_parser_diagnose_invalid_type_name): Likewise.
(cp_parser_namespace_name): Likewise.
* pt.c (check_specialization_namespace): Likewise.
(check_template_variable): Likewise.
(warn_spec_missing_attributes): Likewise.
(check_explicit_specialization): Likewise.
(process_partial_specialization): Likewise.
(lookup_template_class_1): Likewise.
(finish_template_variable): Likewise.
(do_auto_deduction): Likewise.
* search.c (check_final_overrider): Likewise.
(look_for_overrides_r): Likewise.
* tree.c (maybe_warn_parm_abi): Likewise.
* typeck.c (cxx_sizeof_expr): Likewise.
(cp_build_function_call_vec): Likewise.
(cp_build_binary_op): Likewise.
(convert_for_assignment): Likewise.
(maybe_warn_about_returning_address_of_local): Likewise.
* typeck2.c (abstract_virtuals_error_sfinae): Likewise.
(check_narrowing): Likewise.

gcc/ChangeLog:
PR other/84889
* attribs.c (diag_attr_exclusions): Add auto_diagnostic_group instance.
(decl_attributes): Likewise.
* calls.c (maybe_warn_nonstring_arg): Add auto_diagnostic_group
instance.
* cgraphunit.c (maybe_diag_incompatible_alias): Likewise.
* diagnostic-core.h (class auto_diagnostic_group): New class.
* diagnostic.c (diagnostic_initialize): Initialize the new fields.
(diagnostic_report_diagnostic): Handle the first diagnostics within
a group.
(emit_diagnostic): Add auto_diagnostic_group instance.
(inform): Likewise.
(inform_n): Likewise.
(warning): Likewise.
(warning_at): Likewise.
(warning_n): Likewise.
(pedwarn): Likewise.
(permerror): Likewise.
(error): Likewise.
(error_n): Likewise.
(error_at): Likewise.
(sorry): Likewise.
(fatal_error): Likewise.
(internal_error): Likewise.
(internal_error_no_backtrace): Likewise.
(auto_diagnostic_group::auto_diagnostic_group): New ctor.
(auto_diagnostic_group::~auto_diagnostic_group): New dtor.
* diagnostic.h (struct diagnostic_context): Add fields
"diagnostic_group_nesting_depth",
"diagnostic_group_emission_count", "begin_group_cb",
"end_group_cb".
* gimple-ssa-isolate-paths.c (find_implicit_erroneous_behavior):
Add auto_diagnostic_group instance(s).
(find_explicit_erroneous_behavior): Likewise.
* gimple-ssa-warn-alloca.c (pass_walloca::execute): Likewise.
* gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Likewise.
* gimplify.c (warn_implicit_fallthrough_r): Likewise.
(gimplify_va_arg_expr): Likewise.
* hsa-gen.c (HSA_SORRY_ATV): Likewise.
(HSA_SORRY_AT): Likewise.
* ipa-devirt.c (compare_virtual_tables): Likewise.
(warn_odr): Likewise.
* multiple_target.c (expand_target_clones): Likewise.
* opts-common.c (cmdline_handle_error): Likewise.
* reginfo.c (globalize_reg): Likewise.
* substring-locations.c (format_warning_n_va): Likewise.
* tree-inline.c (expand_call_inline): Likewise.
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise.
* tree-ssa-loop-niter.c
(do_warn_aggressive_loop_optimizations): Likewise.
* tree-ssa-uninit.c (warn_uninit): Likewise.
* tree.c (warn_deprecated_use): Likewise.

gcc/testsuite/ChangeLog:
PR other/84889
* gcc.dg/plugin/diagnostic-group-test-1.c: New test.
* gcc.dg/plugin/diagnostic_group_plugin.c: New test.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add the new tests.

From-SVN: r263675

6 years agox86: Always update EH return address in word_mode
H.J. Lu [Mon, 20 Aug 2018 19:14:04 +0000 (19:14 +0000)]
x86: Always update EH return address in word_mode

On x86, return address is always popped in word_mode.  eh_return needs
to put EH return address in word_mode on stack.

gcc/

PR target/87014
* config/i386/i386.md (eh_return): Always update EH return
address in word_mode.

gcc/testsuite/

PR target/87014
* g++.dg/torture/pr87014.C: New file.

From-SVN: r263672

6 years agotarghooks.c (std_gimplify_va_arg_expr): Properly handle case of when TARGET_SPLIT_COM...
Chung-Lin Tang [Mon, 20 Aug 2018 18:32:06 +0000 (18:32 +0000)]
targhooks.c (std_gimplify_va_arg_expr): Properly handle case of when TARGET_SPLIT_COMPLEX_ARG is defined.

* targhooks.c (std_gimplify_va_arg_expr): Properly handle case of when
TARGET_SPLIT_COMPLEX_ARG is defined.

From-SVN: r263671

6 years ago[CPP PATCH] node field bits
Nathan Sidwell [Mon, 20 Aug 2018 17:45:42 +0000 (17:45 +0000)]
[CPP PATCH] node field bits

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01171.html
* include/cpplib.h: Fixup some whitespace.
(cpp_hashnode): Reduce type to 2 bit & flags to 8.

From-SVN: r263669

6 years ago[CPP PATCH] node type
Nathan Sidwell [Mon, 20 Aug 2018 16:32:29 +0000 (16:32 +0000)]
[CPP PATCH] node type

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01164.html
* include/cpplib.h (NODE_BUILTIN, NODE_MACRO_ARG): Delete.
Renumber others.
(enum node_type): Replace NT_MACRO with NT_USER_MACRO,
NT_BUILTIN_MACRO, NT_MACRO_ARG.  Delete NT_ASSERTION.
(NTV_MACRO, NTV_ANSWER, NTV_BUILTIN, NTV_ARGUMENT, NTV_NONE):
Delete.
(CPP_HASHNODE_VALUE_IDX): Delete.
(union _cpp_hashnode_value): GTY tag from enum node_type directly.
(struct cpp_hashnode): Adjust GTY desc for value field.
(cpp_user_macro_p, cpp_builtin_macro_p, cpp_macro_p): Adjust.
* directives.c (undefine_macros): Clear value.anwers, adjust flag
clearing.
(_cpp_test_assertion): No need to check NT_ASSERTION.
(do_assert, do_unassert): Likewise.
* init.c (cpp_init_special_builtins): Set type not flags.
* macro.c (struct macro_arg_saved_data): Add type field.
(cpp_get_token_1): Check type not NT_VOID.
(_cpp_free_definition): Adjust flag clearing.  Nullify
value.answers.
(_cpp_save_parameter, _cpp_unsave_parameters): Save and restore
type.
(lex_expansion_token): Check type not flags.
(_cpp_create_definition): Set type to NT_USER_MACRO.
(_cpp_notify_macro_use): Adjust type checking.
* pch.c (write_macdef, count_defs, write_defs, cpp_valid_state)
(save_macros): Adjust node type/flag handling.
* traditional.c (_cpp_scan_out_logical_line): Check type not flags.

From-SVN: r263667

6 years ago[CPP PATCH] Fix warning & other cleanups.
Nathan Sidwell [Mon, 20 Aug 2018 15:28:15 +0000 (15:28 +0000)]
[CPP PATCH] Fix warning & other cleanups.

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01162.html
* directives.c (do_undef): Use cpp_macro_p & cpp_builtin_macro_p.
* include/cpplib.h (enum cpp_macro_kind): Remove trailing comma.
(cpp_fun_like_macro_p): Make inline, define.
* macro.c (cpp_define_lazily): Use UCHAR_MAX.
(cpp_fun_like_macro_p): Delete.

From-SVN: r263666

6 years agoexpr.c (store_field): Change gcc_assert to gcc_checking_assert.
Bernd Edlinger [Mon, 20 Aug 2018 15:01:04 +0000 (15:01 +0000)]
expr.c (store_field): Change gcc_assert to gcc_checking_assert.

2018-08-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

* expr.c (store_field): Change gcc_assert to gcc_checking_assert.

From-SVN: r263665

6 years agore PR target/86984 (invalid relocation accessing a const char array)
Bernd Edlinger [Mon, 20 Aug 2018 14:20:59 +0000 (14:20 +0000)]
re PR target/86984 (invalid relocation accessing a const char array)

PR target/86984
* expr.c (expand_assignment): Assert that bitpos is positive.
(store_field): Likewise
(expand_expr_real_1): Make sure that bitpos is positive.
* config/alpha/alpha.h (CONSTANT_ADDRESS_P): Avoid signed
integer overflow.

PR target/86984
* gcc.target/alpha/pr86984.c: New test.

From-SVN: r263664

6 years ago[PATCH] Kill cpp-id-data.h
Nathan Sidwell [Mon, 20 Aug 2018 14:20:04 +0000 (14:20 +0000)]
[PATCH] Kill cpp-id-data.h

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01149.html
libcpp/
* Makefile.in (TAGS_SOURCES): Remove cpp-id-data.h.
* include/cpp-id-data.h: Delete.
* internal.h: Include cpplib.h not cpp-id-data.h.
gcc/
* Makefile.in (CPP_ID_DATA_H): Delete.
(CPP_INTERNAL_H): Don't add it.
(GTFILES): Replace CPP_ID_DATA_H with CPPLIB_H.
* gengtype.c (open_base_files): Replace cpp-id-data.h with cpplib.h

From-SVN: r263663

6 years agore PR c++/78655 (gcc doesn't exploit the fact that the result of pointer addition...
Richard Biener [Mon, 20 Aug 2018 14:01:05 +0000 (14:01 +0000)]
re PR c++/78655 (gcc doesn't exploit the fact that the result of pointer addition can not be nullptr)

2018-08-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78655
* tree-vrp.c (extract_range_from_binary_expr_1): Make
pointer + offset nonnull if either operand is nonnull work.

* gcc.dg/tree-ssa/evrp11.c: New testcase.

From-SVN: r263662

6 years agoPR libstdc++/86963 Remove use of __tuple_base in std::tuple
Jonathan Wakely [Mon, 20 Aug 2018 13:53:56 +0000 (14:53 +0100)]
PR libstdc++/86963 Remove use of __tuple_base in std::tuple

The _Tuple_impl base class can be used to disable copy/move assignment,
without requiring an extra base class.

Exception specifications on std::tuple assignment and swap functions can
be defined directly using is_nothrow_swappable, instead of querying the
base classes.

PR libstdc++/86963
* include/std/tuple (_Tuple_impl::operator=): Define as deleted.
(_Tuple_impl::_M_assign): New functions to perform assignment instead
of assignment operators.
(_Tuple_impl::_M_swap): Remove exception specification.
(_Tuple_impl<_Idx, _Head>): Likewise.
(_TC::_NonNestedTuple, _TC::_NotSameTuple): Use __remove_cvref_t.
(__tuple_base): Remove.
(tuple, tuple<_T1, _T2>): Remove inheritance from __tuple_base.
(tuple::operator=, tuple<_T1, _T2>::operator=): Call _M_assign.
(tuple::swap, tuple<_T1, _T2>::swap): Define exception specification
using __is_nothrow_swappable.
(tuple<_T1, _T2>::tuple(_U1&&, _U2&&)): Use __remove_cvref_t.

From-SVN: r263661

6 years ago[debug] Fix handling of vlas in lto
Tom de Vries [Mon, 20 Aug 2018 13:52:29 +0000 (13:52 +0000)]
[debug] Fix handling of vlas in lto

Atm, when running vla-1.c with -O0 -flto, we have:
...
FAIL: gcc.dg/guality/vla-1.c -O0 -flto -fuse-linker-plugin \
  -fno-fat-lto-objects line 17 sizeof (a) == 6
...

The vla a[i + 1] in f1 is gimplified into:
...
f1 (int i)
{
  char a[0:D.1922] [value-expr: *a.0];
  char[0:D.1922] * a.0;

  D.1921 = i + 1;
  D.1926 = (sizetype) D.1921;
  a.0 = __builtin_alloca_with_align (D.1926, 8);
...

The early debug info for the upper bound of the type of vla a that we stream
out is:
...
  DIE    0: DW_TAG_subrange_type (0x7f85029a90f0)
    DW_AT_upper_bound: location descriptor:
      (0x7f85029a9230) DW_OP_GNU_variable_value die -> 0 (0x7f85029a94b0), 0
  DIE    0: DW_TAG_variable (0x7f85029a94b0)
    DW_AT_name: "D.1922"
    DW_AT_type: die -> 0 (0x7f85029a3d70)
    DW_AT_artificial: 1
...

and in ltrans we have for that same upper bound:
...
  DIE    0: DW_TAG_subrange_type (0x7f5183b57d70)
    DW_AT_upper_bound: die -> 0 (0x7f5183b576e0)
  DIE    0: DW_TAG_variable (0x7f5183b576e0)
    DW_AT_name: "D.4278"
    DW_AT_abstract_origin: die -> label: vla_1.c.6719312a + 193 (0x7f5183b57730)
...
where D.4278 has abstract origin D.1922.

The D.4278 die has no DW_AT_location, so when evaluting "sizeof (a)" in the
debugger, we can't find the information to get the value of D.4278, and the
debugger prints "<optimized out>".

This patch fixes that by either:
- adding DW_AT_location to the referenced variable die, or
- instead of using a ref for the upper bound, using an exprloc.

When changing gcc.dg/guality/guality.exp to run the usual flto flavours
"-fno-use-linker-plugin -flto-partition=none" and "-fuse-linker-plugin
-fno-fat-lto-objects" in combination with O0, Og, O1, O2, O3 and Os, this patch
fixes all (20) failures in vla-1.c, leaving only:
...
No symbol "i" in current context.
UNSUPPORTED: gcc.dg/guality/vla-1.c  -O3 -flto -fno-use-linker-plugin \
  -flto-partition=none line 17 i == 5
'a' has unknown type; cast it to its declared type
UNSUPPORTED: gcc.dg/guality/vla-1.c  -O3 -flto -fno-use-linker-plugin \
  -flto-partition=none line 17 sizeof (a) == 6
...

Bootstrapped and reg-tested on x86_64.

2018-08-20  Tom de Vries  <tdevries@suse.de>

* dwarf2out.c (add_scalar_info): Don't add reference to existing die
unless the referenced die describes the added property using
DW_AT_location or DW_AT_const_value.  Fall back to exprloc case.
Otherwise, add a DW_AT_location to the referenced die.

From-SVN: r263660

6 years ago[PATCH] #assert becomes macro-like
Nathan Sidwell [Mon, 20 Aug 2018 12:39:36 +0000 (12:39 +0000)]
[PATCH] #assert becomes macro-like

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01140.html
libcpp/
* include/cpp-id-data.h (struct answer): Delete.
* include/cpplib.h (struct answer): Don't forward-declare.
(enum cpp_macro_kind): Add cmk_assert.
(struct cpp_macro): Union parms and next assert chain.
(union _cpp_hashnode_value): 'answer' field is cpp_macro.
* directives.c (parse_answer): Convert to use cpp_macro. Return
true on success.
(parse_assertion, find_answer, _cpp_test_assertion, cpp_do_assert)
(cpp_do_unassert): Convert to use cpp_macro.
* macro.c (warn_of_redefinition, _cpp_new_macro)
(check_trad_stringification, cpp_macro_definition): Adjust macro
parm access.
* traditional.c (_cpp_replacement_text_len)
(_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise.
gcc/c-family/
* c-ada-spec.c (macro_length, dump_ada_macros): Adjust macro parm
access.

From-SVN: r263658

6 years agoRefactor std::optional SFINAE constraints
Jonathan Wakely [Mon, 20 Aug 2018 12:13:25 +0000 (13:13 +0100)]
Refactor std::optional SFINAE constraints

* include/std/optional (_Optional_payload): Use variable templates
for conditions in default template arguments and exception
specifications.
(optional): Likewise. Adjust indentation.
(optional::__not_self, optional::__not_tag, optional::_Requires): New
SFINAE helpers.
(optional::optional): Use new helpers in constructor constraints.
* include/std/type_traits (__or_v, __and_v): New variable templates.
* testsuite/20_util/optional/cons/value_neg.cc: Change dg-error to
dg-prune-output. Remove unused header.

From-SVN: r263657

6 years agoDaily bump.
GCC Administrator [Mon, 20 Aug 2018 00:16:26 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263656

6 years agore PR target/86994 (64-bit gcc.target/i386/20040112-1.c FAILs)
Uros Bizjak [Sun, 19 Aug 2018 19:10:37 +0000 (21:10 +0200)]
re PR target/86994 (64-bit gcc.target/i386/20040112-1.c FAILs)

PR target/86994
* config/i386/i386.c (ix86_rtx_costs) [case SET]: Check source for
register_operand when calling ix86_set_reg_reg_cost.
[case CONST_INT, case CONST, case LABEL_REF, case SYMBOL_REF]:
Set *total to 0 for operands that satisfy x86_64_immediate_operand
predicate and to 1 otherwise.

From-SVN: r263652

6 years agoDaily bump.
GCC Administrator [Sun, 19 Aug 2018 00:16:19 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263651

6 years ago86658.cc: Use dg-options to define _GLIBCXX_DEBUG.
François Dumont [Sat, 18 Aug 2018 20:01:14 +0000 (20:01 +0000)]
86658.cc: Use dg-options to define _GLIBCXX_DEBUG.

2018-08-18  François Dumont  <fdumont@gcc.gnu.org>

* testsuite/25_algorithms/copy/86658.cc: Use dg-options to define
_GLIBCXX_DEBUG.

From-SVN: r263647

6 years agoDarwin emits pubnames/types by default which mask the intent of the test.
Iain Sandoe [Sat, 18 Aug 2018 09:24:55 +0000 (09:24 +0000)]
Darwin emits pubnames/types by default which mask the intent of the test.

gcc/testsuite

2018-08-18  Iain Sandoe  <iain@sandoe.co.uk>

* gcc.dg/debug/dwarf2/pr80263.c: Suppress pubtypes output
for Darwin.

From-SVN: r263646

6 years agoDarwin does not support gsplit-dwarf.
Iain Sandoe [Sat, 18 Aug 2018 09:15:05 +0000 (09:15 +0000)]
Darwin does not support gsplit-dwarf.

2018-08-18  Iain Sandoe  <iain@sandoe.co.uk>

gcc/

* config/darwin.c (darwin_override_options): If -gsplit-dwarf is set,
emit a diagnostic that it is not supported and reset the option.
* config/darwin.h (DRIVER_SELF_SPECS): Note that gsplit-dwarf is not
supported and consume the option.  (ASM_FINAL_SPEC): New.

gcc/testsuite

* g++.dg/debug/dwarf2/pr85302.C: Skip unsupported split DWARF
test on Darwin.
* g++.dg/debug/dwarf2/pr85302.C: Likewise.
* gcc.dg/lto/pr83719_0.c: Likewise.

From-SVN: r263645

6 years agoDaily bump.
GCC Administrator [Sat, 18 Aug 2018 00:16:26 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263644

6 years ago[PATCH] Adjust lazy macro definition
Nathan Sidwell [Fri, 17 Aug 2018 23:18:11 +0000 (23:18 +0000)]
[PATCH] Adjust lazy macro definition

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01072.html
libcpp/
* include/cpplib.h (struct cpp_callbacks): Replace
user_builtin_macro with user_lazy_macro.
(struct cpp_macro): add lazy field.
(enum cpp_builtin_type): Remove BT_FIRST_USER, BT_LAST_USER.
(cpp_define_lazily): Declare.
* macro.c (enter_macro_context) Use _cpp_maybe_notify_macro_use.
(warn_of_redefinition): Use cpp_builtin_macro_p, directly call
user_lazy_macro hook.
(_cpp_new_macro): Clear lazy field.
(cpp_define_lazily): Define.
(_cpp_notify_macro_use): Adjust lazy definition code.
(cpp_macro_definition): No need to do lazy definition here.
* pch.c (write_macdef, save_macros): Likewise.
gcc/c-family/
* c-cppbuiltin.c (struct lazy_hex_fp_value_struct): Remove macro
field.
(laxy_hex_fp_value_count): Make unsigned.
(lazy_hex_fp_value): Provided with macro & lazy number.  Directly
manipulate the macro.
(builtin_defin_with_hex_fp_value): Adjust callback name, use
cpp_define_lazily.

From-SVN: r263640

6 years agore PR testsuite/86996 (gcc.dg/tree-ssa/builtin-sprintf-warn-1.c FAILs)
Martin Sebor [Fri, 17 Aug 2018 21:58:27 +0000 (21:58 +0000)]
re PR testsuite/86996 (gcc.dg/tree-ssa/builtin-sprintf-warn-1.c FAILs)

PR testsuite/86996

gcc/testsuite/CHangeLog:
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust.

From-SVN: r263636

6 years agoC++: -Wwrite-strings: use location of string constant
David Malcolm [Fri, 17 Aug 2018 21:56:21 +0000 (21:56 +0000)]
C++: -Wwrite-strings: use location of string constant

Consider:

extern int callee (const char *one, char *two, const char *three);

int test ()
{
  return callee ("first", "second", "third");
}

for which -Wwrite-strings was emitting:

Wwrite-strings.C: In function 'int test()':
Wwrite-strings.C:10:44: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
10 |   return callee ("first", "second", "third");
   |                                            ^

This patch fixes the warning so that it underlines the pertinent argument
at the callsite:

Wwrite-strings.C: In function 'int test()':
Wwrite-strings.C:10:27: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
10 |   return callee ("first", "second", "third");
   |                           ^~~~~~~~

Ideally we ought to also issue a "note" highlighting the pertinent
parameter within the decl, but that's not readily available, so I'm
saving it for another patch.

gcc/cp/ChangeLog:
* typeck.c (string_conv_p): Extract location from EXP and use it
in preference to input_location when issuing warnings.

gcc/testsuite/ChangeLog:
* g++.dg/conversion/Wwrite-strings.C: New test.

From-SVN: r263635

6 years agodoc: Use @ref, not @xref, in the middle of a sentence
Segher Boessenkool [Fri, 17 Aug 2018 19:35:18 +0000 (21:35 +0200)]
doc: Use @ref, not @xref, in the middle of a sentence

makeinfo warns about this.

* doc/md.texi (Patterns): Use @ref instead of @xref in the middle of
a sentence.

From-SVN: r263633

6 years ago2018-08-17 Sandra Loosemore <sandra@codesourcery.com>
Sandra Loosemore [Fri, 17 Aug 2018 19:18:38 +0000 (15:18 -0400)]
2018-08-17  Sandra Loosemore  <sandra@codesourcery.com>

MAINTAINERS: Add c-sky port maintainers.

From-SVN: r263632

6 years agoC-SKY port: libgcc
Jojo [Fri, 17 Aug 2018 19:08:27 +0000 (19:08 +0000)]
C-SKY port: libgcc

2018-08-17  Jojo  <jijie_rong@c-sky.com>
    Huibin Wang  <huibin_wang@c-sky.com>
    Sandra Loosemore  <sandra@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>

C-SKY port: libgcc

libgcc/
* config.host: Add C-SKY support.
* config/csky/*: New.

Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
Co-Authored-By: Huibin Wang <huibin_wang@c-sky.com>
Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
From-SVN: r263631

6 years agoC-SKY port: Testsuite
Sandra Loosemore [Fri, 17 Aug 2018 19:06:52 +0000 (15:06 -0400)]
C-SKY port: Testsuite

2018-08-17  Sandra Loosemore  <sandra@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>
    Xianmiao Qu  <xianmiao_qu@c-sky.com>

C-SKY port: Testsuite

gcc/testsuite/
* g++.dg/Wno-frame-address.C: Adjust for C-SKY.
* g++.dg/torture/type-generic-1.C: Likewise.
* gcc.c-torture/compile/20000804-1.c: Likewise.
* gcc.c-torture/execute/20101011-1.c: Likewise.
* gcc.c-torture/execute/ieee/mul-subnormal-single-1.x: Likewise.
* gcc.dg/20020312-2.c: Likewise.
* gcc.dg/Wno-frame-address.c: Likewise.
* gcc.dg/c11-true_min-1.c: Likewise.
* gcc.dg/sibcall-10.c: Likewise.
* gcc.dg/sibcall-9.c: Likewise.
* gcc.dg/stack-usage-1.c: Likewise.
* gcc.dg/torture/float32-tg-3.c: Likewise.
* gcc.dg/torture/float32x-tg-3.c: Likewise.
* gcc.dg/torture/float64-tg-3.c: Likewise.
* gcc.dg/torture/float64x-tg-3.c: Likewise.
* gcc.dg/torture/type-generic-1.c: Likewise.
* gcc.target/csky/*: New.
* lib/target-supports.exp (check_profiling_available): Add
csky-*-elf.
(check_effective_target_hard_float): Handle C-SKY targets with
single-precision hard float only.
(check_effective_target_logical_op_short_circuit): Handle C-SKY.

Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
Co-Authored-By: Xianmiao Qu <xianmiao_qu@c-sky.com>
From-SVN: r263630

6 years agoC-SKY port: Documentation
Sandra Loosemore [Fri, 17 Aug 2018 19:05:12 +0000 (15:05 -0400)]
C-SKY port: Documentation

2018-08-17  Sandra Loosemore  <sandra@codesourcery.com>

C-SKY port: Documentation

gcc/
* doc/extend.texi (C-SKY Function Attributes): New section.
* doc/invoke.texi (Option Summary): Add C-SKY options.
(C-SKY Options): New section.
* doc/md.texi (Machine Constraints): Document C-SKY constraints.

From-SVN: r263629

6 years agoC-SKY port: Backend implementation
Jojo [Fri, 17 Aug 2018 19:03:27 +0000 (19:03 +0000)]
C-SKY port: Backend implementation

2018-08-17  Jojo  <jijie_rong@c-sky.com>
    Huibin Wang  <huibin_wang@c-sky.com>
    Sandra Loosemore  <sandra@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>

C-SKY port: Backend implementation

gcc/
* config/csky/*: New.
* common/config/csky/*: New.

Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
Co-Authored-By: Huibin Wang <huibin_wang@c-sky.com>
Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
From-SVN: r263628

6 years agoC-SKY port: Configury
Jojo [Fri, 17 Aug 2018 19:00:25 +0000 (19:00 +0000)]
C-SKY port: Configury

2018-08-17  Jojo  <jijie_rong@c-sky.com>
    Huibin Wang  <huibin_wang@c-sky.com>
    Sandra Loosemore  <sandra@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>
    Andrew Jenner  <andrew@codesourcery.com>

C-SKY port: Configury

gcc/
* config.gcc (csky-*-*): New.
* configure.ac: Add csky to targets for dwarf2 debug_line support.
* configure: Regenerated.

contrib/
* config-list.mk (LIST): Add csky-elf and csky-linux-gnu.

Co-Authored-By: Andrew Jenner <andrew@codesourcery.com>
Co-Authored-By: Chung-Lin Tang <cltang@codesourcery.com>
Co-Authored-By: Huibin Wang <huibin_wang@c-sky.com>
Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
From-SVN: r263627

6 years agoFormatted printing for dump_* in the middle-end
David Malcolm [Fri, 17 Aug 2018 18:21:31 +0000 (18:21 +0000)]
Formatted printing for dump_* in the middle-end

This patch converts dump_print and dump_printf_loc from using
printf (and thus ATTRIBUTE_PRINTF) to using a new pretty-printer
based on pp_format, which supports formatting middle-end types.

In particular, the following codes are implemented (in addition
to the standard pretty_printer ones):

   %E: gimple *:
       Equivalent to: dump_gimple_expr (MSG_*, TDF_SLIM, stmt, 0)
   %G: gimple *:
       Equivalent to: dump_gimple_stmt (MSG_*, TDF_SLIM, stmt, 0)
   %T: tree:
       Equivalent to: dump_generic_expr (MSG_*, arg, TDF_SLIM).

Hence it becomes possible to convert e.g.:

  if (dump_enabled_p ())
    {
      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                       "not vectorized: different sized vector "
                       "types in statement, ");
      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype);
      dump_printf (MSG_MISSED_OPTIMIZATION, " and ");
      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, nunits_vectype);
      dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
    }

into a one-liner:

  if (dump_enabled_p ())
    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                     "not vectorized: different sized vector "
                     "types in statement, %T and %T\n",
                     vectype, nunits_vectype);

Unlike regular pretty-printers, this one captures optinfo_item
instances for the formatted chunks as appropriate, so that when
written out to a JSON optimization record, the relevant parts of
the message are labelled by type, and by source location (so that
e.g. %G is entirely equivalent to using dump_gimple_stmt).

dump_printf and dump_printf_loc become marked with
ATTRIBUTE_GCC_DUMP_PRINTF, which the patch also implements.

gcc/c-family/ChangeLog:
* c-format.c (enum format_type): Add gcc_dump_printf_format_type.
(gcc_dump_printf_length_specs): New.
(gcc_dump_printf_flag_pairs): New.
(gcc_dump_printf_flag_specs): New.
(gcc_dump_printf_char_table): New.
(format_types_orig): Add entry for "gcc_dump_printf".
(init_dynamic_diag_info): Set up length_char_specs and
conversion_specs for gcc_dump_printf_format_type.
(handle_format_attribute): Handle gcc_dump_printf_format_type.

gcc/ChangeLog:
* dump-context.h: Include "dumpfile.h".
(dump_context::dump_printf_va): Convert final param from va_list
to va_list *.  Convert from ATTRIBUTE_PRINTF to
ATTRIBUTE_GCC_DUMP_PRINTF.
(dump_context::dump_printf_loc_va): Likewise.
* dumpfile.c: Include "stringpool.h".
(make_item_for_dump_printf_va): Delete.
(make_item_for_dump_printf): Delete.
(class dump_pretty_printer): New class.
(dump_pretty_printer::dump_pretty_printer): New ctor.
(dump_pretty_printer::emit_items): New member function.
(dump_pretty_printer::emit_any_pending_textual_chunks): New member
function.
(dump_pretty_printer::emit_item): New member function.
(dump_pretty_printer::stash_item): New member function.
(dump_pretty_printer::format_decoder_cb): New member function.
(dump_pretty_printer::decode_format): New member function.
(dump_context::dump_printf_va): Reimplement in terms of
dump_pretty_printer.
(dump_context::dump_printf_loc_va): Convert final param from va_list
to va_list *.
(dump_context::begin_scope): Reimplement call to
make_item_for_dump_printf.
(dump_printf): Update for change to dump_printf_va.
(dump_printf_loc): Likewise.
(selftest::test_capture_of_dump_calls): Convert "stmt" from
greturn * to gimple *.  Add a test_decl.  Add tests of dump_printf
with %T, %E, and %G.
* dumpfile.h (ATTRIBUTE_GCC_DUMP_PRINTF): New macro.
(dump_printf): Replace ATTRIBUTE_PRINTF_2 with
ATTRIBUTE_GCC_DUMP_PRINTF (2, 3).
(dump_printf_loc): Replace ATTRIBUTE_PRINTF_3 with
ATTRIBUTE_GCC_DUMP_PRINTF (3, 0).
* tree-vect-data-refs.c (vect_lanes_optab_supported_p): Convert
use of HOST_WIDE_INT_PRINT_DEC on unsigned HOST_WIDE_INT "count"
within a dump_printf_loc call to "%wu".
(vector_alignment_reachable_p): Merge two dump_printf[_loc] calls,
converting a use of HOST_WIDE_INT_PRINT_DEC to "%wd".  Add a
missing space after "=".
* tree-vect-loop.c (vect_analyze_loop_2) Within a dump_printf
call, convert use of HOST_WIDE_INT_PRINT_DEC to "%wd".
* tree-vect-slp.c (vect_slp_bb): Within a dump_printf_loc call,
convert use of HOST_WIDE_INT_PRINT_UNSIGNED to "%wu".
* tree-vectorizer.c (try_vectorize_loop_1): Likewise.  Remove
duplicate "vectorized" from message.

gcc/testsuite/ChangeLog:
* gcc.dg/format/gcc_diag-1.c: Fix typo.  Add test coverage for
gcc_dump_printf.
* gcc.dg/format/gcc_diag-10.c: Add gimple typedef.  Add test
coverage for gcc_dump_printf.

From-SVN: r263626

6 years agoPR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
Jonathan Wakely [Fri, 17 Aug 2018 17:52:49 +0000 (18:52 +0100)]
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment

PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.

From-SVN: r263625

6 years agoFix poly types after PR tree-optimization/71625 strlen optimization
Szabolcs Nagy [Fri, 17 Aug 2018 17:26:11 +0000 (17:26 +0000)]
Fix poly types after PR tree-optimization/71625 strlen optimization

Same as r263561, but for arm: avoid compilation errors caused by poly
initializers getting treated as string literals.

Tested on arm-none-linux-gnueabihf.

gcc/ChangeLog:

* config/arm/arm-builtins.c (arm_init_simd_builtin_types): Clear
polyNxK_t element's TYPE_STRING_FLAG.

From-SVN: r263624

6 years agors6000: Give names to cbranch/creturn patterns
Segher Boessenkool [Fri, 17 Aug 2018 17:22:36 +0000 (19:22 +0200)]
rs6000: Give names to cbranch/creturn patterns

This gives a name to the conditional branch and conditional return
patterns, so that it looks neater in dumps and verbose asm.  Also, the
comment for conditional branch was out of date; this fixes it.

* config/rs6000/rs6000.md (*cbranch, *creturn): Name these patterns
(they were unnamed before).  Fix comments.

From-SVN: r263623

6 years ago[PATCH] Macro body is trailing array
Nathan Sidwell [Fri, 17 Aug 2018 16:07:19 +0000 (16:07 +0000)]
[PATCH] Macro body is trailing array

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01037.html
* include/cpplib.h (enum cpp_macro_kind): New.
(struct cpp_macro): Make body trailing array.  Add kind field,
delete traditional flag.
* internal.h (_cpp_new_macro): Declare.
(_cpp_reserve_room): New inline.
(_cpp_commit_buf): Declare.
(_cpp_create_trad_definition): Return new macro.
* lex.c (_cpp_commit_buff): New.
* macro.c (macro_real_token_count): Count backwards.
(replace_args): Pointer equality not orderedness.
(_cpp_save_parameter): Use _cpp_reserve_room.
(alloc_expansion_token): Delete.
(lex_expansion_token): Return macro pointer.  Use _cpp_reserve_room.
(create_iso_definition): Allocate macro itself.  Adjust for
different allocation ordering.
(_cpp_new_macro): New.
(_cpp_create_definition): Adjust for API changes.
* traditional.c (push_replacement_text): Don't set traditional
flag.
(save_replacement_text): Likewise.
(_cpp_create_trad_definition): Allocate macro itself, Adjust for
different allocation ordering.

From-SVN: r263622

6 years ago[PATCH] Move cpp_macro to cpplib.h
Nathan Sidwell [Fri, 17 Aug 2018 12:04:13 +0000 (12:04 +0000)]
[PATCH] Move cpp_macro to cpplib.h

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01016.html
libcpp/
* cpp-id-data.h (uchar, UC): Move to internal.h
(struct cpp_macro): Move to cpplib.h.
* internal.h (uchar, UC): From cpp-id-data.h.
* include/cpplib.h (struct cpp_macro): From cpp-id-data.h.
gcc/c-family/
* c-ada-spec.c: Don't #include "cpp-id-data.h"
* c-cppbuiltin.c: Likewise.
gcc/
* cppbuiltin.c: Include "cpplib.h", not "cpp-id-data.h".

From-SVN: r263618

6 years agore PR tree-optimization/86841 (ICE in gcc/gcc/tree-vrp.c:1325 with graphite)
Richard Biener [Fri, 17 Aug 2018 09:26:53 +0000 (09:26 +0000)]
re PR tree-optimization/86841 (ICE in gcc/gcc/tree-vrp.c:1325 with graphite)

2018-08-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86841
* wide-int-range.cc (wide_int_range_lshift): Use to_uhwi.

From-SVN: r263615

6 years agoMerge Ignore and Deprecated in .opt files.
Martin Liska [Fri, 17 Aug 2018 09:25:56 +0000 (11:25 +0200)]
Merge Ignore and Deprecated in .opt files.

2018-08-17  Martin Liska  <mliska@suse.cz>

* common.opt: Remove Warn, Init and Report for options with
        Ignore/Deprecated flag. Warning is done automatically for
        Deprecated flags.
* config/i386/i386.opt: Likewise.
* config/ia64/ia64.opt: Likewise.
* config/rs6000/rs6000.opt: Likewise.
* cppbuiltin.c (define_builtin_macros_for_compilation_flags):
        Remove usage of flag_check_pointer_bounds.
* lto-wrapper.c (merge_and_complain): Do not handle
        OPT_fcheck_pointer_bounds.
(append_compiler_options): Likewise.
* opt-functions.awk: Do not handle Deprecated.
* optc-gen.awk: Check that Var, Report and Init are not
        used for an option with Ignore/Deprecated flag.
* opts-common.c (decode_cmdline_option): Do not report
        CL_ERR_DEPRECATED.
(read_cmdline_option): Report warning for OPT_SPECIAL_deprecated
        options.
* opts.h (struct cl_option): Remove cl_deprecated flag.
(CL_ERR_DEPRECATED): Remove error enum value.
2018-08-17  Martin Liska  <mliska@suse.cz>

* g++.dg/opt/mpx.C: Fix scanned pattern.
* gcc.target/i386/mpx.c: Likewise.
* g++.dg/warn/Wunreachable-code-1.C: Remove.
* g++.dg/warn/Wunreachable-code-2.C: Likewise.
* gcc.dg/torture/pr52969.c: Likewise.
* g++.dg/warn/pr31246-2.C: Likewise.
* g++.dg/warn/pr31246.C: Likewise.
* gcc.dg/pr33092.c: Likewise.
* g++.dg/opt/eh1.C: Remove a deprecated option.
* g++.dg/template/inline1.C: Likewise.
* g++.dg/tree-ssa/pr81408.C: Likewise.
* gcc.dg/pr41837.c: Likewise.
* gcc.dg/pr41841.c: Likewise.
* gcc.dg/pr42250.c: Likewise.
* gcc.dg/pr43084.c: Likewise.
* gcc.dg/pr43317.c: Likewise.
* gcc.dg/pr51879-18.c: Likewise.
* gcc.dg/torture/pr36066.c: Likewise.
* gcc.dg/tree-ssa/ifc-8.c: Likewise.
* gcc.dg/tree-ssa/ifc-cd.c: Likewise.
* gcc.dg/tree-ssa/pr19210-1.c: Likewise.
* gcc.dg/tree-ssa/pr45122.c: Likewise.
* gcc.target/i386/pr45352-2.c: Likewise.
* gcc.target/i386/zee.c: Likewise.
* gfortran.dg/auto_char_len_2.f90: Likewise.
* gfortran.dg/auto_char_len_4.f90: Likewise.
* gfortran.dg/c_ptr_tests_15.f90: Likewise.
* gfortran.dg/char_array_structure_constructor.f90: Likewise.
* gfortran.dg/gomp/pr47331.f90: Likewise.
* gfortran.dg/pr40999.f: Likewise.
* gfortran.dg/pr41011.f: Likewise.
* gfortran.dg/pr42051.f03: Likewise.
* gfortran.dg/pr46804.f90: Likewise.
* gfortran.dg/pr83149_1.f90: Likewise.
* gfortran.dg/pr83149_b.f90: Likewise.
* gfortran.dg/whole_file_1.f90: Likewise.
* gfortran.dg/whole_file_10.f90: Likewise.
* gfortran.dg/whole_file_11.f90: Likewise.
* gfortran.dg/whole_file_12.f90: Likewise.
* gfortran.dg/whole_file_13.f90: Likewise.
* gfortran.dg/whole_file_14.f90: Likewise.
* gfortran.dg/whole_file_15.f90: Likewise.
* gfortran.dg/whole_file_16.f90: Likewise.
* gfortran.dg/whole_file_17.f90: Likewise.
* gfortran.dg/whole_file_18.f90: Likewise.
* gfortran.dg/whole_file_19.f90: Likewise.
* gfortran.dg/whole_file_2.f90: Likewise.
* gfortran.dg/whole_file_20.f03: Likewise.
* gfortran.dg/whole_file_3.f90: Likewise.
* gfortran.dg/whole_file_4.f90: Likewise.
* gfortran.dg/whole_file_5.f90: Likewise.
* gfortran.dg/whole_file_6.f90: Likewise.
* gfortran.dg/whole_file_7.f90: Likewise.
* gfortran.dg/whole_file_8.f90: Likewise.
* gfortran.dg/whole_file_9.f90: Likewise.
* gcc.dg/vect/vect.exp: Likewise.
2018-08-17  Martin Liska  <mliska@suse.cz>

* c.opt: Remove Warn, Init and Report for options with
        Ignore/Deprecated flag. Warning is done automatically for
        Deprecated flags.

From-SVN: r263614

6 years agore PR middle-end/86505 (__builtin_va_arg_pack_len() computes the number of arguments...
Richard Biener [Fri, 17 Aug 2018 08:48:58 +0000 (08:48 +0000)]
re PR middle-end/86505 (__builtin_va_arg_pack_len() computes the number of arguments wrongly)

2018-08-17  Richard Biener  <rguenther@suse.de>

PR middle-end/86505
* tree-inline.c (copy_bb): When inlining __builtin_va_arg_pack_len ()
across a va-arg-pack using call adjust its return value accordingly.

* gcc.dg/torture/pr86505.c: New testcase.

From-SVN: r263613

6 years agore PR tree-optimization/86853 (sprintf optimization for wide strings doesn't account...
Martin Sebor [Fri, 17 Aug 2018 04:01:14 +0000 (04:01 +0000)]
re PR tree-optimization/86853 (sprintf optimization for wide strings doesn't account for conversion failure)

gcc/ChangeLog:

PR tree-optimization/86853
* gimple-ssa-sprintf.c (struct format_result): Rename member.
(struct fmtresult): Add member and initialize it in ctors.
(format_character): Handle %C.  Extend range to NUL.  Set MAYFAIL.
(format_string): Handle %S the same as %ls.  Set MAYFAIL.
(format_directive): Set POSUNDER4K when MAYFAIL is set.
(parse_directive): Handle %C same as %c.
(sprintf_dom_walker::compute_format_length): Adjust.
(is_call_safe): Adjust.

gcc/testsuite/ChangeLog:

PR tree-optimization/86853
* gcc.dg/tree-ssa/builtin-sprintf-10.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-11.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-18.c: Adjust.

From-SVN: r263612

6 years agoDaily bump.
GCC Administrator [Fri, 17 Aug 2018 00:16:31 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263611

6 years agobuiltins.c (c_strlen): Add new parameter eltsize.
Bernd Edlinger [Thu, 16 Aug 2018 22:38:04 +0000 (22:38 +0000)]
builtins.c (c_strlen): Add new parameter eltsize.

* builtins.c (c_strlen): Add new parameter eltsize.  Use it
for determining how to count the elements.
* builtins.h (c_strlen): Adjust prototype.
* expr.c (string_constant): Add new parameter mem_size.
Set *mem_size appropriately.
* expr.h (string_constant): Adjust protoype.
* gimple-fold.c (get_range_strlen): Add new parameter eltsize.
* gimple-fold.h (get_range_strlen): Adjust prototype.
* gimple-ssa-sprintf.c (get_string_length): Add new parameter eltsize.
(format_string): Call get_string_length with eltsize.

From-SVN: r263607

6 years agodiagnostics: fix bad interaction between line spans and line numbers
David Malcolm [Thu, 16 Aug 2018 22:33:00 +0000 (22:33 +0000)]
diagnostics: fix bad interaction between line spans and line numbers

Without this patch, the "line span" markers and the line numbering
interacted badly, leading to stray copies of the line-span markers
appearing as prefixes on the first source line in a span:

missing-header-fixit-3.c: In function 'test':
missing-header-fixit-3.c:9:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
9 |   printf ("%i of %i\n", i, j);
  |   ^~~~~~
missing-header-fixit-3.c:9:3: warning: incompatible implicit declaration of built-in function 'printf'
missing-header-fixit-3.c:9:3: note: include '<stdio.h>' or provide a declaration of 'printf'
missing-header-fixit-3.c:1:1:
  |+#include <stdio.h>
missing-header-fixit-3.c:1:1:1 | /* Example of a fix-it hint that adds a #include directive,
missing-header-fixit-3.c:9:3:
missing-header-fixit-3.c:9:3:9 |   printf ("%i of %i\n", i, j);
  |   ^~~~~~

With this patch, we now correctly print:

missing-header-fixit-3.c: In function 'test':
missing-header-fixit-3.c:9:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
9 |   printf ("%i of %i\n", i, j);
  |   ^~~~~~
missing-header-fixit-3.c:9:3: warning: incompatible implicit declaration of built-in function 'printf'
missing-header-fixit-3.c:9:3: note: include '<stdio.h>' or provide a declaration of 'printf'
missing-header-fixit-3.c:1:1:
+ |+#include <stdio.h>
1 | /* Example of a fix-it hint that adds a #include directive,
missing-header-fixit-3.c:9:3:
9 |   printf ("%i of %i\n", i, j);
  |   ^~~~~~

gcc/ChangeLog:
* diagnostic.c (default_diagnostic_start_span_fn): Call pp_string
to emit the span, rather than setting it as the prefix.

gcc/testsuite/ChangeLog:
* gcc.dg/missing-header-fixit-3.c: New test.

From-SVN: r263606

6 years agodiagnostics: tweak to line-insertion fix-it hints with line-numbering
David Malcolm [Thu, 16 Aug 2018 22:28:19 +0000 (22:28 +0000)]
diagnostics: tweak to line-insertion fix-it hints with line-numbering

This commit slightly tweaks line-insertion fix-it hints, so that
with line-numbering, rather than e.g.:

 99 |       x = a;
    |+      break;
110 |     case 'b':
    |     ^~~~~~~~

we fill the margin with "+":

 99 |       x = a;
+++ |+      break;
110 |     case 'b':
    |     ^~~~~~~~

to emphasize that this is a suggested new line, rather than the user's
source.

gcc/ChangeLog:
* diagnostic-show-locus.c (layout::start_annotation_line): Add
"margin_char" parameter, defaulting to space.  Use it in place
of pp_space for the initial part of the margin.
(layout::print_leading_fixits): Use '+' when filling the margin
of line-insertion fix-it hints.

gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c
(test_fixit_insert_newline): Update expected output to show '+'
characters in margin of line-insertion fix-it hint.

From-SVN: r263605

6 years agors6000: Delete old add+cmp patterns
Segher Boessenkool [Thu, 16 Aug 2018 19:47:01 +0000 (21:47 +0200)]
rs6000: Delete old add+cmp patterns

There are some patterns that recognise the parallel of an add and a
compare, and split it back to the same two insns.  This apparently
helped RIOS machines before RTL scheduling existed?  Either way, it
isn't helpful anymore, and even hurts a tiny bit.  So, delete it.

* config/rs6000/rs6000.md (two unnamed define_insn and define_split):
Delete.

From-SVN: r263604

6 years agors6000: Remove "length 4" from other insns
Segher Boessenkool [Thu, 16 Aug 2018 19:44:38 +0000 (21:44 +0200)]
rs6000: Remove "length 4" from other insns

There were many insns that set "length 4" explicitly while that does
not make anything clearer to the reader.  So, simplify the code.

* config/rs6000/altivec.md: Don't set length attribute to the default
value.
* config/rs6000/darwin.md: Ditto.
* config/rs6000/dfp.md: Ditto.
* config/rs6000/htm.md: Ditto.
* config/rs6000/rs6000.md: Ditto.
* config/rs6000/sync.md: Ditto.
* config/rs6000/vsx.md: Ditto.

From-SVN: r263603

6 years agors6000: Remove "length 4" from branch insns
Segher Boessenkool [Thu, 16 Aug 2018 19:42:36 +0000 (21:42 +0200)]
rs6000: Remove "length 4" from branch insns

Now that it is the default for branch insns like for all other insns,
we don't need to set it explicitly so often anymore.

* config/rs6000/altivec.md: Don't set length attribute to the default
value, for branch instructions.
* config/rs6000/darwin.md: Ditto.
* config/rs6000/rs6000.md: Ditto.

From-SVN: r263602

6 years agors6000: Change the length attribute default
Segher Boessenkool [Thu, 16 Aug 2018 19:40:07 +0000 (21:40 +0200)]
rs6000: Change the length attribute default

This moves what is currently the default of the length attribute to
the only branch instruction patterns where it applies, namely, the
B-form instructions.  It was used for the "jump" instruction as well
before, but that is an I-form instruction and always has length 4.

* config/rs6000/rs6000.md (length): Always define as const_int 4.
(unnamed conditional branch define_insn): Set length to 4 or 8
depending on offset.
(<bd>_<mode>): Similar, for alternative 0.
(<bd>tf_<mode>): Ditto.

From-SVN: r263601

6 years ago[PATCH] Macro definition parameter parsing
Nathan Sidwell [Thu, 16 Aug 2018 19:18:42 +0000 (19:18 +0000)]
[PATCH] Macro definition parameter parsing

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00977.html
libcpp/
* internal.h (_cpp_save_parameter): Take parmno, not macro.
(_cpp_unsave_parameters): Declare.
* macro.c (_cpp_save_parameter): Take parm number, not macro.
Return true on success.
(_cpp_unsave_parameters): New.
(parse_params): Take parm_no and variadic pointers, not macro.
Reimplement parsing logic.
(create_iso_definition): Adjust parse_params changes.  Call
_cpp_unsave_parameters here.
(_cpp_create_definition): Don't unsave params here.
* traditional.c (scan_parameters): Take n_param pointer, adjust.
(_cpp_create_trad_definition): Ajust scan_parameters change.  Call
_cpp_unsave_parameters.
gcc/testsuite/
* gcc.dg/cpp/macsyntx.c: Adjust expected errors.
* gcc.dg/cpp/macsyntx2.c: likewise.

From-SVN: r263600

6 years agore PR testsuite/86745 (gcc.target/i386/avx-cvt-2.c etc. FAIL on 64-bit x86)
Uros Bizjak [Thu, 16 Aug 2018 18:52:26 +0000 (20:52 +0200)]
re PR testsuite/86745 (gcc.target/i386/avx-cvt-2.c etc. FAIL on 64-bit x86)

PR testsuite/86745
* gcc.target/i386/avx-cvt-2.c: Loosen scan-assembler strings.
* gcc.target/i386/avx-cvt-2.c: Ditto.

From-SVN: r263598

6 years agoFix warning with -Wsign-compare -Wsystem-headers
Jonathan Wakely [Thu, 16 Aug 2018 17:16:33 +0000 (18:16 +0100)]
Fix warning with -Wsign-compare -Wsystem-headers

* include/tr1/legendre_function.tcc (__sph_legendre): Avoid warning
about signed/unsigned comparison.

From-SVN: r263596

6 years ago-Wmisleading-indentation: fix ICE in get_visual_column (PR c++/70693)
David Malcolm [Thu, 16 Aug 2018 17:07:15 +0000 (17:07 +0000)]
-Wmisleading-indentation: fix ICE in get_visual_column (PR c++/70693)

PR c++/70693 reports a crash within -Wmisleading-indentation in
get_visual_column, reading past the end of a source line.

The issue occurs due to a stray carriage return aka '\r' aka ^M, occurring
towards the end of line 35 of attachment 38289 - but not at the end itself.

This carriage return confuses our line numbering: from that point in the
file, the lexer (and thus location_t values) use line numbers that are
one larger than those seen by input.c, "cat -n" and emacs.

This discrepancy between the lexer's line numbering and input.c's line
numbering leads to an out-of-range read in get_visual_column (trying to
read column 8, to locate the first non-whitespace on the line containing
"break;", but finding the next line, which is only 4 characters long).

This patch fixes the ICE by adding a range check to get_visual_column
before accessing the input.c line buffer.  This is arguably papering
over the root cause, but there are presumably other ways of triggering
such an out-of-range read by writing to the source file after the lexer
but before -Wmisleading-indentation, and we ought to be not ICE in the
face of that.

gcc/c-family/ChangeLog:
PR c++/70693
* c-common.c (selftest::c_family_tests): Call
selftest::c_indentation_c_tests.
* c-common.h (selftest::c_indentation_c_tests): New decl.
* c-indentation.c: Include "selftest.h".
(next_tab_stop): Add "tab_width" param, rather than accessing
cpp_opts.
(get_visual_column): Likewise.  Clarify comment.  Bulletproof
against reading past the end of the line.
(get_first_nws_vis_column): Add "tab_width" param.
(detect_intervening_unindent): Likewise.
(should_warn_for_misleading_indentation): Read tab width from
cpp_opts and pass around.
(selftest::test_next_tab_stop): New test.
(selftest::assert_get_visual_column_succeeds): New function.
(ASSERT_GET_VISUAL_COLUMN_SUCCEEDS): New macro.
(selftest::assert_get_visual_column_fails): New function.
(ASSERT_GET_VISUAL_COLUMN_FAILS): New macro.
(selftest::test_get_visual_column): New test.
(selftest::c_indentation_c_tests): New function.

gcc/testsuite/ChangeLog:
PR c++/70693
* c-c++-common/Wmisleading-indentation-pr70693.c: New test.

From-SVN: r263595

6 years agoAllow larger copies when not slow_unaligned_access and no padding.
Tamar Christina [Thu, 16 Aug 2018 17:05:19 +0000 (17:05 +0000)]
Allow larger copies when not slow_unaligned_access and no padding.

This allows copy_blkmode_to_reg to perform larger copies when it is safe to do so by calculating
the bitsize per iteration doing the maximum copy allowed that does not read more
than the amount of bits left to copy.

Strictly speaking, this copying is only done if:

  1. the target supports fast unaligned access
  2. no padding is being used.

This should avoid the issues of the first patch (PR85123) but still work for targets that are safe
to do so.

Original patch https://gcc.gnu.org/ml/gcc-patches/2017-11/msg01088.html
Previous respin https://gcc.gnu.org/ml/gcc-patches/2018-04/msg00239.html

gcc/
2018-08-16  Tamar Christina  <tamar.christina@arm.com>

* expr.c (copy_blkmode_to_reg): Perform larger copies when safe.

From-SVN: r263594

6 years agoAvoid deprecation warning with -Wsystem-headers
Jonathan Wakely [Thu, 16 Aug 2018 16:56:40 +0000 (17:56 +0100)]
Avoid deprecation warning with -Wsystem-headers

C++17 says to use std::uncaught_exceptions() here instead of
std::uncaught_exception() but since we only care whether the result is
non-zero (and we aren't planning to remove the deprecated version) we
can just keep using std::uncaught_exception() and suppress the warning.

* include/std/ostream (basic_ostream::sentry::~sentry): Suppress
deprecation warnings for using uncaught_exception().

From-SVN: r263593

6 years agoRemove rtl.texi references to old RTX code class names
Matthew Malcomson [Thu, 16 Aug 2018 16:41:52 +0000 (16:41 +0000)]
Remove rtl.texi references to old RTX code class names

Committed on behalf of Matthew Malcomson.

2018-08-16  Matthew Malcomson  <matthew.malcomson@arm.com>

gcc/
* doc/rtl.texi: Replace old RTX class names with new names.

From-SVN: r263592

6 years agoexpmed.h (canonicalize_comparison): New declaration.
Vlad Lazar [Thu, 16 Aug 2018 16:33:43 +0000 (16:33 +0000)]
expmed.h (canonicalize_comparison): New declaration.

* expmed.h (canonicalize_comparison): New declaration.
* expmed.c (canonicalize_comparison, equivalent_cmp_code): New function.
* expmed.c (emit_store_flag_1): Add call to canonicalize_comparison.
* optabs.c (prepare_cmp_insn): Likewise.
* rtl.h (unsigned_condition_p): New function which checks if a
comparison operator is unsigned.

* gcc.target/aarch64/imm_choice_comparison.c: New test.

From-SVN: r263591

6 years agoFix bootstrap with --enable-fully-dynamic-string
Jonathan Wakely [Thu, 16 Aug 2018 15:56:21 +0000 (16:56 +0100)]
Fix bootstrap with --enable-fully-dynamic-string

PR libstdc++/86447
* src/c++11/cow-stdexcept.cc [_GLIBCXX_FULLY_DYNAMIC_STRING]
(logic_error::logic_error(logic_error&&))
(logic_error::operator=(logic_error&&))
(runtime_error::runtime_error(runtime_error&&))
(runtime_error::operator=(runtime_error&&)): Copy strings instead of
moving, to avoid allocating empty reps for moved-from strings.

From-SVN: r263590

6 years ago[PATCH] CPP Macro predicates
Nathan Sidwell [Thu, 16 Aug 2018 13:51:38 +0000 (13:51 +0000)]
[PATCH] CPP Macro predicates

https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00897.html
libcpp/
* include/cpplib.h (cpp_user_macro_p, cpp_builtin_macro_p)
(cpp_macro_p): New inlines.
* directives.c (do_pragma_poison): Use cpp_macro_p.
(do_ifdef, do_ifndef): Likewise.  Use _cpp_maybe_notify_macro_use.
(cpp_pop_definition): Use cpp_macro_p.  Move _cpp_free_definition
earlier.  Don't zap node directly.
* expr.c (parse_defined): Use _cpp_maybe_notify_macro_use &
cpp_macro_p.
* files.c (should_stack_file): Use cpp_macro_p.
* identifiers.c (cpp_defined): Likewise.
* internal.h (_cpp_mark_macro): Use cpp_user_macro_p.
(_cpp_notify_macro_use): Declare.
(_cpp_maybe_notify_macro_use): New inline.
* lex.c (is_macro): Use cpp_macro_p.
* macro.c (_cpp_warn_if_unused_macro): Use cpp_user_macro_p.
(enter_macro_context): Likewise.
(_cpp_create_definition): Use cpp_builtin_macro_p,
cpp_user_macro_p.  Move _cpp_free_definition earlier.
(_cpp_notify_macro_use): New, broken out of multiple call sites.
* traditional.c (fun_like_macro_p): Use cpp_builtin_macro_p.
(maybe_start_funlike, _cpp_scan_out_logical_line)
(push_replacement_text): Likewise.
gcc/c-family/
* c-ada-spec.c (count_ada_macro): Use cpp_user_macro_p.
(store_ada_macro): Likewise.
* c-ppoutput.c (cb_used_define, dump_macro): Likewise.
* c-spellcheck.cc (should-suggest_as_macro_p): Likewise,
gcc/
* config/rs6000/rs6000-c.c (rs6000_macro_to_expend): Use cpp_macro_p.
* config/powerpcspc/powerpcspe-c.c (rs6000_macro_to_expend): Likewise.
gcc/cp/
* name-lookup.c (lookup_name_fuzzy): Likewise.
gcc/fortran/
* cpp.c (dump_macro): Use cpp_user_macro_p.

From-SVN: r263587

6 years agoAdd __USER_LABEL_PREFIX__ to the asm names for targets that need it.
Iain Sandoe [Thu, 16 Aug 2018 11:58:25 +0000 (11:58 +0000)]
Add __USER_LABEL_PREFIX__ to the asm names for targets that need it.

2018-08-16  Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite

        * gcc.dg/memcmp-1.c (lib_memcmp): Apply __USER_LABEL_PREFIX__.
        (lib_strncmp): Likewise.

From-SVN: r263586

6 years agoDarwin doesn't have pthread_barrier, at least up to Darwin18
Iain Sandoe [Thu, 16 Aug 2018 10:40:04 +0000 (10:40 +0000)]
Darwin doesn't have pthread_barrier, at least up to Darwin18
so don't try to do tests with it.

2018-08-16  Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite/
* c-c++-common/asan/pointer-subtract-3.c: Skip for Darwin.
* c-c++-common/asan/pointer-subtract-4.c: Likewise.
* g++.dg/torture/pr44295.C : Likewise.

From-SVN: r263585

6 years agoUpdate fall through pattern for FP16 patterns in ARM.
Tamar Christina [Thu, 16 Aug 2018 10:39:13 +0000 (10:39 +0000)]
Update fall through pattern for FP16 patterns in ARM.

The original issue comes from the fact that the code does

... foo (... bar)
{
  return bar;
}

The expansion of the return statement causes GCC to try to return the value in
a register.  GCC will try to emit the move then, from MEM to REG (due to the SSA
temporary.).  It checks for a mov optab for this which isn't available and
then tries to do the move in bits using emit_move_multi_word.

emit_move_multi_word will split the move into sub parts, but then needs to get
the sub parts and does this using subregs, but it's told it can't do subregs!

The compiler is now stuck in an infinite loop.

The way this is worked around in the back-end is that we have move patterns in
neon.md that usually just force the register instead of checking with the
back-end. This prevents emit_move_multi_word from being needed.  However the
pattern for V4HF and V8HF were guarded by TARGET_NEON && TARGET_FP16.

I don't believe the TARGET_FP16 guard to be needed, because the pattern doesn't
actually generate code and requires another pattern for that, and a reg to reg move
should always be possible anyway. So allowing the force to register here is safe
and it allows the compiler to generate a correct error instead of ICEing in an
infinite loop.

gcc/
2018-08-16  Tamar Christina  <tamar.christina@arm.com>

PR target/84711
* config/arm/arm.c (arm_can_change_mode_class): Disallow subreg.
* config/arm/neon.md (movv4hf, movv8hf): Refactored to..
(mov<mov>): ..this and enable unconditionally.

From-SVN: r263584

6 years agofix section naming convention for Darwin in three tests
Iain Sandoe [Thu, 16 Aug 2018 10:33:03 +0000 (10:33 +0000)]
fix section naming convention for Darwin in three tests

2018-08-15  Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite:

PR testsuite/78544
* gcc.dg/tree-prof/section-attr-1.c: Add Darwin-specific section attributes and matching.
* gcc.dg/tree-prof/section-attr-2.c: Likewise.
* gcc.dg/tree-prof/section-attr-3.c: Likewise.
6

From-SVN: r263583

6 years agoRemove dead pattern on ARM.
Tamar Christina [Thu, 16 Aug 2018 10:26:05 +0000 (10:26 +0000)]
Remove dead pattern on ARM.

About 13 years ago the reg-to-reg patterns were split up, before that time
output_move_double could actually handle this case.

After the split was done most patterns were updated except for *neon_mov
which incorrectly retained reg,reg as a valid alternative.

However output_move_double can not handle this and simply returns ""
and asserts.

This pattern is essentially dead and I'm removing it for clarity.

gcc/
2018-08-16  Tamar Christina  <tamar.christina@arm.com>

* config/arm/neon.md (*neon_mov<mode>): Remove reg-to-reg alternative.

From-SVN: r263582

6 years ago[aarch64] Make common aarch64 options target-dependent
Sam Tebbs [Thu, 16 Aug 2018 09:43:58 +0000 (09:43 +0000)]
[aarch64] Make common aarch64 options target-dependent

This patch replaces the "Common" attribute in some aarch64 options with "Target"
to make them target-dependent. This doesn't affect their behaviour or how they
are documented with "--help", but does mean that they follow the option
specification that target-specific options are given the "Target" attribute.

Tested by ensuring the changed options are still accepted as before and that
they aren't invokable from an invalid target. Bootstrapped and regression tested
on aarch64-none-elf with ... regressions.

2018-08-16  Sam Tebbs  <sam.tebbs@arm.com>

* config/aarch64/aarch64.opt (mlow-precision-recip-sqrt)
(mlow-precision-sqrt, mlow-precision-div, mverbose-cost-dump): Replace
"Common" with "Target".

From-SVN: r263578

6 years agoFix pr81923 test for targets using __USER_LABEL_PREFIX__
Iain Sandoe [Thu, 16 Aug 2018 08:33:16 +0000 (08:33 +0000)]
Fix pr81923 test for targets using __USER_LABEL_PREFIX__

2018-08-16  Iain Sandoe <iain@sandoe.co.uk>

gcc/testsuite

* gcc.dg/asan/pr81923.c: Stringify __USER_LABEL_PREFIX__.

From-SVN: r263577

6 years agoDaily bump.
GCC Administrator [Thu, 16 Aug 2018 00:16:36 +0000 (00:16 +0000)]
Daily bump.

From-SVN: r263576

6 years agoi386.opt (mmitigate-rop): Mark as deprecated.
Uros Bizjak [Wed, 15 Aug 2018 21:07:08 +0000 (23:07 +0200)]
i386.opt (mmitigate-rop): Mark as deprecated.

* config/i386/i386.opt (mmitigate-rop): Mark as deprecated.
* doc/invoke.texi (mmitigate-rop): Remove.
* config/i386/i386.c: Do not include "regrename.h".
(ix86_rop_should_change_byte_p, reg_encoded_number)
(ix86_get_modrm_for_rop, set_rop_modrm_reg_bits, ix86_mitigate_rop):
Remove.
(ix86_reorg): Remove call to ix86_mitigate_rop.
* config/i386/i386.md (attr "modrm_class"): Remove.
(cmp<mode>_ccno_1, mov<mode>_xor, movstrict<mode>_xor)
(x86_mov<mode>cc_0_m1. x86_mov<mode>cc_0_m1_se)
(x86_mov<mode>cc_0_m1_neg): Remove modrm_class attribute override.

testsuite/Changelog:

* gcc.target/i386/rop1.c: Remove.
* gcc.target/i386/pr83554 (dg-options): Remove -mmitigate-rop.

From-SVN: r263572

6 years agoChangeLog: Fix whitespace.
Uros Bizjak [Wed, 15 Aug 2018 21:06:06 +0000 (23:06 +0200)]
ChangeLog: Fix whitespace.

* ChangeLog: Fix whitespace.
* testsuite/ChangeLog: Ditto.

From-SVN: r263571

6 years agofold-vec-splat-char.c: New.
Will Schmidt [Wed, 15 Aug 2018 20:29:04 +0000 (20:29 +0000)]
fold-vec-splat-char.c: New.

[testsuite]

2018-08-13  Will Schmidt  <will_schmidt@vnet.ibm.com>

* gcc.target/powerpc/fold-vec-splat-char.c: New.
* gcc.target/powerpc/fold-vec-splat-floatdouble.c: New.
* gcc.target/powerpc/fold-vec-splat-int.c: New.
* gcc.target/powerpc/fold-vec-splat-longlong.c: New.
* gcc.target/powerpc/fold-vec-splat-pixel.c: New.
* gcc.target/powerpc/fold-vec-splat-short.c: New.

From-SVN: r263570

6 years agors600.c (rs6000_gimple_fold_builtin): Add entries to allow folding of mergeh() and...
Will Schmidt [Wed, 15 Aug 2018 20:24:57 +0000 (20:24 +0000)]
rs600.c (rs6000_gimple_fold_builtin): Add entries to allow folding of mergeh() and mergel() for the float and double...

[gcc]

2018-08-07 Will Schmidt  <will_schmidt@vnet.ibm.com>

* config/rs6000/rs600.c (rs6000_gimple_fold_builtin): Add entries to
allow folding of mergeh() and mergel() for the float and double types.
(fold_mergehl_helper): Rework to handle building a permute tree
for float vectors.

From-SVN: r263569

6 years agoFix experimental::pmr typedefs and add tests
Jonathan Wakely [Wed, 15 Aug 2018 19:46:25 +0000 (20:46 +0100)]
Fix experimental::pmr typedefs and add tests

The typedefs in <experimental/regex> and <experimental/string> don't
need to be in the __cxx11 namespace, because they are only aliases and
so will have the same mangled name as the underlying types.

* include/experimental/regex: Remove begin/end macros for namespace.
* include/experimental/string: Likewise.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_deque.cc:
New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_forward_list.cc: New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_list.cc:
New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_map.cc:
New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_match.cc:
New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_multimap.cc: New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_multiset.cc: New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_set.cc:
New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_string.cc:
New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_unordered_map.cc: New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_unordered_multimap.cc: New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_unordered_multiset.cc: New test.
* testsuite/experimental/polymorphic_allocator/
pmr_typedefs_unordered_set.cc: New test.
* testsuite/experimental/polymorphic_allocator/pmr_typedefs_vector.cc:
New test.

From-SVN: r263568

6 years agoi386.c (expand_vec_perm_movs): Enable V4SFmode for TARGET_SSE.
Uros Bizjak [Wed, 15 Aug 2018 19:34:26 +0000 (21:34 +0200)]
i386.c (expand_vec_perm_movs): Enable V4SFmode for TARGET_SSE.

* config/i386/i386.c (expand_vec_perm_movs): Enable V4SFmode
for TARGET_SSE.

From-SVN: r263567

6 years agoRefactor uses-allocator construction
Jonathan Wakely [Wed, 15 Aug 2018 19:20:02 +0000 (20:20 +0100)]
Refactor uses-allocator construction

Remove duplicated logic in experimental::pmr::polymorphic_allocator by
calling the __uses_allocator_construct helper.

Fix bugs in std::pmr::polymorphic_allocator with incorrect SFINAE
constraint and incorrect argument order.

* include/bits/uses_allocator.h (__uses_allocator_construct): Qualify
calls to __uses_allocator_construct_impl and __use_alloc.
* include/experimental/memory_resource
(polymorphic_allocator::_M_construct): Remove.
(polymorphic_allocator::construct): Call __uses_allocator_construct.
Qualify calls to __use_alloc.
* include/std/memory_resource (polymorphic_allocator::construct): Fix
type in SFINAE constraint. Use constexpr if instead of tag dispatching
to _S_construct overloads.
(polymorphic_allocator::construct(pair<T1, T2>*, ...)): Fix order of
arguments to _S_construct_p.
(polymorphic_allocator::_S_construct): Remove.
(polymorphic_allocator::_S_construct_p): Return allocators by value
not by reference.
* include/std/scoped_allocator (scoped_allocator_adaptor::construct):
Qualify calls to __use_alloc.
* testsuite/20_util/polymorphic_allocator/construct_pair.cc: New test,
copied from testsuite/20_util/scoped_allocator/construct_pair.cc.
* testsuite/experimental/polymorphic_allocator/1.cc: New test.
* testsuite/experimental/polymorphic_allocator/construct_pair.cc:
New test.

From-SVN: r263566

6 years agodiagnostics: add labeling of source ranges
David Malcolm [Wed, 15 Aug 2018 18:09:35 +0000 (18:09 +0000)]
diagnostics: add labeling of source ranges

This patch adds the ability to label source ranges within a rich_location,
to be printed by diagnostic_show_locus.

For example:

pr69554-1.c:11:18: error: invalid operands to binary + (have 'const char *' and 'const char *')
11 |   return (p + 1) + (q + 1);
   |          ~~~~~~~ ^ ~~~~~~~
   |             |         |
   |             |         const char *
   |             const char *

The patch implements labels for various type mismatch errors in the C and
C++ frontends, and in -Wformat.  I implemented it wherever accurate location
information was guaranteed (there are other places that could benefit, but
we need better location information in those places).

The labels can be disabled via -fno-diagnostics-show-labels.

Similarly:

param-type-mismatch.C: In function 'int test_1(int, int, float)':
param-type-mismatch.C:11:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
11 |   return callee_1 (first, second, third);
   |                           ^~~~~~
   |                           |
   |                           int
param-type-mismatch.C:7:43: note:   initializing argument 2 of 'int callee_1(int, const char*, float)'
7 | extern int callee_1 (int one, const char *two, float three);
  |                               ~~~~~~~~~~~~^~~

where the first "error" describing the bad argument gets a label
describing the type inline (since it's non-obvious from "second").
The "note" describing the type of the param of the callee *doesn't*
get a label, since that information is explicit there in the
source ("const char *two").

The idea is that in any diagnostic where two aspects of the source aren't
in sync it ought to be easier for the user if we directly show them the
mismatching aspects inline (e.g. types).

As well as type mismatch errors, perhaps labels could also be used for
buffer overflow warnings, for describing the capacity of the destination
buffer vs the size of what's being written:

  sprintf (buf, "filename: %s\n", file);
           ^~~   ~~~~~~~~~~~^~~
           |                |
           capacity: 32     10 + strlen(file) + 2

or somesuch.  Another idea might be for macro expansion warnings:

warning: repeated side effects in macro expansion...
   x = MIN (p++, q++);
       ~~~~^~~~~~~~~~
note: ...expanded here as
 #define MIN(X,Y) (X<Y?X:Y)
         ^~~ ~ ~   ~ ~ ~ ~
             | |   | | | |
             | |   | | | q++
             | |   | | p++
             | |   | q++
             | q++ p++
             p++

The patch removes some logic from multiline.exp which special-cased
lines ending with a '|' character (thus complicating testing of this
patch).  I believe that this was a vestige from experiments I did to
support strippng dg directives from the output; it was present in the
earliest version of multiline.exp I posted:
  "[RFC, stage1] Richer source location information for gcc 6 (location ranges etc)"
    https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00837.html
and I believe was neved used.

gcc/c-family/ChangeLog:
* c-format.c: Include "selftest-diagnostic.h" and
"gcc-rich-location.h".
(format_warning_at_char): Pass NULL for new label params of
format_warning_va.
(class indirection_suffix): New class.
(class range_label_for_format_type_mismatch): New class.
(format_type_warning): Move logic for generating "*" suffix to
class indirection_suffix.  Create "fmt_label" and "param_label"
to show their types, and pass them to the
format_warning_at_substring calls.
(selftest::test_type_mismatch_range_labels): New test.
(selftest::c_format_c_tests): Call it.

gcc/c/ChangeLog:
* c-objc-common.c: Include "gcc-rich-location.h".
(c_tree_printer): Move implemenation of '%T' to...
(print_type): ...this new function.
(range_label_for_type_mismatch::get_text): New function.
* c-typeck.c (convert_for_assignment): Add type labels to the rhs
range for the various ic_argpass cases.
(class maybe_range_label_for_tree_type_mismatch): New class.
(build_binary_op): Use it when calling binary_op_error.

gcc/cp/ChangeLog:
* call.c: Include "gcc-rich-location.h".
(convert_like_real): Add range label for "invalid conversion"
diagnostic.
(perform_implicit_conversion_flags): Add type label to the
"could not convert" error.
* error.c: Include "gcc-rich-location.h".
(range_label_for_type_mismatch::get_text): New function.
* typeck.c (convert_for_assignment): Add type label to
the "cannot convert" error if a location is available.

gcc/ChangeLog:
* common.opt (fdiagnostics-show-labels): New option.
* diagnostic-show-locus.c (class layout_range): Add field
"m_label".
(class layout): Add field "m_show_labels_p".
(layout_range::layout_range): Add param "label" and use it to
initialize m_label.
(make_range): Pass in NULL for new "label" param of layout_range's
ctor.
(layout::layout): Initialize m_show_labels_p.
(layout::maybe_add_location_range): Pass in loc_range->m_label
when constructing layout_range instances.
(struct line_label): New struct.
(layout::print_any_labels): New member function.
(layout::print_line): Call it if label-printing is enabled.
(selftest::test_one_liner_labels): New test.
(selftest::test_diagnostic_show_locus_one_liner): Call it.
* diagnostic.c (diagnostic_initialize): Initialize
context->show_labels_p.
* diagnostic.h (struct diagnostic_context): Add field
"show_labels_p".
* doc/invoke.texi (Diagnostic Message Formatting Options): Add
-fno-diagnostics-show-labels.
* dwarf2out.c (gen_producer_string): Add
OPT_fdiagnostics_show_labels to the ignored options.
* gcc-rich-location.c (gcc_rich_location::add_expr): Add "label"
param.
(gcc_rich_location::maybe_add_expr): Likewise.
* gcc-rich-location.h (gcc_rich_location::gcc_rich_location): Add
label" param, defaulting to NULL.
(gcc_rich_location::add_expr): Add "label" param.
(gcc_rich_location::maybe_add_expr): Likewise.
(class text_range_label): New class.
(class range_label_for_type_mismatch): New class.
* gimple-ssa-sprintf.c (fmtwarn): Pass NULL for new label params
of format_warning_va.
(fmtwarn_n): Likewise for new params of format_warning_n_va.
* lto-wrapper.c (merge_and_complain): Add
OPT_fdiagnostics_show_labels to the "pick one setting" options.
(append_compiler_options): Likewise to the dropped options.
(append_diag_options): Likewise to the passed-on options.
* opts.c (common_handle_option): Handle the new option.
* selftest-diagnostic.c
(test_diagnostic_context::test_diagnostic_context): Enable
show_labels_p.
* substring-locations.c: Include "gcc-rich-location.h".
(format_warning_n_va): Add "fmt_label" and "param_label" params
and use them as appropriate.
(format_warning_va): Add "fmt_label" and "param_label" params,
passing them on to format_warning_n_va.
(format_warning_at_substring): Likewise.
(format_warning_at_substring_n): Likewise.
* substring-locations.h (format_warning_va): Add "fmt_label" and
"param_label" params.
(format_warning_n_va): Likewise.
(format_warning_at_substring): Likewise.
(format_warning_at_substring_n): Likewise.
* toplev.c (general_init): Initialize global_dc->show_labels_p.

gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/aka3.C: New test.
* g++.dg/diagnostic/param-type-mismatch-2.C: Update expected
output to show range labels.
* g++.dg/diagnostic/param-type-mismatch.C: Likewise.
* g++.dg/plugin/plugin.exp (plugin_test_list): Add...
* g++.dg/plugin/show-template-tree-color-labels.C: New test.
* gcc.dg/bad-binary-ops.c: Update expected output to show range
labels.  Add an "aka" example.
* gcc.dg/cpp/pr66415-1.c: Update expected output to show range
labels.
* gcc.dg/format/diagnostic-ranges.c: Likewise.
* gcc.dg/format/pr72858.c: Likewise.
* gcc.dg/format/pr78498.c: Likewise.
* gcc.dg/param-type-mismatch.c: Add "-Wpointer-sign" to options.
Update expected output to show range labels.  Add examples of
-Wincompatible-pointer-types and -Wpointer-sign for parameters.
* gcc.dg/plugin/diagnostic-test-show-locus-bw-line-numbers.c:
Update expected output to show range labels.
* gcc.dg/plugin/diagnostic-test-show-locus-bw.c: Likewise.
(test_very_wide_line): Adjust so that label is at left-clipping
boundary.
(test_very_wide_line_2): New test.
* gcc.dg/plugin/diagnostic-test-show-locus-color-line-numbers.c:
Update expected output to show range labels.
* gcc.dg/plugin/diagnostic-test-show-locus-color.c: Likewise.
* gcc.dg/plugin/diagnostic-test-show-locus-no-labels.c: New test.
* gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Update
for new param to gcc_rich_location::add_expr.
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (add_range):
Add "label" param.
(test_show_locus): Add examples of labels to various tests.  Tweak
the "very wide_line" test case and duplicate it, to cover the
boundary values for clipping of labels against the left-margin.
* gcc.dg/plugin/plugin.exp (plugin_test_list): Add
diagnostic-test-show-locus-no-labels.c.
* gcc.dg/pr69554-1.c: Update expected output to show range labels.
Update line numbers of dg-locus directives.
* gcc.dg/pr69627.c:  Update expected output to show range labels.
* lib/multiline.exp (proc _build_multiline_regex): Remove
special-case handling of lines with trailing '|'.

libcpp/ChangeLog:
* include/line-map.h (struct location_range): Add "m_label" field.
(class rich_location): Add description of labels to leading
comment.
(rich_location::rich_location): Add "label" param, defaulting to
NULL.
(rich_location::add_range): Likewise.
(struct label_text): New struct.
(class range_label): New abstract base class.
* line-map.c (rich_location::rich_location): Add "label" param;
use it.
(rich_location::add_range): Likewise.

From-SVN: r263564

6 years agoDo not expand the call to memcmp at all when overflow is detected.
Qing Zhao [Wed, 15 Aug 2018 16:33:52 +0000 (16:33 +0000)]
Do not expand the call to memcmp at all when overflow is detected.

From-SVN: r263563

6 years agoc-decl.c (start_decl): Do not warn if variables is named as main and is a local variable.
Prathamesh Kulkarni [Wed, 15 Aug 2018 15:52:22 +0000 (15:52 +0000)]
c-decl.c (start_decl): Do not warn if variables is named as main and is a local variable.

2018-08-15  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

c/
* c-decl.c (start_decl): Do not warn if variables is named as main
and is a local variable.

testsuite/
* gcc.dg/wmain.c: New test.

From-SVN: r263562

6 years agoPR tree-optimization/71625 - missing strlen optimization on different array
Martin Sebor [Wed, 15 Aug 2018 15:25:46 +0000 (15:25 +0000)]
PR tree-optimization/71625 - missing strlen optimization on different array

PR tree-optimization/71625 - missing strlen optimization on different array
initialization style (avoid compilation errors on aarch64)

gcc/ChangeLog:
* config/aarch64/aarch64-builtins.c
(aarch64_init_simd_builtin_types): Clear Poly8_t's TYPE_STRING_FLAG.

From-SVN: r263561