diff options
author | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-20 21:49:12 +0000 |
---|---|---|
committer | burnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-20 21:49:12 +0000 |
commit | c9c81ef3c667aaa14c498a5449ec6d134b4b66ff (patch) | |
tree | 0ac440db6513ee01deb5e5dc6142769d1e5b7b2d | |
parent | 12cdcb9d74f55c165366ca1b1eeec013a0ce72ef (diff) | |
parent | 891196d7325e4c55d92d5ac5cfe7161c4f36c0ce (diff) | |
download | gcc-fortran-dev.tar.gz |
Merge from trunk (r239915 to r240230)fortran-dev
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@240290 138bc75d-0d04-0410-961f-82ee72b054a4
818 files changed, 16379 insertions, 3581 deletions
diff --git a/.gitignore b/.gitignore index c9a6158bc4e..b53f60db792 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,9 @@ lost+found # ignore ./contrib/gcc_update output LAST_UPDATED REVISION + +# ignore in-tree prerequisites +/mpfr* +/mpc* +/gmp* +/isl* diff --git a/ChangeLog b/ChangeLog index f08794d1234..d0e4b06ea88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-09-12 Maciej W. Rozycki <macro@imgtec.com> + + * configure.ac: Check for the minimum in-tree MPFR version + handled. + * configure: Regenerate. + 2016-07-20 Yan-Ting Lin <currygt52@gmail.com> * configure.ac (nds32*-*-*): Remove entry to enable gdb. diff --git a/configure b/configure index cd0e7b932c4..c4a2cd1db45 100755 --- a/configure +++ b/configure @@ -5566,6 +5566,10 @@ if test "x$with_mpfr_lib" != x; then gmplibs="-L$with_mpfr_lib $gmplibs" fi if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then + # MPFR v3.1.0 moved the sources into a src sub-directory. + if ! test -d ${srcdir}/mpfr/src; then + as_fn_error "Building GCC with MPFR in the source tree is only handled for MPFR 3.1.0+." "$LINENO" 5 + fi gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs" gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc" extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir" diff --git a/configure.ac b/configure.ac index 51b53b5c56a..a1b9da4fa9e 100644 --- a/configure.ac +++ b/configure.ac @@ -1546,6 +1546,11 @@ if test "x$with_mpfr_lib" != x; then gmplibs="-L$with_mpfr_lib $gmplibs" fi if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then + # MPFR v3.1.0 moved the sources into a src sub-directory. + if ! test -d ${srcdir}/mpfr/src; then + AC_MSG_ERROR([dnl +Building GCC with MPFR in the source tree is only handled for MPFR 3.1.0+.]) + fi gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs" gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc" extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir" diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog index 01488f76756..6b4aa421050 100644 --- a/fixincludes/ChangeLog +++ b/fixincludes/ChangeLog @@ -1,3 +1,8 @@ +2016-09-04 John David Anglin <danglin@gcc.gnu.org> + + * inclhack.def (hpux_longjmp): Adjust select regular expression. + * fixincl.x: Regenerate. + 2016-08-13 John David Anglin <danglin@gcc.gnu.org> * inclhack.def (hpux_longjmp): New fix. diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index 5304141032f..cc5209e6205 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed Saturday August 13, 2016 at 02:05:44 PM EDT + * It has been AutoGen-ed Sunday September 4, 2016 at 12:15:33 PM EDT * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Sat 13 Aug 2016 14:05:44 EDT +/* DO NOT SVN-MERGE THIS FILE, EITHER Sun 4 Sep 2016 12:15:33 EDT * * You must regenerate it. Use the ./genfixes script. * @@ -5106,7 +5106,7 @@ tSCC* apzHpux_LongjmpMachs[] = { * content selection pattern - do fix if pattern found */ tSCC zHpux_LongjmpSelect0[] = - "^[ \t]*extern[ \t]+void.*longjmp[ \t]+__\\(\\(.*int\\)\\)"; + "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\))"; #define HPUX_LONGJMP_TEST_CT 1 static tTestDesc aHpux_LongjmpTests[] = { diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 690c5671c2e..1183b590f44 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -2648,7 +2648,7 @@ fix = { hackname = hpux_longjmp; mach = "*-hp-hpux*"; files = setjmp.h; - select = "^[ \t]*extern[ \t]+void.*longjmp[ \t]+__\\(\\(.*int\\)\\)"; + select = "^[ \t]*extern[ \t]+void[ \t]+.*longjmp[ \t]*\(__\\(\\(.*int\\)\\)|\\(.*int\\)|\\(\\)\)"; c_fix = format; c_fix_arg = "%0 __attribute__ ((__noreturn__))"; diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1cf6ef600dd..2f3f91b4a03 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,864 @@ +2016-09-19 Richard Biener <rguenther@suse.de> + + * dwarf2out.c (early_dwarf_finished): New global. + (set_early_dwarf::set_early_dwarf): Assert early_dwarf_finished + is false. + (dwarf2out_early_finish): Set early_dwarf_finished at the end, + if called from LTO exit early. + (dwarf2out_late_global_decl): When being during the early + debug phase do not add locations but only const value attributes. + Adjust the way we generate early DIEs for LTO. + +2016-09-19 Richard Biener <rguenther@suse.de> + + PR middle-end/77605 + * tree-data-ref.c (analyze_subscript_affine_affine): Use the + proper niter to bound the loops. + +2016-09-19 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77514 + * tree-ssa-pre.c (create_expression_by_pieces): Optimize + search for folded stmt. + +2016-09-17 Jan Hubicka <hubicka@ucw.cz> + + * passes.def (pass_early_thread_jumps): Schedule after forwprop. + * tree-pass.h (make_pass_early_thread_jumps): Declare. + * tree-ssa-threadbackward.c (fsm_find_thread_path, + fsm_find_thread_path, profitable_jump_thread_path, + fsm_find_control_statement_thread_paths, + find_jump_threads_backwards): Add speed_p parameter. + (pass_data_early_thread_jumps): New pass. + (make_pass_early_thread_jumps): New function. + +2016-09-17 Andreas Schwab <schwab@suse.de> + + * config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Add cast. + * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Likewise. + +2016-09-16 Eric Botcazou <ebotcazou@adacore.com> + + * recog.c (rest_of_handle_split_after_reload): Delete. + (pass_split_after_reload::gate): New method. + (pass_split_after_reload::execute): Call split_all_insns directly. + +2016-09-16 Jonathan Wakely <jwakely@redhat.com> + + * doc/extend.texi (Integer Overflow Builtins): Fix type of out + parameters for functions taking long long arguments. + +2016-09-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR target/77613 + * config/rs6000/rs6000.c (rtx_is_swappable_p): Add support for + splat with truncate. + +2016-09-16 Jason Merrill <jason@redhat.com> + + * hwint.h (least_bit_hwi, pow2_or_zerop, pow2p_hwi, ctz_or_zero): + New. + * hwint.c (exact_log2): Use pow2p_hwi. + (ctz_hwi, ffs_hwi): Use least_bit_hwi. + * alias.c (memrefs_conflict_p): Use pow2_or_zerop. + * builtins.c (get_object_alignment_2, get_object_alignment) + (get_pointer_alignment, fold_builtin_atomic_always_lock_free): Use + least_bit_hwi. + * calls.c (compute_argument_addresses, store_one_arg): Use + least_bit_hwi. + * cfgexpand.c (expand_one_stack_var_at): Use least_bit_hwi. + * combine.c (force_to_mode): Use least_bit_hwi. + (contains_muldiv, find_split_point, combine_simplify_rtx) + (simplify_if_then_else, simplify_set, force_to_mode) + (if_then_else_cond, simplify_and_const_int_1) + (simplify_compare_const): Use pow2p_hwi. + * cse.c (fold_rtx): Use pow2p_hwi. + * emit-rtl.c (set_mem_attributes_minus_bitpos, adjust_address_1): + Use least_bit_hwi. + * expmed.c (synth_mult, expand_divmod): Use ctz_or_zero, ctz_hwi. + (init_expmed_one_conv): Use pow2p_hwi. + * expr.c (is_aligning_offset): Use pow2p_hwi. + * fold-const.c (round_up_loc, round_down_loc): Use pow2_or_zerop. + (fold_binary_loc): Use pow2p_hwi. + * function.c (assign_parm_find_stack_rtl): Use least_bit_hwi. + * gimple-fold.c (gimple_fold_builtin_memory_op): Use pow2p_hwi. + * gimple-ssa-strength-reduction.c (replace_ref): Use least_bit_hwi. + * hsa-gen.c (gen_hsa_addr_with_align, hsa_bitmemref_alignment): + Use least_bit_hwi. + * ifcvt.c (noce_try_store_flag_constants): Use pow2p_hwi. + * ipa-cp.c (ipcp_alignment_lattice::meet_with_1): Use least_bit_hwi. + * ipa-prop.c (ipa_modify_call_arguments): Use least_bit_hwi. + * omp-low.c (oacc_loop_fixed_partitions) + (oacc_loop_auto_partitions): Use least_bit_hwi. + * rtlanal.c (nonzero_bits1): Use ctz_or_zero. + * stor-layout.c (place_field): Use least_bit_hwi. + * tree-pretty-print.c (dump_generic_node): Use pow2p_hwi. + * tree-sra.c (build_ref_for_offset): Use least_bit_hwi. + * tree-ssa-ccp.c (ccp_finalize): Use least_bit_hwi. + * tree-ssa-math-opts.c (bswap_replace): Use least_bit_hwi. + * tree-ssa-strlen.c (handle_builtin_memcmp): Use pow2p_hwi. + * tree-vect-data-refs.c (vect_analyze_group_access_1) + (vect_grouped_store_supported, vect_grouped_load_supported) + (vect_permute_load_chain, vect_shift_permute_load_chain) + (vect_transform_grouped_load): Use pow2p_hwi. + * tree-vect-generic.c (expand_vector_divmod): Use ctz_or_zero. + * tree-vect-patterns.c (vect_recog_divmod_pattern): Use ctz_or_zero. + * tree-vect-stmts.c (vectorizable_mask_load_store): Use + least_bit_hwi. + * tsan.c (instrument_expr): Use least_bit_hwi. + * var-tracking.c (negative_power_of_two_p): Use pow2_or_zerop. + +2016-09-16 Andreas Schwab <schwab@suse.de> + + * config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Use parameter + OFFSET, not offset. + * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Likewise. + +2016-09-16 Jakub Jelinek <jakub@redhat.com> + + PR target/77526 + * combine.c (rest_of_handle_combine): If any edges have been purged, + free dominators if available. + +2016-09-16 Jakub Jelinek <jakub@redhat.com> + Eric Botcazou <ebotcazou@adacore.com> + + PR middle-end/77594 + * internal-fn.c (expand_arith_overflow) <case MINUS_EXPR>: Don't fall + through into expand_addsub_overflow after expand_neg_overflow. + +2016-09-15 David Malcolm <dmalcolm@redhat.com> + + * diagnostic-show-locus.c + (selftest::test_fixit_insert_containing_newline): New function. + (selftest::test_fixit_replace_containing_newline): New function. + (selftest::diagnostic_show_locus_c_tests): Call the above. + +2016-09-15 Bin Cheng <bin.cheng@arm.com> + + PR tree-optimization/77503 + * tree-vect-loop.c (vectorizable_reduction): Record reduction + code for CONST_COND_REDUCTION at analysis stage and use it at + transform stage. + * tree-vectorizer.h (struct _stmt_vec_info): New field. + (STMT_VINFO_VEC_CONST_COND_REDUC_CODE): New macro. + * tree-vect-stmts.c (new_stmt_vec_info): Initialize above new + field. + +2016-09-15 Richard Biener <rguenther@suse.de> + + PR middle-end/77544 + * fold-const.c (split_tree): Do not split constant ~X. + +2016-09-15 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/77425 + * sched-int.h (sd_iterator_cond): Don't update it_ptr->linkp if list + is NULL. + + PR middle-end/77475 + * config/i386/i386.c (ix86_parse_stringop_strategy_string): Simplify, + use %qs instead of %s where desirable, use argument instead of arg in + the diagnostic wording, add list of supported strategies and + spellcheck hint. + (ix86_option_override_internal): Emit target("m...") instead of + option("m...") in the diagnostic. Use %qs instead of %s in invalid + -march/-mtune option diagnostic. Add list of supported arches/tunings + and spellcheck hint. Remove prefix, suffix and sw variables, use + main_args_p ? "..." : "..." in diagnostics to make translation + possible. + +2016-09-15 Richard Biener <rguenther@suse.de> + + * dwarf2asm.h (dw2_asm_output_offset): Add overload with + extra offset argument. + * dwarf2asm.c (dw2_asm_output_offset): Implement that. + * doc/tm.texi.in (ASM_OUTPUT_DWARF_OFFSET): Adjust documentation + to reflect new offset parameter. + * doc/tm.texi: Regenerate. + * config/darwin.h (ASM_OUTPUT_DWARF_OFFSET): Adjust. + * config/darwin-protos.h (darwin_asm_output_dwarf_delta): Add + offset argument. + (darwin_asm_output_dwarf_offset): Likewise. + * config/darwin.c (darwin_asm_output_dwarf_delta): Add offset + argument. + (darwin_asm_output_dwarf_offset): Pass offset argument through. + * config/ia64/ia64.h (ASM_OUTPUT_DWARF_OFFSET): Adjust. + * config/i386/cygmin.h (ASM_OUTPUT_DWARF_OFFSET): Likewise. + +2016-09-15 Chung-Lin Tang <cltang@codesourcery.com> + + PR fortran/72743 + * ipa-icf.c (set_alias_uids): New function. + (sem_variable::merge): Use set_alias_uids to set DECL_PT_UID of + all the merged variable's referring aliases. + +2016-09-15 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77514 + * tree-ssa-pre.c (create_expression_by_pieces): Handle garbage + only forced_stmts sequence. + +2016-09-15 Kugan Vivekanandarajah <kuganv@linaro.org> + + * tree-ssanames.h (FOR_EACH_SSA_NAME): New. + * cfgexpand.c (update_alias_info_with_stack_vars): Use + FOR_EACH_SSA_NAME to iterate over SSA variables. + (pass_expand::execute): Likewise. + * omp-simd-clone.c (ipa_simd_modify_function_body): Likewise. + * tree-cfg.c (dump_function_to_file): Likewise. + * tree-into-ssa.c (pass_build_ssa::execute): Likewise. + (update_ssa): Likewise. + * tree-ssa-alias.c (dump_alias_info): Likewise. + * tree-ssa-ccp.c (ccp_finalize): Likewise. + * tree-ssa-coalesce.c (build_ssa_conflict_graph): Likewise. + (create_outofssa_var_map): Likewise. + (coalesce_ssa_name): Likewise. + * tree-ssa-operands.c (dump_immediate_uses): Likewise. + * tree-ssa-pre.c (compute_avail): Likewise. + * tree-ssa-sccvn.c (init_scc_vn): Likewise. + (scc_vn_restore_ssa_info): Likewise. + (free_scc_vn): Likwise. + (run_scc_vn): Likewise. + * tree-ssa-structalias.c (compute_points_to_sets): Likewise. + * tree-ssa-ter.c (new_temp_expr_table): Likewise. + * tree-ssa-copy.c (fini_copy_prop): Likewise. + * tree-ssa.c (verify_ssa): Likewise. + +2016-09-14 Matthew Fortune <matthew.fortune@imgtec.com> + + * config.gcc (mips*-mti-elf*, mips*-mti-linux*): Set mips32r2 + and mips64r2 as default 32-bit and 64-bit architectures. + (mips*-img-elf*, mips*-img-linux*): Set mips32r6 and mips64r6 + as default 32-bit and 64-bit architectures. + +2016-09-14 Pat Haugen <pthaugen@us.ibm.com> + + * loop-unroll.c (unroll_loop_runtime_iterations): Set probability of succ edge. + +2016-09-14 Segher Boessenkool <segher@kernel.crashing.org> + + * target.def (lra_p): Change commentary (for the manual) for the + new default. + * doc/tm.texi: Regenerate. + +2016-09-14 Segher Boessenkool <segher@kernel.crashing.org> + + * config/aarch64/aarch64.c (TARGET_LRA_P): Delete macro. + * config/arm/arm.c (TARGET_LRA_P): Delete macro. + * config/i386/i386.c (TARGET_LRA_P): Delete macro. + * config/nds32/nds32.c (TARGET_LRA_P): Delete macro. + +2016-09-14 Segher Boessenkool <segher@kernel.crashing.org> + + * targhooks.c (default_lra_p): Return true instead of false. + +2016-09-14 Segher Boessenkool <segher@kernel.crashing.org> + + * config/alpha/alpha.c (TARGET_LRA_P): New macro, defined to + hook_bool_void_false. + * config/avr/avr.c: Ditto. + * config/bfin/bfin.c: Ditto. + * config/c6x/c6x.c: Ditto. + * config/cr16/cr16.c: Ditto. + * config/cris/cris.c: Ditto. + * config/epiphany/epiphany.c: Ditto. + * config/fr30/fr30.c: Ditto. + * config/frv/frv.c: Ditto. + * config/h8300/h8300.c: Ditto. + * config/ia64/ia64.c: Ditto. + * config/iq2000/iq2000.c: Ditto. + * config/lm32/lm32.c: Ditto. + * config/m32c/m32c.c: Ditto. + * config/m32r/m32r.c: Ditto. + * config/m68k/m68k.c: Ditto. + * config/mcore/mcore.c: Ditto. + * config/microblaze/microblaze.c: Ditto. + * config/mmix/mmix.c: Ditto. + * config/mn10300/mn10300.c: Ditto. + * config/moxie/moxie.c: Ditto. + * config/msp430/msp430.c: Ditto. + * config/nios2/nios2.c: Ditto. + * config/nvptx/nvptx.c: Ditto. + * config/pa/pa.c: Ditto. + * config/pdp11/pdp11.c: Ditto. + * config/rl78/rl78.c: Ditto. + * config/sparc/sparc.c: Ditto. + * config/spu/spu.c: Ditto. + * config/stormy16/stormy16.c: Ditto. + * config/tilegx/tilegx.c: Ditto. + * config/tilepro/tilepro.c: Ditto. + * config/v850/v850.c: Ditto. + * config/vax/vax.c: Ditto. + * config/visium/visium.c: Ditto. + * config/xtensa/xtensa.c: Ditto. + +2016-09-14 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/68260 + * tsan.c: Include target.h. + (enum tsan_atomic_action): Add bool_clear and bool_test_and_set. + (BOOL_CLEAR, BOOL_TEST_AND_SET): Define. + (tsan_atomic_table): Add BUILT_IN_ATOMIC_CLEAR and + BUILT_IN_ATOMIC_TEST_AND_SET entries. + (instrument_builtin_call): Handle bool_clear and bool_test_and_set. + +2016-09-14 Bernd Edlinger <bernd.edlinger@hotmail.de> + Martin Liska <mliska@suse.cz> + + PR middle-end/77574 + * predict.c (force_edge_cold): Add braces to a condition. + +2016-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR rtl-optimization/77289 + * lra-constraints.c (get_final_hard_regno): Removed. + (get_hard_regno): Add new parameter final_p. + (get_reg_class): Directly call lra_get_elimination_hard_regno. + (operands_match_p): Adjust call to get_hard_regno. + (uses_hard_regs_p): Likewise. + (process_alt_operands): Likewise. + +2016-09-13 Joe Seymour <joe.s@somniumtech.com> + + PR target/70713 + * config/msp430/msp430.c (msp430_start_function): Emit an error + if a function is both weak and specifies an interrupt number. + +2016-09-13 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/77454 + * tree-ssa-dom.c (optimize_stmt): Set modified flag on stmt after + changing GIMPLE_COND. Move update_stmt_if_modified call after this. + Formatting fix. + +2016-09-13 Tamar Christina <tamar.christina@arm.com> + + * config/aarch64/aarch64-builtins.c + (aarch64_init_simd_builtins): Fix builtin type signature printing. + +2016-09-13 Uros Bizjak <ubizjak@gmail.com> + + * config/alpha/alpha.c (alpha_pass_by_reference): Pass un-named + SFmode and SCmode arguments by reference. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * diagnostic-show-locus.c (selftest::test_one_liner_fixit_insert): + Rename to... + (selftest::test_one_liner_fixit_insert_before): ...this, and update + for renaming of add_fixit_insert to add_fixit_insert_before. + (selftest::test_one_liner_fixit_insert_after): New function. + (selftest::test_one_liner_fixit_validation_adhoc_locations): + Update for renaming of add_fixit_insert to add_fixit_insert_before. + (selftest::test_one_liner_many_fixits): Likewise. + (selftest::test_diagnostic_show_locus_one_liner): Update for + renaming, call new test function. + (selftest::test_diagnostic_show_locus_fixit_lines): Update for + renaming of add_fixit_insert to add_fixit_insert_before. + (selftest::test_fixit_consolidation): Likewise. + * diagnostic.c (selftest::test_print_parseable_fixits_insert): + Likewise. + * edit-context.c (selftest::test_applying_fixits_insert): Rename to... + (selftest::test_applying_fixits_insert_before): ...this. + (selftest::test_applying_fixits_insert): Update for renaming of + add_fixit_insert to add_fixit_insert_before. + (selftest::test_applying_fixits_insert_after): New function. + (selftest::test_applying_fixits_insert_after_at_line_end): New + function. + (selftest::test_applying_fixits_insert_after_failure): New function. + (selftest::test_applying_fixits_multiple): Update for renaming of + add_fixit_insert to add_fixit_insert_before. + (selftest::change_line): Likewise. + (selftest::test_applying_fixits_unreadable_file): Likewise. + (selftest::test_applying_fixits_line_out_of_range): Likewise. + (selftest::test_applying_fixits_column_validation): Likewise. + (selftest::test_applying_fixits_column_validation): Likewise. + (selftest::edit_context_c_tests): Update for renamed test function; + call new test functions. + +2016-09-13 Pat Haugen <pthaugen@us.ibm.com> + + PR tree-optimization/77536 + PR rtl-optimization/68212 + * config/rs6000/rs6000.md (div->recip splitter): Remove + optimize_insn_for_speed_p condition. + +2016-09-13 Maciej W. Rozycki <macro@imgtec.com> + + * optabs.c (prepare_cmp_insn): Update documentation comment. + +2016-09-13 Jakub Jelinek <jakub@redhat.com> + Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR middle-end/77475 + * opts.h (candidates_list_and_hint): Declare. + * opts-common.c (candidates_list_and_hint): New function. + (cmdline_handle_error): Use it. + +2016-09-12 David Malcolm <dmalcolm@redhat.com> + + * edit-context.c (edited_line::get_len): New accessor. + (edited_file::print_diff): Split out hunk-printing into... + (edited_file::print_diff_hunk): New method. + (edited_file::print_diff_line): New method. + +2016-09-12 Andrew Pinski <apinski@cavium.com> + + * config/aarch64/aarch64-tuning-flags.def (SLOW_UNALIGNED_LDPW): + New tuning option. + * config/aarch64/aarch64.c (thunderx_tunings): Enable + AARCH64_EXTRA_TUNE_SLOW_UNALIGNED_LDPW. + (aarch64_operands_ok_for_ldpstp): Return false if + AARCH64_EXTRA_TUNE_SLOW_UNALIGNED_LDPW and the mode + was SImode and the alignment is less than 8 byte. + (aarch64_operands_adjust_ok_for_ldpstp): Likewise. + +2016-09-12 Orlando Arias <oarias@knights.ucf.edu> + + PR target/77570 + * config/msp430/msp430.md (delay_cycles_32x): Fix pushm/popm. + +2016-09-12 Marek Polacek <polacek@redhat.com> + + * doc/extend.texi: Use lowercase "boolean". + * doc/invoke.texi: Likewise. + * doc/md.texi: Likewise. + * target.def: Likewise. + * doc/tm.texi: Regenerated. + +2016-09-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + PR middle-end/77426 + * expmed.c (synth_mult): Delete duplicate mode check. + +2016-09-10 Tom de Vries <tom@codesourcery.com> + + PR C/71602 + * builtins.c (std_canonical_va_list_type): Strictly return non-null for + va_list type only. + * config/i386/i386.c (ix86_canonical_va_list_type): Same. + * gimplify.c (gimplify_va_arg_expr): Handle &va_list. + +2016-09-09 Peter Bergner <bergner@vnet.ibm.com> + + PR rtl-optimization/77289 + * lra-constraints.c (get_final_hard_regno): Add support for non hard + register numbers. Remove support for subregs. + (get_hard_regno): Use SUBREG_P. Don't call get_final_hard_regno(). + (get_reg_class): Delete removed get_final_hard_regno() argument. + (uses_hard_regs_p): Call get_final_hard_regno(). + +2016-09-09 Martin Sebor <msebor@redhat.com> + + PR c/77520 + PR c/77521 + * pretty-print.c (pp_quoted_string): New function. + (pp_format): Call it for %c and %s directives. + +2016-09-10 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * doc/tm.texi.in (INITIAL_FRAME_POINTER_OFFSET): Remove. + (ELIMINABLE_REGS, TARGET_CAN_ELIMINATE, + INITIAL_ELIMINATION_OFFSET) : Update documentation. + * target.def (frame_pointer_required, can_eliminate): Likewise. + * doc/tm.texi: Regenerated. + * builtins.c (expand_builtin_setjmp_receiver): Remove #ifdef + ELIMINABLE_REGS. + * df-scan.c (df_hard_reg_init): Likewise. + * ira.c (ira_setup_eliminable_regset): Likewise. + * lra-eliminations.c (reg_eliminate_1, (update_reg_eliminate, + init_elim_table): Likewise. + * reload1.c (reg_eliminate_1, verify_initial_elim_offsets, + set_initial_elim_offsets, update_eliminables, + init_elim_table): Likewise. + * rtlanal.c (get_initial_register_offset): Likewise. + * config/ft32/ft32.h (INITIAL_FRAME_POINTER_OFFSET): Remove. + * config/m32r/m32r.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. + * config/moxie/moxie.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. + * config/vax/vax.h (INITIAL_FRAME_POINTER_OFFSET): Likewise. + * config/fr30/fr30.h: Fix comment. + * config/frv/frv.c: Likewise. + * config/frv/frv.h: Likewise. + * config/ft32/ft32.h: Likewise. + * config/visium/visium.h: Likewise. + * config/pa/pa64-linux.h: Likewise. + * config/v850/v850.h: Likewise. + * config/cris/cris.c: Likewise. + * config/ia64/ia64.h: Likewise. + * config/moxie/moxie.h: Likewise. + * config/m32r/m32r.h: Likewise. + +2016-09-10 Alexander Ivchenko <alexander.ivchenko@intel.com> + + PR target/77267 + * config.in: Regenerate. + * config/i386/linux-common.h (MPX_LD_AS_NEEDED_GUARD_PUSH): + New macro. + (MPX_LD_AS_NEEDED_GUARD_PUSH): Ditto. + (LIBMPXWRAPPERS_SPEC): Remove "--no-whole-archive" from + static-libmpxwrappers case. + (LIBMPX_SPEC): Add guards with MPX_LD_AS_NEEDED_GUARD_PUSH and + MPX_LD_AS_NEEDED_GUARD_POP. + * configure: Regenerate. + * configure.ac (HAVE_LD_PUSHPOPSTATE_SUPPORT): New variable. + defined if linker support "--push-state"/"--pop-state". + +2016-09-09 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * doc/cpp.texi (__*_WIDTH__): Small wording fixes. + +2016-09-09 Joseph Myers <joseph@codesourcery.com> + + * doc/cpp.texi (__SCHAR_WIDTH__, __SHRT_WIDTH__, __INT_WIDTH__) + (__LONG_WIDTH__, __LONG_LONG_WIDTH__, __PTRDIFF_WIDTH__) + (__SIG_ATOMIC_WIDTH__, __SIZE_WIDTH__, __WCHAR_WIDTH__) + (__WINT_WIDTH__, __INT_LEAST8_WIDTH__, __INT_LEAST16_WIDTH__) + (__INT_LEAST32_WIDTH__, __INT_LEAST64_WIDTH__) + (__INT_FAST8_WIDTH__, __INT_FAST16_WIDTH__, __INT_FAST32_WIDTH__) + (__INT_FAST64_WIDTH__, __INTPTR_WIDTH__, __INTMAX_WIDTH__): + Document. + * ginclude/stdint-gcc.h [__STDC_WANT_IEC_60559_BFP_EXT__]: Define + width macros from TS 18661-1. + * glimits.h [__STDC_WANT_IEC_60559_BFP_EXT__]: Likewise. + +2016-09-08 Jakub Jelinek <jakub@redhat.com> + + PR fortran/77516 + * omp-low.c (lower_rec_simd_input_clauses): Use max_vf for non-positive + OMP_CLAUSE_SAFELEN_EXPR. + +2016-09-07 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in (OBJS): Add substring-locations.o. + * langhooks-def.h (class substring_loc): New forward decl. + (lhd_get_substring_location): New decl. + (LANG_HOOKS_GET_SUBSTRING_LOCATION): New macro. + (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SUBSTRING_LOCATION. + * langhooks.c (lhd_get_substring_location): New function. + * langhooks.h (class substring_loc): New forward decl. + (struct lang_hooks): Add field get_substring_location. + * substring-locations.c: New file, taking definition of + format_warning_va and format_warning_at_substring from + c-family/c-format.c, making them non-static. + * substring-locations.h (class substring_loc): Move class here + from c-family/c-common.h. Add and rewrite comments. + (format_warning_va): New decl. + (format_warning_at_substring): New decl. + (get_source_location_for_substring): Add comment. + +2016-09-07 Eric Gallager <egall@gwmail.gwu.edu> + + * config/i386/i386.c: Add 'U' suffix to processor feature bits + to avoid -Wnarrowing warning. + * config/i386/x86-tune.def: Likewise for DEF_TUNE selector bitmasks. + * opts.c: Likewise for SANITIZER_OPT bitmasks. + +2016-09-07 Wilco Dijkstra <wdijkstr@arm.com> + + * config/aarch64/aarch64.c (aarch64_legitimize_address): + Avoid use of base_offset if offset already in range. + +2016-09-07 Kaz Kojima <kkojima@gcc.gnu.org> + + * config/sh/sh-protos.h (struct sh_atomic_model, + selected_atomic_model, TARGET_ATOMIC_ANY, TARGET_ATOMIC_STRICT, + TARGET_ATOMIC_SOFT_GUSA, TARGET_ATOMIC_HARD_LLCS, + TARGET_ATOMIC_SOFT_TCB, TARGET_ATOMIC_SOFT_IMASK): Move to... + * config/sh/sh.h (struct sh_atomic_model, + selected_atomic_model, TARGET_ATOMIC_ANY, TARGET_ATOMIC_STRICT, + TARGET_ATOMIC_SOFT_GUSA, TARGET_ATOMIC_HARD_LLCS, + TARGET_ATOMIC_SOFT_TCB, TARGET_ATOMIC_SOFT_IMASK): ...here. + Guard with __cplusplus. + +2016-09-06 Jakub Jelinek <jakub@redhat.com> + + PR target/69255 + * config/i386/i386.c (ix86_expand_builtin): For builtin with + unsupported or unknown ISA, use expand_call. + +2016-09-06 Martin Liska <mliska@suse.cz> + + PR gcov-profile/77378 + PR gcov-profile/77466 + * tree-profile.c (tree_profiling): Detect whether target can use + -fprofile-update=atomic. + +2016-09-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77479 + * tree-vrp.c (update_value_range): Extend overflow handling to + VARYING. + +2016-09-05 Jakub Jelinek <jakub@redhat.com> + + PR target/77476 + * config/i386/i386.md (isa): Add x64_avx512bw. + (*zero_extendsidi2): For alternative 11 use x64_avx512bw isa. + (kmov_isa): New mode attr. + (zero_extend<mode>di2): Use <kmov_isa> isa for the last alternative. + (*zero_extend<mode>si2): Likewise. + (*zero_extendqihi2): Use avx512dq isa for the last alternative. + +2016-09-05 Gerald Pfeifer <gerald@pfeifer.com> + + * doc/invoke.texi (SPU Options): nops -> NOPs. + (x86 Options): Ditto. + +2016-09-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/77475 + * toplev.c (process_options): Temporarily set input_location + to UNKNOWN_LOCATION around targetm.target_option.override () call. + +2016-09-05 Uros Bizjak <ubizjak@gmail.com> + + PR rtl-optimization/77452 + * explow.c (plus_constant) <case MEM>: Extract scalar constant from + inner-mode reference to a CONST_VECTOR constant in the constant pool. + +2016-09-05 Marek Polacek <polacek@redhat.com> + + PR c/77423 + * doc/invoke.texi: Update -Wlogical-not-parentheses documentation. + +2016-09-05 Jakub Jelinek <jakub@redhat.com> + + PR other/77421 + * gensupport.c (alter_output_for_subst_insn): Remove redundant + *insn_out == '*' test. Don't copy unnecessary to yet another + memory buffer, and don't leak it. + + PR rtl-optimization/77425 + * ipa-devirt.c (get_odr_type): Set val->id unconditionally. + +2016-09-03 Kirill Yukhin <kirill.yukhin@intel.com> + + * ubsan.c (ubsan_use_new_style_p): Fix check for empty string. + +2016-09-02 David Malcolm <dmalcolm@redhat.com> + + * common.opt (fdiagnostics-generate-patch): New option. + * diagnostic.c: Include "edit-context.h". + (diagnostic_initialize): Initialize context->edit_context_ptr. + (diagnostic_finish): Delete context->edit_context_ptr. + (diagnostic_report_diagnostic): Add fix-it hints from the + diagnostic to context->edit_context_ptr, if any. + * diagnostic.h (class edit_context): Add forward decl. + (struct diagnostic_context): Add field "edit_context_ptr". + * doc/invoke.texi (Diagnostic Message Formatting Options): Add + -fdiagnostics-generate-patch. + (-fdiagnostics-generate-patch): New item. + * toplev.c: Include "edit-context.h". + (process_options): Set global_dc->edit_context_ptr to a new + edit_context if the options need one. + (toplev::main): Handle -fdiagnostics-generate-patch by using + global_dc->edit_context_ptr. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR c/65467 + * gimplify.c (gimplify_adjust_omp_clauses_1): Diagnose implicit + map and firstprivate clauses on target construct for _Atomic + qualified decls. + (gimplify_adjust_omp_clauses): Diagnose explicit firstprivate clauses + on target construct for _Atomic qualified decls. + * omp-low.c (use_pointer_for_field): Return true for _Atomic qualified + decls. + * omp-simd-clone.c (simd_clone_clauses_extract): Warn and give up for + _Atomic qualified arguments not mentioned in uniform clause. + +2016-09-02 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in (OBJS-libcommon): Add edit-context.o. + * diagnostic-color.c (color_dict): Add "diff-filename", + "diff-hunk", "diff-delete", and "diff-insert". + (parse_gcc_colors): Update default value of GCC_COLORS in comment + to reflect above changes. + * doc/invoke.texi (-fdiagnostics-color): Update description of + default GCC_COLORS, and of the supported capabilities. + * edit-context.c: New file. + * edit-context.h: New file. + * input.c (struct fcache): Add field "missing_trailing_newline". + (diagnostics_file_cache_forcibly_evict_file): Initialize it to + true. + (add_file_to_cache_tab): Likewise. + (fcache::fcache): Likewise. + (get_next_line): Update c->missing_trailing_newline. + (location_missing_trailing_newline): New function. + * input.h (location_missing_trailing_newline): New decl. + * selftest-run-tests.c (selftest::run_tests): Call + edit_context_c_tests. + * selftest.h (edit_context_c_tests): New decl. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + Richard Biener <rguenth@suse.de> + + PR tree-optimization/77444 + * tree-ssa-loop-ivopts.c (cand_value_at): For pointers use sizetype + as steptype, remove redundant initialization. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/77396 + * sanopt.c: Include gimple-ssa.h, tree-phinodes.h and ssa-iterators.h. + (sanopt_optimize_walker): Optimize away + __asan_before_dynamic_init (...) followed by + __asan_after_dynamic_init () without intervening memory loads/stores. + * ipa-pure-const.c (special_builtin_state): Handle + BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT and + BUILT_IN_ASAN_AFTER_DYNAMIC_INIT. + +2016-09-02 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + + * cfg.c (free_original_copy_tables): Replace second assignment of + bb_copy = NULL by bb_original = NULL. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR other/77421 + * config/i386/i386.c (ix86_expanded_args_builtin): Remove redundant + assignment added in r216794. + +2016-09-02 David Malcolm <dmalcolm@redhat.com> + + * Makefile.in (OBJS): Add typed-splay-tree.o. + * selftest-run-tests.c (selftest::run_tests): Call + typed_splay_tree_c_tests. + * selftest.h (typed_splay_tree_c_tests): New decl. + * typed-splay-tree.c: New file. + * typed-splay-tree.h (typed_splay_tree::foreach_fn): New typedef. + (typed_splay_tree::max): New method. + (typed_splay_tree::min): New method. + (typed_splay_tree::foreach): New method. + (typed_splay_tree::closure): New struct. + (typed_splay_tree::inner_foreach_fn): New function. + +2016-09-02 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + + * ipa-cp.c (ipcp_store_bits_results): Change option name from + -fipa-cp-bit to -fipa-bit-cp. + +2016-09-01 Martin Sebor <msebor@redhat.com> + + PR tree-optimization/71831 + * tree-object-size.h: Return bool instead of the size and add + argument for the size. + * tree-object-size.c (compute_object_offset): Update signature. + (addr_object_size): Same. + (compute_builtin_object_size): Return bool instead of the size + and add argument for the size. Handle POINTER_PLUS_EXPR when + optimization is disabled. + (expr_object_size): Adjust. + (plus_stmt_object_size): Adjust. + (pass_object_sizes::execute): Adjust. + * builtins.c (fold_builtin_object_size): Adjust. + * doc/extend.texi (Object Size Checking): Update. + * ubsan.c (instrument_object_size): Adjust. + +2016-09-01 Martin Sebor <msebor@redhat.com> + + * genmatch.c (parser::parse_expr): Increase buffer size to guarantee + it fits the output of the formatted function regardless of its + arguments. + * gcc/genmodes.c (parser::parse_expr): Same. + * gimplify.c (gimplify_asm_expr): Same. + * passes.c (pass_manager::register_one_dump_file): Same. + * print-tree.c (print_node): Same. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/altivec.md: Use VSCR_REGNO instead of 110 throughout. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/altivec.md: Use VRSAVE_REGNO instead of 109 throughout. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/altivec.md: Use CR6_REGNO instead of 74 throughout. + * config/rs6000/vector.md: Ditto. + * config/rs6000/vsx.md: Ditto. + +2016-09-01 Eric Botcazou <ebotcazou@adacore.com> + + * ipa-inline-analysis.c (param_change_prob): Get to the base object + first in all cases. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/rs6000.md (*restore_gpregs_<mode>_r11, + *restore_gpregs_<mode>_r12, *restore_gpregs_<mode>_r1, + *return_and_restore_gpregs_<mode>_r11, + *return_and_restore_gpregs_<mode>_r12, + *return_and_restore_gpregs_<mode>_r1, + *return_and_restore_fpregs_<mode>_r11, + *return_and_restore_fpregs_<mode>_r12, + *return_and_restore_fpregs_<mode>_r1): Use the hard register LR_REGNO + directly instead of via the "l" constraint. Renumber operands. + Fix whitespace. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/altivec.md (*save_world, *save_vregs_<mode>_r11, + save_vregs_<mode>_r12, *restore_vregs_<mode>_r11, + *restore_vregs_<mode>_r12): Use LR_REGNO instead of 65. + * config/rs6000/darwin.md (load_macho_picbase, load_macho_picbase_si, + load_macho_picbase_di, *call_indirect_nonlocal_darwin64, + *call_nonlocal_darwin64, *call_value_indirect_nonlocal_darwin64, + *call_value_nonlocal_darwin64, reload_macho_picbase, + reload_macho_picbase_si, reload_macho_picbase_di): Ditto. + * config/rs6000/rs6000.h (RETURN_ADDR_IN_PREVIOUS_FRAME): Ditto. + * config/rs6000/rs6000.md (*save_gpregs_<mode>_r11, + *save_gpregs_<mode>_r12, *save_gpregs_<mode>_r1, + *save_fpregs_<mode>_r11, *save_fpregs_<mode>_r12, + *save_fpregs_<mode>_r1): Ditto. + * config/rs6000/spe.md (*save_gpregs_spe, *restore_gpregs_spe, + *return_and_restore_gpregs_spe): Ditto. + +2016-09-01 Segher Boessenkool <segher@kernel.crashing.org> + + * config/rs6000/rs6000.md + (define_insn "*return_and_restore_fpregs_aix_<mode>_r11"): Delete + the use of the link register. + (define_insn "*return_and_restore_fpregs_aix_<mode>_r1"): Ditto. + +2016-09-01 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + Michael Meissner <meissner@linux.vnet.ibm.com> + + PR target/72827 + * config/rs6000/rs6000.c (rs6000_legitimize_address): Avoid + reg+reg addressing for TImode. + (rs6000_legitimate_address_p): Only allow register indirect + addressing for TImode, even without TARGET_QUAD_MEMORY. + +2016-09-01 Richard Biener <rguenther@suse.de> + + PR middle-end/77436 + * tree-chrec.c (tree_fold_binomial): Use widest_int, properly + check whether the result fits the desired result type. + +2016-09-01 Nathan Sidwell <nathan@acm.org> + + * config/nvptx/nvptx.md (cbranch<mode>4): Op 2 can be const. + +2016-09-01 Wilco Dijkstra <wdijkstr@arm.com> + + * config/aarch64/aarch64.c (aarch64_legitimize_address_displacement): + New function. + (TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT): Define. + +2016-09-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * config/aarch64/aarch64.md (*ands<mode>_compare0): New pattern. + * config/aarch64/aarch64.c (aarch64_select_cc_mode): Return CC_NZmode + for comparisons of integer ZERO_EXTEND against zero. + +2016-09-01 Eric Botcazou <ebotcazou@adacore.com> + + * config/i386/i386.c (ix86_option_override_internal): Also disable the + STV pass if -mstackrealign is enabled. + 2016-08-31 Ilya Verbin <iverbin@gmail.com> * config/i386/driver-i386.c (host_detect_local_cpu): Fix detection of @@ -438,8 +1299,8 @@ (gen_scheduled_generic_parms_dies): Do not set early dwarf here. (dwarf2out_early_finish): But do it here. -2016-08-24 Michael Collison <michael.collison@linaro.org> - Michael Collison <michael.collison@arm.com> +2016-08-24 Michael Collison <michael.collison@linaro.org> + Michael Collison <michael.collison@arm.com> * config/arm/arm-modes.def: Add new condition code mode CC_V to represent the overflow bit. @@ -994,8 +1855,8 @@ When doing auto-parallelizing also prevent use of PHIs that carry dependences across loop backedges. -2016-08-18 Tamar Christina <tamar.christina@arm.com> - Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> +2016-08-18 Tamar Christina <tamar.christina@arm.com> + Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> * varasm.c (default_use_anchors_for_symbol_p): Reject too large decls. @@ -1039,7 +1900,7 @@ when find_reloads_toplev returns address_reloaded==-1. (alternative_allows_const_pool_ref): Update comment. -2015-08-17 Alan Hayward <alan.hayward@arm.com> +2015-08-17 Alan Hayward <alan.hayward@arm.com> PR tree-optimization/71752 * tree-vect-loop.c (vectorizable_reduction): Keep SLP operand ordering. @@ -1537,7 +2398,7 @@ the currently executable edges have fixed ranges. Always go through update_value_range. -2016-08-12 Alexandre Oliva <aoliva@redhat.com> +2016-08-12 Alexandre Oliva <aoliva@redhat.com> PR debug/63240 * langhooks-def.h @@ -2519,7 +3380,7 @@ fix_debug_reg_uses after changing source register mode to V1TImode if source register is undefined. -2015-08-01 Alan Hayward <alan.hayward@arm.com> +2015-08-01 Alan Hayward <alan.hayward@arm.com> PR tree-optimization/71818 * tree-vect-loop-manip.c (vect_can_advance_ivs_p): Don't advance IVs @@ -2901,7 +3762,7 @@ choosing a better vector mode to do the extraction from. 2016-07-26 Richard Biener <rguenther@suse.de> - Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR middle-end/70920 * match.pd ((intptr)x eq/ne CST to x eq/ne (typeof x) CST): New @@ -3337,11 +4198,11 @@ * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Reformat two multi-line strings. -2016-07-22 Martin Sebor <msebor@redhat.com> +2016-07-22 Martin Sebor <msebor@redhat.com> * doc/extend.texi (Compound Literals): Add '@' missed in last commit. -2016-07-22 Martin Sebor <msebor@redhat.com> +2016-07-22 Martin Sebor <msebor@redhat.com> PR c/71560 * doc/extend.texi (Compound Literals): Correct and clarify. @@ -6040,7 +6901,7 @@ * tree-ssa-loop-ivopts.c (determine_group_iv_cost_address): Compute cost for all uses in group. -2016-06-17 Bin Cheng <bin.cheng@arm.com> +2016-06-17 Bin Cheng <bin.cheng@arm.com> * tree-vect-loop.c (vect_create_epilog_for_reduction): Only insert gimple seq if it's not empty. @@ -9526,7 +10387,7 @@ builtin __SANITIZE_THREAD__ macros for fsanitize=thread switch. * doc/cpp.texi: Document new macros. -2016-05-19 Bin Cheng <bin.cheng@arm.com> +2016-05-19 Bin Cheng <bin.cheng@arm.com> PR tree-optimization/69848 * tree-vect-loop.c (vectorizable_reduction): Don't factor @@ -9755,7 +10616,7 @@ cleanup_cfg with CLEANUP_EXPENSIVE after shrink-wrapping instead of before. Add a comment. -2016-05-18 Bin Cheng <bin.cheng@arm.com> +2016-05-18 Bin Cheng <bin.cheng@arm.com> * tree-ssa-loop-ivopts.c (get_computation_cost_at): Check invariant expression pointer, not pointer to the pointer. @@ -14958,7 +15819,7 @@ (possible_polymorphic_call_target_p): Fix formatting. 2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com> - Jakub Jelinek <jakub@redhat.com> + Jakub Jelinek <jakub@redhat.com> PR middle-end/70457 * tree-inline.c (estimate_num_insn): Use gimple_call_builtin_p @@ -16132,7 +16993,7 @@ * config/aarch64/aarch64.opt (aarch64_fix_a53_err843419): Save. 2016-03-10 Alan Lawrence <alan.lawrence@arm.com> - Jakub Jelinek <jakub@redhat.com> + Jakub Jelinek <jakub@redhat.com> * common.opt (funconstrained-commons, flag_unconstrained_commons): New. * tree.c (array_at_struct_end_p): Do not limit to size of decl for @@ -18672,7 +19533,7 @@ * wide-int.cc (canonize_uhwi): New function. (wi::divmod_internal): Use it. -2016-02-02 James Norris <jnorris@codesourcery.com +2016-02-02 James Norris <jnorris@codesourcery.com> * gimplify.c (omp_notice_variable): Add usage check. diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP index 45d40cddd2b..718c5c932ef 100644 --- a/gcc/DATESTAMP +++ b/gcc/DATESTAMP @@ -1 +1 @@ -20160901 +20160919 diff --git a/gcc/Makefile.in b/gcc/Makefile.in index eb5ab61f36c..332c85e2fb2 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1443,6 +1443,7 @@ OBJS = \ store-motion.o \ streamer-hooks.o \ stringpool.o \ + substring-locations.o \ target-globals.o \ targhooks.o \ timevar.o \ @@ -1542,6 +1543,7 @@ OBJS = \ tree-vectorizer.o \ tree-vrp.o \ tree.o \ + typed-splay-tree.o \ valtrack.o \ value-prof.o \ var-tracking.o \ @@ -1560,6 +1562,7 @@ OBJS = \ # Objects in libcommon.a, potentially used by all host binaries and with # no target dependencies. OBJS-libcommon = diagnostic.o diagnostic-color.o diagnostic-show-locus.o \ + edit-context.o \ pretty-print.o intl.o \ vec.o input.o version.o hash-table.o ggc-none.o memory-block.o \ selftest.o diff --git a/gcc/alias.c b/gcc/alias.c index f4b5a924b33..277125e01ae 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -2534,7 +2534,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) { HOST_WIDE_INT sc = INTVAL (XEXP (x, 1)); unsigned HOST_WIDE_INT uc = sc; - if (sc < 0 && -uc == (uc & -uc)) + if (sc < 0 && pow2_or_zerop (-uc)) { if (xsize > 0) xsize = -xsize; @@ -2549,7 +2549,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) { HOST_WIDE_INT sc = INTVAL (XEXP (y, 1)); unsigned HOST_WIDE_INT uc = sc; - if (sc < 0 && -uc == (uc & -uc)) + if (sc < 0 && pow2_or_zerop (-uc)) { if (ysize > 0) ysize = -ysize; diff --git a/gcc/builtins.c b/gcc/builtins.c index b981bcd281a..189aeac6912 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -305,7 +305,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, { ptr_bitmask = TREE_INT_CST_LOW (TREE_OPERAND (addr, 1)); ptr_bitmask *= BITS_PER_UNIT; - align = ptr_bitmask & -ptr_bitmask; + align = least_bit_hwi (ptr_bitmask); addr = TREE_OPERAND (addr, 0); } @@ -325,7 +325,7 @@ get_object_alignment_2 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT step = 1; if (TMR_STEP (exp)) step = TREE_INT_CST_LOW (TMR_STEP (exp)); - align = MIN (align, (step & -step) * BITS_PER_UNIT); + align = MIN (align, least_bit_hwi (step) * BITS_PER_UNIT); } if (TMR_INDEX2 (exp)) align = BITS_PER_UNIT; @@ -404,7 +404,7 @@ get_object_alignment (tree exp) ptr & (align - 1) == bitpos. */ if (bitpos != 0) - align = (bitpos & -bitpos); + align = least_bit_hwi (bitpos); return align; } @@ -502,7 +502,7 @@ get_pointer_alignment (tree exp) ptr & (align - 1) == bitpos. */ if (bitpos != 0) - align = (bitpos & -bitpos); + align = least_bit_hwi (bitpos); return align; } @@ -862,7 +862,6 @@ expand_builtin_setjmp_receiver (rtx receiver_label) if (!HARD_FRAME_POINTER_IS_ARG_POINTER && fixed_regs[ARG_POINTER_REGNUM]) { -#ifdef ELIMINABLE_REGS /* If the argument pointer can be eliminated in favor of the frame pointer, we don't need to restore it. We assume here that if such an elimination is present, it can always be used. @@ -877,7 +876,6 @@ expand_builtin_setjmp_receiver (rtx receiver_label) break; if (i == ARRAY_SIZE (elim_regs)) -#endif { /* Now restore our arg pointer from the address at which it was saved in our stack frame. */ @@ -4089,10 +4087,6 @@ std_canonical_va_list_type (tree type) { tree wtype, htype; - if (INDIRECT_REF_P (type)) - type = TREE_TYPE (type); - else if (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE (type))) - type = TREE_TYPE (type); wtype = va_list_type_node; htype = type; /* Treat structure va_list types. */ @@ -5565,7 +5559,7 @@ fold_builtin_atomic_always_lock_free (tree arg0, tree arg1) /* Either this argument is null, or it's a fake pointer encoding the alignment of the object. */ - val = val & -val; + val = least_bit_hwi (val); val *= BITS_PER_UNIT; if (val == 0 || mode_align < val) @@ -9615,7 +9609,7 @@ fold_builtin_object_size (tree ptr, tree ost) if (TREE_CODE (ptr) == ADDR_EXPR) { - bytes = compute_builtin_object_size (ptr, object_size_type); + compute_builtin_object_size (ptr, object_size_type, &bytes); if (wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } @@ -9624,9 +9618,8 @@ fold_builtin_object_size (tree ptr, tree ost) /* If object size is not known yet, delay folding until later. Maybe subsequent passes will help determining it. */ - bytes = compute_builtin_object_size (ptr, object_size_type); - if (bytes != (unsigned HOST_WIDE_INT) (object_size_type < 2 ? -1 : 0) - && wi::fits_to_tree_p (bytes, size_type_node)) + if (compute_builtin_object_size (ptr, object_size_type, &bytes) + && wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2a38deb1666..fa9b96140fd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,171 @@ +2016-09-15 Jason Merrill <jason@redhat.com> + + * c-common.c (check_cxx_fundamental_alignment_constraints): Check + DECL_EXTERNAL. + +2016-09-14 Jason Merrill <jason@redhat.com> + + * c-common.c (check_cxx_fundamental_alignment_constraints): Don't + limit FIELD_DECL, either. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * c-common.c (c_common_truthvalue_conversion): Use false instead of 0. + * c-common.h (build_unary_op): Change nonconvert parameter type to bool. + * c-omp.c (c_finish_omp_atomic): Use false instead of 0. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * c-common.c (warn_logical_not_parentheses): Replace + rich_location::add_fixit_insert calls with add_fixit_insert_before + and add_fixit_insert_after, eliminating the "next_loc" calculation. + +2016-09-13 Jason Merrill <jason@redhat.com> + Tom de Vries <tom@codesourcery.com> + + PR c++/77427 + * c-common.c (set_underlying_type): Don't treat array as builtin type. + +2016-09-13 Jason Merrill <jason@redhat.com> + + * c-common.c (check_cxx_fundamental_alignment_constraints): Don't + limit types at all. + +2016-09-12 Jason Merrill <jason@redhat.com> + + * c-common.c (check_cxx_fundamental_alignment_constraints): Fix + bit/byte confusion, allow large alignment for types. + +2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR c++/77496 + * c-common.c (warn_for_omitted_condop): Also warn for boolean data. + +2016-09-12 David Malcolm <dmalcolm@redhat.com> + + PR c/72858 + * c-format.c (argument_parser::check_argument_type): Add params + "type_start" and "conversion_char". Use the former to generate + offset_to_type_start and pass it and conversion_char to + check_format_types. + (check_format_info_main): Capture the start of the type + information as "type_start", and pass it an format_char + to arg_parser.check_argument_type. + (check_format_types): Provide an example in the leading comment. + Add params "offset_to_type_start" and "conversion_char"; pass + them to format_type_warning calls. + (test_get_modifier_for_format_len): Likewise. + (matching_type_p): New function. + (get_format_for_type): Add param "conversion_char" and move + implementation into... + (get_format_for_type_1): ...new function, called twice. + Use new function matching_type_p rather than checking for + TYPE_CANONICAL equality. + (get_corrected_substring): New function. + (format_type_warning): Provide an example in the leading comment. + Add params "offset_to_type_start" and "conversion_char". Replace + call to get_format_for_type with call to get_corrected_substring + and move rejection of hints for widths/precisions there. + (assert_format_for_type_streq): Add param "conversion_char". + (ASSERT_FORMAT_FOR_TYPE_STREQ): Add param CONVERSION_CHAR. + (test_get_format_for_type_printf): Add conversion chars to the + tests, adding coverage for various combinations of integer + vs double conversions, and for preserving octal and hexadecimal + conversions. + (test_get_format_for_type_scanf): Add conversion chars to the + tests. + +2016-09-10 Tom de Vries <tom@codesourcery.com> + + PR C/71602 + * c-common.c (build_va_arg): Handle more strict + targetm.canonical_va_list_type. Replace first argument type error with + assert. + +2016-09-09 Martin Sebor <msebor@redhat.com> + + PR c/77520 + PR c/77521 + * c-format.c (argument_parser::find_format_char_info): Use %qc + format directive unconditionally. + +2016-09-09 Jason Merrill <jason@redhat.com> + + Implement C++17 new of over-aligned types. + * c.opt: Add -faligned-new and -Waligned-new. + * c-common.c (max_align_t_align): Split out from... + (cxx_fundamental_alignment_p): ...here. + * c-common.h: Declare it. + * c-cppbuiltin.c (c_cpp_builtins): Handle aligned new. + +2016-09-09 Joseph Myers <joseph@codesourcery.com> + + * c-cppbuiltin.c (builtin_define_type_width): New function. + (builtin_define_stdint_macros, c_cpp_builtins): Define type width + macros. + +2016-09-07 David Malcolm <dmalcolm@redhat.com> + + * c-common.c (get_cpp_ttype_from_string_type): Handle being passed + a POINTER_TYPE. + (substring_loc::get_location): Move to substring-locations.c, + keeping implementation as... + (c_get_substring_location): New function, from the above, reworked + to use accessors rather than member lookup. + * c-common.h (class substring_loc): Move to substring-locations.h, + replacing with a forward decl. + (c_get_substring_location): New decl. + * c-format.c: Include "substring-locations.h". + (format_warning_va): Move to substring-locations.c. + (format_warning_at_substring): Likewise. + +2016-09-06 Martin Sebor <msebor@redhat.com> + + PR c/77336 + * c-format.c (check_function_format): Avoid issuing warnings for + functions unless they call format functions with non-constant + format strings. + +2016-09-06 Richard Biener <rguenther@suse.de> + + PR c/77450 + * c-common.c (c_common_mark_addressable_vec): Handle + COMPOUND_LITERAL_EXPR. + +2016-09-05 Marek Polacek <polacek@redhat.com> + + PR c/77423 + * c-common.c (bool_promoted_to_int_p): New function. + (expr_has_boolean_operands_p): New function. + (warn_logical_not_parentheses): Return if expr_has_boolean_operands_p. + (maybe_warn_bool_compare): Use bool_promoted_to_int_p. + +2016-09-04 Tom de Vries <tom@codesourcery.com> + + revert: + 2016-08-29 Tom de Vries <tom@codesourcery.com> + + * c-common.c (build_va_arg): Replace first argument type error + with assert. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR c/65467 + * c-omp.c (c_finish_omp_atomic): Reject _Atomic qualified expressions. + (c_finish_omp_for): Reject _Atomic qualified iterators. + +2016-09-01 Martin Sebor <msebor@redhat.com> + + * c-ada-spec.c (dump_ada_function_declaration): Increase buffer + size to guarantee it fits the output of the formatted function + regardless of its arguments. + +2016-09-01 Marek Polacek <polacek@redhat.com> + + PR c/7652 + * c-common.c (resolve_overloaded_builtin): Fix formatting. Add + FALLTHRU comments. + 2016-08-29 Marek Polacek <polacek@redhat.com> PR c/77292 @@ -278,7 +446,7 @@ PR c++/65970 * c.opt (fconstexpr-loop-limit): New. -2016-07-22 Martin Sebor <msebor@redhat.com> +2016-07-22 Martin Sebor <msebor@redhat.com> PR c++/71675 * c-common.c (resolve_overloaded_builtin): Avoid converting @@ -1004,7 +1172,7 @@ * c-common.c (valid_array_size_p): New function. * c-common.h (valid_array_size_p): Declare. -2015-11-11 Dominique d'Humieres <dominiq@lps.ens.fr> +2015-11-11 Dominique d'Humieres <dominiq@lps.ens.fr> PR bootstrap/68271 * c-pragma.c (c_register_pragma_1): Update the gcc_assert to 256. @@ -1113,7 +1281,7 @@ * c-omp.c (c_omp_split_clauses): Remove conditional compilation. Use flag_checking. -2015-11-03 Bernd Schmidt <bschmidt@redhat.com> +2015-11-03 Bernd Schmidt <bschmidt@redhat.com> PR c++-common/67882 * c-common.h (fold_offsetof_1): Add argument. @@ -2167,14 +2335,14 @@ PRAGMA_OACC_CLAUSE_VECTOR_LENGTH, PRAGMA_OACC_CLAUSE_WAIT, PRAGMA_OACC_CLAUSE_WORKER. -2015-01-14 Marcos Diaz <marcos.diaz@tallertechnologies.com> +2015-01-14 Marcos Diaz <marcos.diaz@tallertechnologies.com> * c-cppbuiltin.c (c_cpp_builtins): New cpp define __SSP_EXPLICIT__ for the new option fstack-protector_explicit. * c-common.c (c_common_attribute_table): Add stack_protect attribute. (handle_stack_protect_attribute): New function. -2015-01-13 Martin Uecker <uecker@eecs.berkeley.edu> +2015-01-13 Martin Uecker <uecker@eecs.berkeley.edu> * c.opt: New option -Warray-bounds=. @@ -2262,7 +2430,7 @@ * c-cppbuiltin.c (__cpp_sized_deallocation): Uncomment and move macro. Control macro with flag_sized_deallocation. -2014-12-20 Martin Uecker <uecker@eecs.berkeley.edu> +2014-12-20 Martin Uecker <uecker@eecs.berkeley.edu> * c.opt (Wdiscarded-array-qualifiers): New option. @@ -3416,7 +3584,7 @@ (print_destructor): Retrieve the origin of the destructor. (print_ada_declaration): Revamp handling of constructors/destructors. -2013-12-23 Stuart Hastings <stuart@apple.com> +2013-12-23 Stuart Hastings <stuart@apple.com> Bill Maddox <maddox@google.com> Jason Merrill <jason@redhat.com> @@ -4663,11 +4831,11 @@ * c-pch.c (c_common_read_pch): Rebuild the location_adhoc_data map when read in the pch. -2012-09-18 Arnaud Charlet <charlet@adacore.com> +2012-09-18 Arnaud Charlet <charlet@adacore.com> * c-ada-spec.c: Style fixes. -2012-09-18 Thomas Quinot <quinot@adacore.com> +2012-09-18 Thomas Quinot <quinot@adacore.com> * c.opt (-fada-spec-parent): Define new command line switch. * c-ada-spec.c (get_ada_package): When -fada-spec-parent @@ -5390,7 +5558,7 @@ (keyword_is_function_specifier): Handle RID_NORETURN. * c-common.h (RID_NORETURN): New. -2011-08-10 Artjoms Sinkarovs <artyom.shinakroff@gmail.com> +2011-08-10 Artjoms Sinkarovs <artyom.shinakroff@gmail.com> * c-common.c (unsafe_conversion_p): New function. Check if it is unsafe to convert an expression to the type. @@ -5758,7 +5926,7 @@ * c-ada-spec.c (dump_ada_template): Skip non-class instances. -2011-03-17 Kai Tietz +2011-03-17 Kai Tietz <ktietz@redhat.com> PR target/12171 * c-pretty-print.c (pp_c_specifier_qualifier_list): @@ -6151,8 +6319,8 @@ * c-common.h (objc_maybe_printable_name): New. * stub-objc.c (objc_maybe_printable_name): New. -2010-10-22 Artjoms Sinkarovs <artyom.shinakroff@gmail.com> - Andrew Pinski <pinskia@gmail.com> +2010-10-22 Artjoms Sinkarovs <artyom.shinakroff@gmail.com> + Andrew Pinski <pinskia@gmail.com> * c-common.h (c_common_mark_addressable_vec): Declare. * c-common.c (c_common_mark_addressable_vec): New function. @@ -6198,7 +6366,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-11-08 Fariborz Jahanian <fjahanian@apple.com> + 2005-11-08 Fariborz Jahanian <fjahanian@apple.com> Radar 4330422 * c-common.h (objc_non_volatilized_type): New declaration @@ -6208,7 +6376,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> + 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * c-common.h (objc_diagnose_private_ivar): New decl. @@ -6233,7 +6401,7 @@ 2010-10-14 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. - 2006 Fariborz Jahanian <fjahanian@apple.com> + 2006 Fariborz Jahanian <fjahanian@apple.com> Radars 4436866, 4505126, 4506903, 4517826 * c-common.c (c_common_resword): Define @property and its attributes. @@ -6250,7 +6418,7 @@ 2010-10-13 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. - 2006-04-26 Fariborz Jahanian <fjahanian@apple.com> + 2006-04-26 Fariborz Jahanian <fjahanian@apple.com> Radar 3803157 (method attributes) * c-common.c (handle_deprecated_attribute): Recognize @@ -6303,7 +6471,7 @@ and @required keywords. merge from FSF 'apple/trunk' branch. - 2006-01-30 Fariborz Jahanian <fjahanian@apple.com> + 2006-01-30 Fariborz Jahanian <fjahanian@apple.com> Radar 4386773 * c-common.h (RID_AT_OPTIONAL, RID_AT_REQUIRED): Two new @@ -6330,7 +6498,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> Radar 4281748 * c-common.h (objc_check_global_decl): New declaration. @@ -6387,7 +6555,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> + 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * c-common.h (objc_have_common_type): New declaration. diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index a4e0c38cef9..6a8e04b8d36 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -1603,7 +1603,7 @@ dump_ada_function_declaration (pretty_printer *buffer, tree func, { tree arg; const tree node = TREE_TYPE (func); - char buf[16]; + char buf[17]; int num = 0, num_args = 0, have_args = true, have_ellipsis = false; /* Compute number of arguments. */ diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index b29334ad9af..fc256867ec5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1122,6 +1122,9 @@ static enum cpp_ttype get_cpp_ttype_from_string_type (tree string_type) { gcc_assert (string_type); + if (TREE_CODE (string_type) == POINTER_TYPE) + string_type = TREE_TYPE (string_type); + if (TREE_CODE (string_type) != ARRAY_TYPE) return CPP_OTHER; @@ -1148,23 +1151,23 @@ get_cpp_ttype_from_string_type (tree string_type) GTY(()) string_concat_db *g_string_concat_db; -/* Attempt to determine the source location of the substring. - If successful, return NULL and write the source location to *OUT_LOC. - Otherwise return an error message. Error messages are intended - for GCC developers (to help debugging) rather than for end-users. */ +/* Implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION. */ const char * -substring_loc::get_location (location_t *out_loc) const +c_get_substring_location (const substring_loc &substr_loc, + location_t *out_loc) { - gcc_assert (out_loc); - - enum cpp_ttype tok_type = get_cpp_ttype_from_string_type (m_string_type); + enum cpp_ttype tok_type + = get_cpp_ttype_from_string_type (substr_loc.get_string_type ()); if (tok_type == CPP_OTHER) return "unrecognized string type"; return get_source_location_for_substring (parse_in, g_string_concat_db, - m_fmt_string_loc, tok_type, - m_caret_idx, m_start_idx, m_end_idx, + substr_loc.get_fmt_string_loc (), + tok_type, + substr_loc.get_caret_idx (), + substr_loc.get_start_idx (), + substr_loc.get_end_idx (), out_loc); } @@ -1479,6 +1482,36 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) } } +/* Return true iff T is a boolean promoted to int. */ + +static bool +bool_promoted_to_int_p (tree t) +{ + return (CONVERT_EXPR_P (t) + && TREE_TYPE (t) == integer_type_node + && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == BOOLEAN_TYPE); +} + +/* Return true iff EXPR only contains boolean operands, or comparisons. */ + +static bool +expr_has_boolean_operands_p (tree expr) +{ + STRIP_NOPS (expr); + + if (CONVERT_EXPR_P (expr)) + return bool_promoted_to_int_p (expr); + else if (UNARY_CLASS_P (expr)) + return expr_has_boolean_operands_p (TREE_OPERAND (expr, 0)); + else if (BINARY_CLASS_P (expr)) + return (expr_has_boolean_operands_p (TREE_OPERAND (expr, 0)) + && expr_has_boolean_operands_p (TREE_OPERAND (expr, 1))); + else if (COMPARISON_CLASS_P (expr)) + return true; + else + return false; +} + /* Warn about logical not used on the left hand side operand of a comparison. This function assumes that the LHS is inside of TRUTH_NOT_EXPR. Do not warn if RHS is of a boolean type, a logical operator, or @@ -1494,6 +1527,10 @@ warn_logical_not_parentheses (location_t location, enum tree_code code, || truth_value_p (TREE_CODE (rhs))) return; + /* Don't warn for expression like !x == ~(bool1 | bool2). */ + if (expr_has_boolean_operands_p (rhs)) + return; + /* Don't warn for !x == 0 or !y != 0, those are equivalent to !(x == 0) or !(y != 0). */ if ((code == EQ_EXPR || code == NE_EXPR) @@ -1507,11 +1544,8 @@ warn_logical_not_parentheses (location_t location, enum tree_code code, { location_t lhs_loc = EXPR_LOCATION (lhs); rich_location richloc (line_table, lhs_loc); - richloc.add_fixit_insert (lhs_loc, "("); - location_t finish = get_finish (lhs_loc); - location_t next_loc - = linemap_position_for_loc_and_offset (line_table, finish, 1); - richloc.add_fixit_insert (next_loc, ")"); + richloc.add_fixit_insert_before (lhs_loc, "("); + richloc.add_fixit_insert_after (lhs_loc, ")"); inform_at_rich_loc (&richloc, "add parentheses around left hand side " "expression to silence this warning"); } @@ -4565,7 +4599,7 @@ c_common_truthvalue_conversion (location_t location, tree expr) : truthvalue_false_node; case FUNCTION_DECL: - expr = build_unary_op (location, ADDR_EXPR, expr, 0); + expr = build_unary_op (location, ADDR_EXPR, expr, false); /* Fall through. */ case ADDR_EXPR: @@ -4705,10 +4739,10 @@ c_common_truthvalue_conversion (location_t location, tree expr) ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR), c_common_truthvalue_conversion (location, - build_unary_op (location, REALPART_EXPR, t, 0)), + build_unary_op (location, REALPART_EXPR, t, false)), c_common_truthvalue_conversion (location, - build_unary_op (location, IMAGPART_EXPR, t, 0)), + build_unary_op (location, IMAGPART_EXPR, t, false)), 0)); goto ret; } @@ -5827,15 +5861,11 @@ build_va_arg (location_t loc, tree expr, tree type) { /* Case 1: Not an array type. */ - /* Take the address, to get '&ap'. */ + /* Take the address, to get '&ap'. Note that &ap is not a va_list + type. */ mark_addressable (expr); expr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (expr)), expr); - /* Verify that &ap is still recognized as having va_list type. */ - tree canon_expr_type - = targetm.canonical_va_list_type (TREE_TYPE (expr)); - gcc_assert (canon_expr_type != NULL_TREE); - return build_va_arg_1 (loc, type, expr); } @@ -7803,8 +7833,7 @@ check_user_alignment (const_tree align, bool allow_zero) return i; } -/* - If in c++-11, check if the c++-11 alignment constraint with respect +/* If in c++-11, check if the c++-11 alignment constraint with respect to fundamental alignment (in [dcl.align]) are satisfied. If not in c++-11 mode, does nothing. @@ -7829,7 +7858,7 @@ check_cxx_fundamental_alignment_constraints (tree node, int flags) { bool alignment_too_large_p = false; - unsigned requested_alignment = 1U << align_log; + unsigned requested_alignment = (1U << align_log) * BITS_PER_UNIT; unsigned max_align = 0; if ((!(flags & ATTR_FLAG_CXX11) && !warn_cxx_compat) @@ -7839,49 +7868,26 @@ check_cxx_fundamental_alignment_constraints (tree node, if (cxx_fundamental_alignment_p (requested_alignment)) return true; - if (DECL_P (node)) + if (VAR_P (node)) { - if (TREE_STATIC (node)) - { - /* For file scope variables and static members, the target - supports alignments that are at most - MAX_OFILE_ALIGNMENT. */ - if (requested_alignment > (max_align = MAX_OFILE_ALIGNMENT)) - alignment_too_large_p = true; - } + if (TREE_STATIC (node) || DECL_EXTERNAL (node)) + /* For file scope variables and static members, the target supports + alignments that are at most MAX_OFILE_ALIGNMENT. */ + max_align = MAX_OFILE_ALIGNMENT; else - { -#ifdef BIGGEST_FIELD_ALIGNMENT -#define MAX_TARGET_FIELD_ALIGNMENT BIGGEST_FIELD_ALIGNMENT -#else -#define MAX_TARGET_FIELD_ALIGNMENT BIGGEST_ALIGNMENT -#endif - /* For non-static members, the target supports either - alignments that at most either BIGGEST_FIELD_ALIGNMENT - if it is defined or BIGGEST_ALIGNMENT. */ - max_align = MAX_TARGET_FIELD_ALIGNMENT; - if (TREE_CODE (node) == FIELD_DECL - && requested_alignment > (max_align = MAX_TARGET_FIELD_ALIGNMENT)) - alignment_too_large_p = true; -#undef MAX_TARGET_FIELD_ALIGNMENT - /* For stack variables, the target supports at most - MAX_STACK_ALIGNMENT. */ - else if (decl_function_context (node) != NULL - && requested_alignment > (max_align = MAX_STACK_ALIGNMENT)) - alignment_too_large_p = true; - } - } - else if (TYPE_P (node)) - { - /* Let's be liberal for types. */ - if (requested_alignment > (max_align = BIGGEST_ALIGNMENT)) + /* For stack variables, the target supports at most + MAX_STACK_ALIGNMENT. */ + max_align = MAX_STACK_ALIGNMENT; + if (requested_alignment > max_align) alignment_too_large_p = true; } + /* Let's be liberal for types and fields; don't limit their alignment any + more than check_user_alignment already did. */ if (alignment_too_large_p) pedwarn (input_location, OPT_Wattributes, "requested alignment %d is larger than %d", - requested_alignment, max_align); + requested_alignment / BITS_PER_UNIT, max_align / BITS_PER_UNIT); return !alignment_too_large_p; } @@ -10569,17 +10575,21 @@ fold_offsetof (tree expr) return convert (size_type_node, fold_offsetof_1 (expr)); } -/* Warn for A ?: C expressions (with B omitted) where A is a boolean +/* Warn for A ?: C expressions (with B omitted) where A is a boolean expression, because B will always be true. */ void -warn_for_omitted_condop (location_t location, tree cond) -{ - if (truth_value_p (TREE_CODE (cond))) - warning_at (location, OPT_Wparentheses, +warn_for_omitted_condop (location_t location, tree cond) +{ + /* In C++ template declarations it can happen that the type is dependent + and not yet known, thus TREE_TYPE (cond) == NULL_TREE. */ + if (truth_value_p (TREE_CODE (cond)) + || (TREE_TYPE (cond) != NULL_TREE + && TREE_CODE (TREE_TYPE (cond)) == BOOLEAN_TYPE)) + warning_at (location, OPT_Wparentheses, "the omitted middle operand in ?: will always be %<true%>, " "suggest explicit middle operand"); -} +} /* Give an error for storing into ARG, which is 'const'. USE indicates how ARG was being used. */ @@ -10874,7 +10884,9 @@ c_common_mark_addressable_vec (tree t) { while (handled_component_p (t)) t = TREE_OPERAND (t, 0); - if (!VAR_P (t) && TREE_CODE (t) != PARM_DECL) + if (!VAR_P (t) + && TREE_CODE (t) != PARM_DECL + && TREE_CODE (t) != COMPOUND_LITERAL_EXPR) return; TREE_ADDRESSABLE (t) = 1; } @@ -11547,7 +11559,7 @@ resolve_overloaded_builtin (location_t loc, tree function, /* Handle these 4 together so that they can fall through to the next case if the call is transformed to an _N variant. */ switch (orig_code) - { + { case BUILT_IN_ATOMIC_EXCHANGE: { if (resolve_overloaded_atomic_exchange (loc, function, params, @@ -11588,17 +11600,15 @@ resolve_overloaded_builtin (location_t loc, tree function, } default: gcc_unreachable (); - } - /* Fallthrough to the normal processing. */ + } } + /* FALLTHRU */ case BUILT_IN_ATOMIC_EXCHANGE_N: case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N: case BUILT_IN_ATOMIC_LOAD_N: case BUILT_IN_ATOMIC_STORE_N: - { - fetch_op = false; - /* Fallthrough to further processing. */ - } + fetch_op = false; + /* FALLTHRU */ case BUILT_IN_ATOMIC_ADD_FETCH_N: case BUILT_IN_ATOMIC_SUB_FETCH_N: case BUILT_IN_ATOMIC_AND_FETCH_N: @@ -11611,10 +11621,8 @@ resolve_overloaded_builtin (location_t loc, tree function, case BUILT_IN_ATOMIC_FETCH_NAND_N: case BUILT_IN_ATOMIC_FETCH_XOR_N: case BUILT_IN_ATOMIC_FETCH_OR_N: - { - orig_format = false; - /* Fallthru for parameter processing. */ - } + orig_format = false; + /* FALLTHRU */ case BUILT_IN_SYNC_FETCH_AND_ADD_N: case BUILT_IN_SYNC_FETCH_AND_SUB_N: case BUILT_IN_SYNC_FETCH_AND_OR_N: @@ -12265,7 +12273,7 @@ set_underlying_type (tree x) { if (x == error_mark_node) return; - if (DECL_IS_BUILTIN (x)) + if (DECL_IS_BUILTIN (x) && TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE) { if (TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; @@ -12409,9 +12417,7 @@ maybe_warn_bool_compare (location_t loc, enum tree_code code, tree op0, don't want to warn here. */ tree noncst = TREE_CODE (op0) == INTEGER_CST ? op1 : op0; /* Handle booleans promoted to integers. */ - if (CONVERT_EXPR_P (noncst) - && TREE_TYPE (noncst) == integer_type_node - && TREE_CODE (TREE_TYPE (TREE_OPERAND (noncst, 0))) == BOOLEAN_TYPE) + if (bool_promoted_to_int_p (noncst)) /* Warn. */; else if (TREE_CODE (TREE_TYPE (noncst)) != BOOLEAN_TYPE && !truth_value_p (TREE_CODE (noncst))) @@ -12835,6 +12841,19 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, return stv_nothing; } +/* Return the alignment of std::max_align_t. + + [support.types.layout] The type max_align_t is a POD type whose alignment + requirement is at least as great as that of every scalar type, and whose + alignment requirement is supported in every context. */ + +unsigned +max_align_t_align () +{ + return MAX (TYPE_ALIGN (long_long_integer_type_node), + TYPE_ALIGN (long_double_type_node)); +} + /* Return true iff ALIGN is an integral constant that is a fundamental alignment, as defined by [basic.align] in the c++-11 specifications. @@ -12843,14 +12862,12 @@ scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, [A fundamental alignment is represented by an alignment less than or equal to the greatest alignment supported by the implementation - in all contexts, which is equal to - alignof(max_align_t)]. */ + in all contexts, which is equal to alignof(max_align_t)]. */ bool -cxx_fundamental_alignment_p (unsigned align) +cxx_fundamental_alignment_p (unsigned align) { - return (align <= MAX (TYPE_ALIGN (long_long_integer_type_node), - TYPE_ALIGN (long_double_type_node))); + return (align <= max_align_t_align ()); } /* Return true if T is a pointer to a zero-sized aggregate. */ diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 42ce9698bdb..5bbf9511d08 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -863,6 +863,7 @@ extern bool keyword_begins_type_specifier (enum rid); extern bool keyword_is_storage_class_specifier (enum rid); extern bool keyword_is_type_qualifier (enum rid); extern bool keyword_is_decl_specifier (enum rid); +extern unsigned max_align_t_align (void); extern bool cxx_fundamental_alignment_p (unsigned); extern bool pointer_to_zero_sized_aggr_p (tree); extern bool diagnose_mismatched_attributes (tree, tree); @@ -963,7 +964,7 @@ extern tree build_real_imag_expr (location_t, enum tree_code, tree); /* These functions must be defined by each front-end which implements a variant of the C language. They are used in c-common.c. */ -extern tree build_unary_op (location_t, enum tree_code, tree, int); +extern tree build_unary_op (location_t, enum tree_code, tree, bool); extern tree build_binary_op (location_t, enum tree_code, tree, tree, int); extern tree perform_integral_promotions (tree); @@ -1132,35 +1133,9 @@ extern const char *cb_get_suggestion (cpp_reader *, const char *, extern GTY(()) string_concat_db *g_string_concat_db; -/* libcpp can calculate location information about a range of characters - within a string literal, but doing so is non-trivial. - - This class encapsulates such a source location, so that it can be - passed around (e.g. within c-format.c). It is effectively a deferred - call into libcpp. If needed by a diagnostic, the actual source_range - can be calculated by calling the get_range method. */ - -class substring_loc -{ - public: - substring_loc (location_t fmt_string_loc, tree string_type, - int caret_idx, int start_idx, int end_idx) - : m_fmt_string_loc (fmt_string_loc), m_string_type (string_type), - m_caret_idx (caret_idx), m_start_idx (start_idx), m_end_idx (end_idx) {} - - void set_caret_index (int caret_idx) { m_caret_idx = caret_idx; } - - const char *get_location (location_t *out_loc) const; - - location_t get_fmt_string_loc () const { return m_fmt_string_loc; } - - private: - location_t m_fmt_string_loc; - tree m_string_type; - int m_caret_idx; - int m_start_idx; - int m_end_idx; -}; +class substring_loc; +extern const char *c_get_substring_location (const substring_loc &substr_loc, + location_t *out_loc); /* In c-gimplify.c */ extern void c_genericize (tree); diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index ee4d233a08b..bb30829c987 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -54,6 +54,7 @@ static void builtin_define_stdint_macros (void); static void builtin_define_constants (const char *, tree); static void builtin_define_type_max (const char *, tree); static void builtin_define_type_minmax (const char *, const char *, tree); +static void builtin_define_type_width (const char *, tree, tree); static void builtin_define_float_constants (const char *, const char *, const char *, @@ -435,9 +436,15 @@ builtin_define_stdint_macros (void) builtin_define_constants ("__INTMAX_C", intmax_type_node); builtin_define_type_max ("__UINTMAX_MAX__", uintmax_type_node); builtin_define_constants ("__UINTMAX_C", uintmax_type_node); + builtin_define_type_width ("__INTMAX_WIDTH__", intmax_type_node, + uintmax_type_node); if (sig_atomic_type_node) - builtin_define_type_minmax ("__SIG_ATOMIC_MIN__", "__SIG_ATOMIC_MAX__", - sig_atomic_type_node); + { + builtin_define_type_minmax ("__SIG_ATOMIC_MIN__", "__SIG_ATOMIC_MAX__", + sig_atomic_type_node); + builtin_define_type_width ("__SIG_ATOMIC_WIDTH__", sig_atomic_type_node, + NULL_TREE); + } if (int8_type_node) builtin_define_type_max ("__INT8_MAX__", int8_type_node); if (int16_type_node) @@ -458,21 +465,32 @@ builtin_define_stdint_macros (void) { builtin_define_type_max ("__INT_LEAST8_MAX__", int_least8_type_node); builtin_define_constants ("__INT8_C", int_least8_type_node); + builtin_define_type_width ("__INT_LEAST8_WIDTH__", int_least8_type_node, + uint_least8_type_node); } if (int_least16_type_node) { builtin_define_type_max ("__INT_LEAST16_MAX__", int_least16_type_node); builtin_define_constants ("__INT16_C", int_least16_type_node); + builtin_define_type_width ("__INT_LEAST16_WIDTH__", + int_least16_type_node, + uint_least16_type_node); } if (int_least32_type_node) { builtin_define_type_max ("__INT_LEAST32_MAX__", int_least32_type_node); builtin_define_constants ("__INT32_C", int_least32_type_node); + builtin_define_type_width ("__INT_LEAST32_WIDTH__", + int_least32_type_node, + uint_least32_type_node); } if (int_least64_type_node) { builtin_define_type_max ("__INT_LEAST64_MAX__", int_least64_type_node); builtin_define_constants ("__INT64_C", int_least64_type_node); + builtin_define_type_width ("__INT_LEAST64_WIDTH__", + int_least64_type_node, + uint_least64_type_node); } if (uint_least8_type_node) { @@ -495,13 +513,29 @@ builtin_define_stdint_macros (void) builtin_define_constants ("__UINT64_C", uint_least64_type_node); } if (int_fast8_type_node) - builtin_define_type_max ("__INT_FAST8_MAX__", int_fast8_type_node); + { + builtin_define_type_max ("__INT_FAST8_MAX__", int_fast8_type_node); + builtin_define_type_width ("__INT_FAST8_WIDTH__", int_fast8_type_node, + uint_fast8_type_node); + } if (int_fast16_type_node) - builtin_define_type_max ("__INT_FAST16_MAX__", int_fast16_type_node); + { + builtin_define_type_max ("__INT_FAST16_MAX__", int_fast16_type_node); + builtin_define_type_width ("__INT_FAST16_WIDTH__", int_fast16_type_node, + uint_fast16_type_node); + } if (int_fast32_type_node) - builtin_define_type_max ("__INT_FAST32_MAX__", int_fast32_type_node); + { + builtin_define_type_max ("__INT_FAST32_MAX__", int_fast32_type_node); + builtin_define_type_width ("__INT_FAST32_WIDTH__", int_fast32_type_node, + uint_fast32_type_node); + } if (int_fast64_type_node) - builtin_define_type_max ("__INT_FAST64_MAX__", int_fast64_type_node); + { + builtin_define_type_max ("__INT_FAST64_MAX__", int_fast64_type_node); + builtin_define_type_width ("__INT_FAST64_WIDTH__", int_fast64_type_node, + uint_fast64_type_node); + } if (uint_fast8_type_node) builtin_define_type_max ("__UINT_FAST8_MAX__", uint_fast8_type_node); if (uint_fast16_type_node) @@ -511,7 +545,11 @@ builtin_define_stdint_macros (void) if (uint_fast64_type_node) builtin_define_type_max ("__UINT_FAST64_MAX__", uint_fast64_type_node); if (intptr_type_node) - builtin_define_type_max ("__INTPTR_MAX__", intptr_type_node); + { + builtin_define_type_max ("__INTPTR_MAX__", intptr_type_node); + builtin_define_type_width ("__INTPTR_WIDTH__", intptr_type_node, + uintptr_type_node); + } if (uintptr_type_node) builtin_define_type_max ("__UINTPTR_MAX__", uintptr_type_node); } @@ -906,6 +944,12 @@ c_cpp_builtins (cpp_reader *pfile) cpp_define (pfile, "__cpp_transactional_memory=210500"); if (flag_sized_deallocation) cpp_define (pfile, "__cpp_sized_deallocation=201309"); + if (aligned_new_threshhold) + { + cpp_define (pfile, "__cpp_aligned_new=201606"); + cpp_define_formatted (pfile, "__STDCPP_DEFAULT_NEW_ALIGNMENT__=%d", + aligned_new_threshhold); + } } /* Note that we define this for C as well, so that we know if __attribute__((cleanup)) will interface with EH. */ @@ -946,6 +990,24 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_type_max ("__PTRDIFF_MAX__", ptrdiff_type_node); builtin_define_type_max ("__SIZE_MAX__", size_type_node); + /* These are needed for TS 18661-1. */ + builtin_define_type_width ("__SCHAR_WIDTH__", signed_char_type_node, + unsigned_char_type_node); + builtin_define_type_width ("__SHRT_WIDTH__", short_integer_type_node, + short_unsigned_type_node); + builtin_define_type_width ("__INT_WIDTH__", integer_type_node, + unsigned_type_node); + builtin_define_type_width ("__LONG_WIDTH__", long_integer_type_node, + long_unsigned_type_node); + builtin_define_type_width ("__LONG_LONG_WIDTH__", + long_long_integer_type_node, + long_long_unsigned_type_node); + builtin_define_type_width ("__WCHAR_WIDTH__", underlying_wchar_type_node, + NULL_TREE); + builtin_define_type_width ("__WINT_WIDTH__", wint_type_node, NULL_TREE); + builtin_define_type_width ("__PTRDIFF_WIDTH__", ptrdiff_type_node, NULL_TREE); + builtin_define_type_width ("__SIZE_WIDTH__", size_type_node, NULL_TREE); + if (c_dialect_cxx ()) for (i = 0; i < NUM_INT_N_ENTS; i ++) if (int_n_enabled_p[i]) @@ -1693,4 +1755,15 @@ builtin_define_type_minmax (const char *min_macro, const char *max_macro, } } +/* Define WIDTH_MACRO for the width of TYPE. If TYPE2 is not NULL, + both types must have the same width. */ + +static void +builtin_define_type_width (const char *width_macro, tree type, tree type2) +{ + if (type2 != NULL_TREE) + gcc_assert (TYPE_PRECISION (type) == TYPE_PRECISION (type2)); + builtin_define_with_int_value (width_macro, TYPE_PRECISION (type)); +} + #include "gt-c-family-c-cppbuiltin.h" diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index ad434f810ce..bf39ee06e79 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -30,7 +30,9 @@ along with GCC; see the file COPYING3. If not see #include "langhooks.h" #include "c-format.h" #include "diagnostic.h" +#include "substring-locations.h" #include "selftest.h" +#include "builtins.h" /* Handle attributes associated with format checking. */ @@ -67,162 +69,6 @@ static int first_target_format_type; static const char *format_name (int format_num); static int format_flags (int format_num); -/* Emit a warning governed by option OPT, using GMSGID as the format - string and AP as its arguments. - - Attempt to obtain precise location information within a string - literal from FMT_LOC. - - Case 1: if substring location is available, and is within the range of - the format string itself, the primary location of the - diagnostic is the substring range obtained from FMT_LOC, with the - caret at the *end* of the substring range. - - For example: - - test.c:90:10: warning: problem with '%i' here [-Wformat=] - printf ("hello %i", msg); - ~^ - - Case 2: if the substring location is available, but is not within - the range of the format string, the primary location is that of the - format string, and an note is emitted showing the substring location. - - For example: - test.c:90:10: warning: problem with '%i' here [-Wformat=] - printf("hello " INT_FMT " world", msg); - ^~~~~~~~~~~~~~~~~~~~~~~~~ - test.c:19: note: format string is defined here - #define INT_FMT "%i" - ~^ - - Case 3: if precise substring information is unavailable, the primary - location is that of the whole string passed to FMT_LOC's constructor. - For example: - - test.c:90:10: warning: problem with '%i' here [-Wformat=] - printf(fmt, msg); - ^~~ - - For each of cases 1-3, if param_range is non-NULL, then it is used - as a secondary range within the warning. For example, here it - is used with case 1: - - test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=] - printf ("foo %s bar", long_i + long_j); - ~^ ~~~~~~~~~~~~~~~ - - and here with case 2: - - test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=] - printf ("foo " STR_FMT " bar", long_i + long_j); - ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ - test.c:89:16: note: format string is defined here - #define STR_FMT "%s" - ~^ - - and with case 3: - - test.c:90:10: warning: '%i' here, but arg 2 is "const char *' [-Wformat=] - printf(fmt, msg); - ^~~ ~~~ - - If CORRECTED_SUBSTRING is non-NULL, use it for cases 1 and 2 to provide - a fix-it hint, suggesting that it should replace the text within the - substring range. For example: - - test.c:90:10: warning: problem with '%i' here [-Wformat=] - printf ("hello %i", msg); - ~^ - %s - - Return true if a warning was emitted, false otherwise. */ - -ATTRIBUTE_GCC_DIAG (5,0) -static bool -format_warning_va (const substring_loc &fmt_loc, source_range *param_range, - const char *corrected_substring, - int opt, const char *gmsgid, va_list *ap) -{ - bool substring_within_range = false; - location_t primary_loc; - location_t fmt_substring_loc = UNKNOWN_LOCATION; - source_range fmt_loc_range - = get_range_from_loc (line_table, fmt_loc.get_fmt_string_loc ()); - const char *err = fmt_loc.get_location (&fmt_substring_loc); - source_range fmt_substring_range - = get_range_from_loc (line_table, fmt_substring_loc); - if (err) - /* Case 3: unable to get substring location. */ - primary_loc = fmt_loc.get_fmt_string_loc (); - else - { - if (fmt_substring_range.m_start >= fmt_loc_range.m_start - && fmt_substring_range.m_finish <= fmt_loc_range.m_finish) - /* Case 1. */ - { - substring_within_range = true; - primary_loc = fmt_substring_loc; - } - else - /* Case 2. */ - { - substring_within_range = false; - primary_loc = fmt_loc.get_fmt_string_loc (); - } - } - - rich_location richloc (line_table, primary_loc); - - if (param_range) - { - location_t param_loc = make_location (param_range->m_start, - param_range->m_start, - param_range->m_finish); - richloc.add_range (param_loc, false); - } - - if (!err && corrected_substring && substring_within_range) - richloc.add_fixit_replace (fmt_substring_range, corrected_substring); - - diagnostic_info diagnostic; - diagnostic_set_info (&diagnostic, gmsgid, ap, &richloc, DK_WARNING); - diagnostic.option_index = opt; - bool warned = report_diagnostic (&diagnostic); - - if (!err && fmt_substring_loc && !substring_within_range) - /* Case 2. */ - if (warned) - { - rich_location substring_richloc (line_table, fmt_substring_loc); - if (corrected_substring) - substring_richloc.add_fixit_replace (fmt_substring_range, - corrected_substring); - inform_at_rich_loc (&substring_richloc, - "format string is defined here"); - } - - return warned; -} - -/* Variadic call to format_warning_va. */ - -ATTRIBUTE_GCC_DIAG (5,0) -static bool -format_warning_at_substring (const substring_loc &fmt_loc, - source_range *param_range, - const char *corrected_substring, - int opt, const char *gmsgid, ...) -{ - va_list ap; - va_start (ap, gmsgid); - bool warned = format_warning_va (fmt_loc, param_range, corrected_substring, - opt, gmsgid, &ap); - va_end (ap); - - return warned; -} - /* Emit a warning as per format_warning_va, but construct the substring_loc for the character at offset (CHAR_IDX - 1) within a string constant FORMAT_STRING_CST at FMT_STRING_LOC. */ @@ -1148,12 +994,16 @@ static const format_flag_spec *get_flag_spec (const format_flag_spec *, static void check_format_types (const substring_loc &fmt_loc, format_wanted_type *, - const format_kind_info *fki); + const format_kind_info *fki, + int offset_to_type_start, + char conversion_char); static void format_type_warning (const substring_loc &fmt_loc, source_range *param_range, format_wanted_type *, tree, tree, - const format_kind_info *fki); + const format_kind_info *fki, + int offset_to_type_start, + char conversion_char); /* Decode a format type from a string, returning the type, or format_type_error if not valid, in which case the caller should print an @@ -1212,9 +1062,17 @@ check_function_format (tree attrs, int nargs, tree *argarray) params = tree_cons (NULL_TREE, argarray[i], params); check_format_info (&info, params); } + + /* Attempt to detect whether the current function might benefit + from the format attribute if the called function is decorated + with it. Avoid using calls with string literal formats for + guidance since those are unlikely to be viable candidates. */ if (warn_suggest_attribute_format && info.first_arg_num == 0 && (format_types[info.format_type].flags - & (int) FMT_FLAG_ARG_CONVERT)) + & (int) FMT_FLAG_ARG_CONVERT) + /* c_strlen will fail for a function parameter but succeed + for a literal or constant array. */ + && !c_strlen (argarray[info.format_num - 1], 1)) { tree c; for (c = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl)); @@ -1242,8 +1100,9 @@ check_function_format (tree attrs, int nargs, tree *argarray) break; } if (args != 0) - warning (OPT_Wsuggest_attribute_format, "function might " - "be possible candidate for %qs format attribute", + warning (OPT_Wsuggest_attribute_format, "function %qD " + "might be a candidate for %qs format attribute", + current_function_decl, format_types[info.format_type].name); } } @@ -1924,7 +1783,9 @@ class argument_parser tree ¶ms, const int alloc_flag, const char * const format_start, - location_t fmt_param_loc); + const char * const type_start, + location_t fmt_param_loc, + char conversion_char); private: const function_format_info *const info; @@ -2500,20 +2361,12 @@ argument_parser::find_format_char_info (char format_char) ++fci; if (fci->format_chars == 0) { - if (ISGRAPH (format_char)) - format_warning_at_char (format_string_loc, format_string_cst, - format_chars - orig_format_chars, - OPT_Wformat_, - "unknown conversion type character" - " %qc in format", - format_char); - else - format_warning_at_char (format_string_loc, format_string_cst, - format_chars - orig_format_chars, - OPT_Wformat_, - "unknown conversion type character" - " 0x%x in format", - format_char); + format_warning_at_char (format_string_loc, format_string_cst, + format_chars - orig_format_chars, + OPT_Wformat_, + "unknown conversion type character" + " %qc in format", + format_char); return NULL; } @@ -2705,7 +2558,9 @@ check_argument_type (const format_char_info *fci, tree ¶ms, const int alloc_flag, const char * const format_start, - location_t fmt_param_loc) + const char * const type_start, + location_t fmt_param_loc, + char conversion_char) { if (info->first_arg_num == 0) return true; @@ -2811,7 +2666,10 @@ check_argument_type (const format_char_info *fci, substring_loc fmt_loc (fmt_param_loc, TREE_TYPE (format_string_cst), offset_to_format_end, offset_to_format_start, offset_to_format_end); - check_format_types (fmt_loc, first_wanted_type, fki); + ptrdiff_t offset_to_type_start = type_start - orig_format_chars; + check_format_types (fmt_loc, first_wanted_type, fki, + offset_to_type_start, + conversion_char); } return true; @@ -2890,6 +2748,13 @@ check_format_info_main (format_check_results *res, arg_parser.handle_alloc_chars (); + /* The rest of the conversion specification is the length modifier + (if any), and the conversion specifier, so this is where the + type information starts. If we need to issue a suggestion + about a type mismatch, then we should preserve everything up + to here. */ + const char *type_start = format_chars; + /* Read any length modifier, if this kind of format has them. */ const length_modifier len_modifier = arg_parser.read_any_length_modifier (); @@ -2947,7 +2812,9 @@ check_format_info_main (format_check_results *res, suppressed, arg_num, params, alloc_flag, - format_start, fmt_param_loc)) + format_start, type_start, + fmt_param_loc, + format_char)) return; } @@ -2967,11 +2834,58 @@ check_format_info_main (format_check_results *res, } /* Check the argument types from a single format conversion (possibly - including width and precision arguments). FMT_LOC is the - location of the format conversion. */ + including width and precision arguments). + + FMT_LOC is the location of the format conversion. + + TYPES is a singly-linked list expressing the parts of the format + conversion that expect argument types, and the arguments they + correspond to. + + OFFSET_TO_TYPE_START is the offset within the execution-charset encoded + format string to where type information begins for the conversion + (the length modifier and conversion specifier). + + CONVERSION_CHAR is the user-provided conversion specifier. + + For example, given: + + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + + then FMT_LOC covers this range: + + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^^^^^^^^ + + and TYPES in this case is a three-entry singly-linked list consisting of: + (1) the check for the field width here: + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^ ^^^^ + against arg3, and + (2) the check for the field precision here: + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^ ^^^^ + against arg4, and + (3) the check for the length modifier and conversion char here: + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^^^ ^^^^ + against arg5. + + OFFSET_TO_TYPE_START is 13, the offset to the "lld" within the + STRING_CST: + + 0000000000111111111122 + 0123456789012345678901 + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^ ^ + | ` CONVERSION_CHAR: 'd' + type starts here. */ + static void check_format_types (const substring_loc &fmt_loc, - format_wanted_type *types, const format_kind_info *fki) + format_wanted_type *types, const format_kind_info *fki, + int offset_to_type_start, + char conversion_char) { for (; types != 0; types = types->next) { @@ -2998,7 +2912,8 @@ check_format_types (const substring_loc &fmt_loc, cur_param = types->param; if (!cur_param) { - format_type_warning (fmt_loc, NULL, types, wanted_type, NULL, fki); + format_type_warning (fmt_loc, NULL, types, wanted_type, NULL, fki, + offset_to_type_start, conversion_char); continue; } @@ -3083,7 +2998,8 @@ check_format_types (const substring_loc &fmt_loc, else { format_type_warning (fmt_loc, param_range_ptr, - types, wanted_type, orig_cur_type, fki); + types, wanted_type, orig_cur_type, fki, + offset_to_type_start, conversion_char); break; } } @@ -3152,7 +3068,8 @@ check_format_types (const substring_loc &fmt_loc, continue; /* Now we have a type mismatch. */ format_type_warning (fmt_loc, param_range_ptr, types, - wanted_type, orig_cur_type, fki); + wanted_type, orig_cur_type, fki, + offset_to_type_start, conversion_char); } } @@ -3217,16 +3134,47 @@ test_get_modifier_for_format_len () #endif /* CHECKING_P */ -/* Generate a string containing the format string that should be - used to format arguments of type ARG_TYPE within FKI (effectively - the inverse of the checking code). +/* Determine if SPEC_TYPE and ARG_TYPE are sufficiently similar for a + format_type_detail using SPEC_TYPE to be offered as a suggestion for + Wformat type errors where the argument has type ARG_TYPE. */ + +static bool +matching_type_p (tree spec_type, tree arg_type) +{ + gcc_assert (spec_type); + gcc_assert (arg_type); + + spec_type = TYPE_CANONICAL (spec_type); + arg_type = TYPE_CANONICAL (arg_type); + + if (TREE_CODE (spec_type) == INTEGER_TYPE + && TREE_CODE (arg_type) == INTEGER_TYPE + && (TYPE_UNSIGNED (spec_type) + ? spec_type == c_common_unsigned_type (arg_type) + : spec_type == c_common_signed_type (arg_type))) + return true; + + return spec_type == arg_type; +} + +/* Subroutine of get_format_for_type. + + Generate a string containing the length modifier and conversion specifier + that should be used to format arguments of type ARG_TYPE within FKI + (effectively the inverse of the checking code). + + If CONVERSION_CHAR is not zero (the first pass), the resulting suggestion + is required to use it, for correcting bogus length modifiers. + If CONVERSION_CHAR is zero (the second pass), then allow any suggestion + that matches ARG_TYPE. If successful, returns a non-NULL string which should be freed - by the called. + by the caller. Otherwise, returns NULL. */ static char * -get_format_for_type (const format_kind_info *fki, tree arg_type) +get_format_for_type_1 (const format_kind_info *fki, tree arg_type, + char conversion_char) { gcc_assert (arg_type); @@ -3235,6 +3183,10 @@ get_format_for_type (const format_kind_info *fki, tree arg_type) spec->format_chars; spec++) { + if (conversion_char) + if (!strchr (spec->format_chars, conversion_char)) + continue; + tree effective_arg_type = deref_n_times (arg_type, spec->pointer_count); if (!effective_arg_type) @@ -3244,8 +3196,7 @@ get_format_for_type (const format_kind_info *fki, tree arg_type) const format_type_detail *ftd = &spec->types[i]; if (!ftd->type) continue; - if (TYPE_CANONICAL (*ftd->type) - == TYPE_CANONICAL (effective_arg_type)) + if (matching_type_p (*ftd->type, effective_arg_type)) { const char *len_modifier = get_modifier_for_format_len (fki->length_char_specs, @@ -3253,15 +3204,168 @@ get_format_for_type (const format_kind_info *fki, tree arg_type) if (!len_modifier) len_modifier = ""; - return xasprintf ("%%%s%c", - len_modifier, - spec->format_chars[0]); + if (conversion_char) + /* We found a match, using the given conversion char - the + length modifier was incorrect (or absent). + Provide a suggestion using the conversion char with the + correct length modifier for the type. */ + return xasprintf ("%s%c", len_modifier, conversion_char); + else + /* 2nd pass: no match was possible using the user-provided + conversion char, but we do have a match without using it. + Provide a suggestion using the first conversion char + listed for the given type. */ + return xasprintf ("%s%c", len_modifier, spec->format_chars[0]); } } } + return NULL; } +/* Generate a string containing the length modifier and conversion specifier + that should be used to format arguments of type ARG_TYPE within FKI + (effectively the inverse of the checking code). + + If successful, returns a non-NULL string which should be freed + by the caller. + Otherwise, returns NULL. */ + +static char * +get_format_for_type (const format_kind_info *fki, tree arg_type, + char conversion_char) +{ + gcc_assert (arg_type); + gcc_assert (conversion_char); + + /* First pass: look for a format_char_info containing CONVERSION_CHAR + If we find one, then presumably the length modifier was incorrect + (or absent). */ + char *result = get_format_for_type_1 (fki, arg_type, conversion_char); + if (result) + return result; + + /* Second pass: we didn't find a match for CONVERSION_CHAR, so try + matching just on the type. */ + return get_format_for_type_1 (fki, arg_type, '\0'); +} + +/* Attempt to get a string for use as a replacement fix-it hint for the + source range in FMT_LOC. + + Preserve all of the text within the range of FMT_LOC up to + OFFSET_TO_TYPE_START, replacing the rest with an appropriate + length modifier and conversion specifier for ARG_TYPE, attempting + to keep the user-provided CONVERSION_CHAR if possible. + + For example, given a long vs long long mismatch for arg5 here: + + 000000000111111111122222222223333333333| + 123456789012345678901234567890123456789` column numbers + 0000000000111111111122| + 0123456789012345678901` string offsets + V~~~~~~~~ : range of FMT_LOC, from cols 23-31 + sprintf (d, "before %-+*.*lld after", arg3, arg4, arg5); + ^ ^ + | ` CONVERSION_CHAR: 'd' + type starts here + + where OFFSET_TO_TYPE_START is 13 (the offset to the "lld" within the + STRING_CST), where the user provided: + %-+*.*lld + the result (assuming "long" argument 5) should be: + %-+*.*ld + + If successful, returns a non-NULL string which should be freed + by the caller. + Otherwise, returns NULL. */ + +static char * +get_corrected_substring (const substring_loc &fmt_loc, + format_wanted_type *type, tree arg_type, + const format_kind_info *fki, + int offset_to_type_start, char conversion_char) +{ + /* Attempt to provide hints for argument types, but not for field widths + and precisions. */ + if (!arg_type) + return NULL; + if (type->kind != CF_KIND_FORMAT) + return NULL; + + /* Locate the current code within the source range, rejecting + any awkward cases where the format string occupies more than + one line. + Lookup the place where the type starts (including any length + modifiers), getting it as the caret location. */ + substring_loc type_loc (fmt_loc); + type_loc.set_caret_index (offset_to_type_start); + + location_t fmt_substring_loc; + const char *err = type_loc.get_location (&fmt_substring_loc); + if (err) + return NULL; + + source_range fmt_substring_range + = get_range_from_loc (line_table, fmt_substring_loc); + + expanded_location caret + = expand_location_to_spelling_point (fmt_substring_loc); + expanded_location start + = expand_location_to_spelling_point (fmt_substring_range.m_start); + expanded_location finish + = expand_location_to_spelling_point (fmt_substring_range.m_finish); + if (caret.file != start.file) + return NULL; + if (start.file != finish.file) + return NULL; + if (caret.line != start.line) + return NULL; + if (start.line != finish.line) + return NULL; + if (start.column > caret.column) + return NULL; + if (start.column > finish.column) + return NULL; + if (caret.column > finish.column) + return NULL; + + int line_width; + const char *line = location_get_source_line (start.file, start.line, + &line_width); + if (line == NULL) + return NULL; + + /* If we got this far, then we have the line containing the + existing conversion specification. + + Generate a trimmed copy, containing the prefix part of the conversion + specification, up to the (but not including) the length modifier. + In the above example, this would be "%-+*.*". */ + const char *current_content = line + start.column - 1; + int length_up_to_type = caret.column - start.column; + char *prefix = xstrndup (current_content, length_up_to_type); + + /* Now attempt to generate a suggestion for the rest of the specification + (length modifier and conversion char), based on ARG_TYPE and + CONVERSION_CHAR. + In the above example, this would be "ld". */ + char *format_for_type = get_format_for_type (fki, arg_type, conversion_char); + if (!format_for_type) + { + free (prefix); + return NULL; + } + + /* Success. Generate the resulting suggestion for the whole range of + FMT_LOC by concatenating the two strings. + In the above example, this would be "%-+*.*ld". */ + char *result = concat (prefix, format_for_type, NULL); + free (format_for_type); + free (prefix); + return result; +} + /* Give a warning about a format argument of different type from that expected. The range of the diagnostic is taken from WHOLE_FMT_LOC; the caret location is based on the location of the char at TYPE->offset_loc. @@ -3271,13 +3375,36 @@ get_format_for_type (const format_kind_info *fki, tree arg_type) precision"), the placement in the format string, a possibly more friendly name of WANTED_TYPE, and the number of pointer dereferences are taken from TYPE. ARG_TYPE is the type of the actual argument, - or NULL if it is missing. */ + or NULL if it is missing. + + OFFSET_TO_TYPE_START is the offset within the execution-charset encoded + format string to where type information begins for the conversion + (the length modifier and conversion specifier). + CONVERSION_CHAR is the user-provided conversion specifier. + + For example, given a type mismatch for argument 5 here: + + 00000000011111111112222222222333333333344444444445555555555| + 12345678901234567890123456789012345678901234567890123456789` column numbers + 0000000000111111111122| + 0123456789012345678901` offsets within STRING_CST + V~~~~~~~~ : range of WHOLE_FMT_LOC, from cols 23-31 + sprintf (d, "before %-+*.*lld after", int_expr, int_expr, long_expr); + ^ ^ ^~~~~~~~~ + | ` CONVERSION_CHAR: 'd' *PARAM_RANGE + type starts here + + OFFSET_TO_TYPE_START is 13, the offset to the "lld" within the + STRING_CST. */ + static void format_type_warning (const substring_loc &whole_fmt_loc, source_range *param_range, format_wanted_type *type, tree wanted_type, tree arg_type, - const format_kind_info *fki) + const format_kind_info *fki, + int offset_to_type_start, + char conversion_char) { enum format_specifier_kind kind = type->kind; const char *wanted_type_name = type->wanted_type_name; @@ -3324,18 +3451,18 @@ format_type_warning (const substring_loc &whole_fmt_loc, substring_loc fmt_loc (whole_fmt_loc); fmt_loc.set_caret_index (type->offset_loc - 1); - /* Attempt to provide hints for argument types, but not for field widths - and precisions. */ - char *format_for_type = NULL; - if (arg_type && kind == CF_KIND_FORMAT) - format_for_type = get_format_for_type (fki, arg_type); + /* Get a string for use as a replacement fix-it hint for the range in + fmt_loc, or NULL. */ + char *corrected_substring + = get_corrected_substring (fmt_loc, type, arg_type, fki, + offset_to_type_start, conversion_char); if (wanted_type_name) { if (arg_type) format_warning_at_substring (fmt_loc, param_range, - format_for_type, OPT_Wformat_, + corrected_substring, OPT_Wformat_, "%s %<%s%.*s%> expects argument of type %<%s%s%>, " "but argument %d has type %qT", gettext (kind_descriptions[kind]), @@ -3345,7 +3472,7 @@ format_type_warning (const substring_loc &whole_fmt_loc, else format_warning_at_substring (fmt_loc, param_range, - format_for_type, OPT_Wformat_, + corrected_substring, OPT_Wformat_, "%s %<%s%.*s%> expects a matching %<%s%s%> argument", gettext (kind_descriptions[kind]), (kind == CF_KIND_FORMAT ? "%" : ""), @@ -3356,7 +3483,7 @@ format_type_warning (const substring_loc &whole_fmt_loc, if (arg_type) format_warning_at_substring (fmt_loc, param_range, - format_for_type, OPT_Wformat_, + corrected_substring, OPT_Wformat_, "%s %<%s%.*s%> expects argument of type %<%T%s%>, " "but argument %d has type %qT", gettext (kind_descriptions[kind]), @@ -3366,14 +3493,14 @@ format_type_warning (const substring_loc &whole_fmt_loc, else format_warning_at_substring (fmt_loc, param_range, - format_for_type, OPT_Wformat_, + corrected_substring, OPT_Wformat_, "%s %<%s%.*s%> expects a matching %<%T%s%> argument", gettext (kind_descriptions[kind]), (kind == CF_KIND_FORMAT ? "%" : ""), format_length, format_start, wanted_type, p); } - free (format_for_type); + free (corrected_substring); } @@ -3912,25 +4039,28 @@ get_info (const char *name) return fki; } -/* Verify that get_format_for_type (FKI, TYPE) is EXPECTED_FORMAT. */ +/* Verify that get_format_for_type (FKI, TYPE, CONVERSION_CHAR) + is EXPECTED_FORMAT. */ static void assert_format_for_type_streq (const location &loc, const format_kind_info *fki, - const char *expected_format, tree type) + const char *expected_format, tree type, + char conversion_char) { gcc_assert (fki); gcc_assert (expected_format); gcc_assert (type); - char *actual_format = get_format_for_type (fki, type); + char *actual_format = get_format_for_type (fki, type, conversion_char); ASSERT_STREQ_AT (loc, expected_format, actual_format); free (actual_format); } /* Selftests for get_format_for_type. */ -#define ASSERT_FORMAT_FOR_TYPE_STREQ(EXPECTED_FORMAT, TYPE) \ - assert_format_for_type_streq (SELFTEST_LOCATION, (fki), (EXPECTED_FORMAT), (TYPE)) +#define ASSERT_FORMAT_FOR_TYPE_STREQ(EXPECTED_FORMAT, TYPE, CONVERSION_CHAR) \ + assert_format_for_type_streq (SELFTEST_LOCATION, (fki), (EXPECTED_FORMAT), \ + (TYPE), (CONVERSION_CHAR)) /* Selftest for get_format_for_type for "printf"-style functions. */ @@ -3940,15 +4070,34 @@ test_get_format_for_type_printf () const format_kind_info *fki = get_info ("gnu_printf"); ASSERT_NE (fki, NULL); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%f", double_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%Lf", long_double_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%d", integer_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%o", unsigned_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%ld", long_integer_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%lo", long_unsigned_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%lld", long_long_integer_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%llo", long_long_unsigned_type_node); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%s", build_pointer_type (char_type_node)); + ASSERT_FORMAT_FOR_TYPE_STREQ ("f", double_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("Lf", long_double_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("f", double_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("Lf", long_double_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("f", double_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("Lf", long_double_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("f", double_type_node, 'X'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("Lf", long_double_type_node, 'X'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("d", integer_type_node, 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("i", integer_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("o", integer_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("x", integer_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("X", integer_type_node, 'X'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("d", unsigned_type_node, 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("i", unsigned_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("o", unsigned_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("x", unsigned_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("X", unsigned_type_node, 'X'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("ld", long_integer_type_node, 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("li", long_integer_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lx", long_integer_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lo", long_unsigned_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lx", long_unsigned_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lld", long_long_integer_type_node, 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lli", long_long_integer_type_node, 'i'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("llo", long_long_unsigned_type_node, 'o'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("llx", long_long_unsigned_type_node, 'x'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("s", build_pointer_type (char_type_node), 'i'); } /* Selftest for get_format_for_type for "scanf"-style functions. */ @@ -3958,18 +4107,18 @@ test_get_format_for_type_scanf () { const format_kind_info *fki = get_info ("gnu_scanf"); ASSERT_NE (fki, NULL); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%d", build_pointer_type (integer_type_node)); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%u", build_pointer_type (unsigned_type_node)); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%ld", - build_pointer_type (long_integer_type_node)); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%lu", - build_pointer_type (long_unsigned_type_node)); + ASSERT_FORMAT_FOR_TYPE_STREQ ("d", build_pointer_type (integer_type_node), 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("u", build_pointer_type (unsigned_type_node), 'u'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("ld", + build_pointer_type (long_integer_type_node), 'd'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("lu", + build_pointer_type (long_unsigned_type_node), 'u'); ASSERT_FORMAT_FOR_TYPE_STREQ - ("%lld", build_pointer_type (long_long_integer_type_node)); + ("lld", build_pointer_type (long_long_integer_type_node), 'd'); ASSERT_FORMAT_FOR_TYPE_STREQ - ("%llu", build_pointer_type (long_long_unsigned_type_node)); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%e", build_pointer_type (float_type_node)); - ASSERT_FORMAT_FOR_TYPE_STREQ ("%le", build_pointer_type (double_type_node)); + ("llu", build_pointer_type (long_long_unsigned_type_node), 'u'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("e", build_pointer_type (float_type_node), 'e'); + ASSERT_FORMAT_FOR_TYPE_STREQ ("le", build_pointer_type (double_type_node), 'e'); } #undef ASSERT_FORMAT_FOR_TYPE_STREQ diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 1691c40f11a..5ccb62eea50 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -199,6 +199,11 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, error_at (loc, "invalid expression type for %<#pragma omp atomic%>"); return error_mark_node; } + if (TYPE_ATOMIC (type)) + { + error_at (loc, "%<_Atomic%> expression in %<#pragma omp atomic%>"); + return error_mark_node; + } if (opcode == RDIV_EXPR) opcode = TRUNC_DIV_EXPR; @@ -207,7 +212,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, /* Take and save the address of the lhs. From then on we'll reference it via indirection. */ - addr = build_unary_op (loc, ADDR_EXPR, lhs, 0); + addr = build_unary_op (loc, ADDR_EXPR, lhs, false); if (addr == error_mark_node) return error_mark_node; if (!test) @@ -298,14 +303,14 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, loc, x, NULL_TREE); if (rhs1 && rhs1 != lhs) { - tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, 0); + tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, false); if (rhs1addr == error_mark_node) return error_mark_node; x = omit_one_operand_loc (loc, type, x, rhs1addr); } if (lhs1 && lhs1 != lhs) { - tree lhs1addr = build_unary_op (loc, ADDR_EXPR, lhs1, 0); + tree lhs1addr = build_unary_op (loc, ADDR_EXPR, lhs1, false); if (lhs1addr == error_mark_node) return error_mark_node; if (code == OMP_ATOMIC_CAPTURE_OLD) @@ -320,7 +325,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code, } else if (rhs1 && rhs1 != lhs) { - tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, 0); + tree rhs1addr = build_unary_op (loc, ADDR_EXPR, rhs1, false); if (rhs1addr == error_mark_node) return error_mark_node; x = omit_one_operand_loc (loc, type, x, rhs1addr); @@ -480,6 +485,14 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, error_at (elocus, "invalid type for iteration variable %qE", decl); fail = true; } + else if (TYPE_ATOMIC (TREE_TYPE (decl))) + { + error_at (elocus, "%<_Atomic%> iteration variable %qE", decl); + fail = true; + /* _Atomic iterator confuses stuff too much, so we risk ICE + trying to diagnose it further. */ + continue; + } /* In the case of "for (int i = 0...)", init will be a decl. It should have a DECL_INITIAL that we can turn into an assignment. */ diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index a5358ededb3..c55c7c34961 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -271,6 +271,26 @@ Waddress C ObjC C++ ObjC++ Var(warn_address) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall) Warn about suspicious uses of memory addresses. +Enum +Name(warn_aligned_new_level) Type(int) UnknownError(argument %qs to %<-Waligned-new%> not recognized) + +EnumValue +Enum(warn_aligned_new_level) String(none) Value(0) + +EnumValue +Enum(warn_aligned_new_level) String(global) Value(1) + +EnumValue +Enum(warn_aligned_new_level) String(all) Value(2) + +Waligned-new +C++ ObjC++ Alias(Waligned-new=,global,none) +Warn about 'new' of type with extended alignment without -faligned-new. + +Waligned-new= +C++ ObjC++ Var(warn_aligned_new) Enum(warn_aligned_new_level) Joined Warning LangEnabledBy(C++ ObjC++,Wall,1,0) +-Waligned-new=all Warn even if 'new' uses a class member allocation function. + Wall C ObjC C++ ObjC++ Warning Enable most warning messages. @@ -1032,6 +1052,14 @@ fada-spec-parent= C ObjC C++ ObjC++ RejectNegative Joined Var(ada_specs_parent) -fada-spec-parent=unit Dump Ada specs as child units of given parent. +faligned-new +C++ ObjC++ Alias(faligned-new=,1,0) +Support C++17 allocation of over-aligned types. + +faligned-new= +C++ ObjC++ Joined Var(aligned_new_threshhold) UInteger Init(-1) +-faligned-new=<N> Use C++17 over-aligned type allocation for alignments greater than N. + fall-virtual C++ ObjC++ Ignore Warn(switch %qs is no longer supported) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ac6648b45a..4c2fc5dda65 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,77 @@ +2016-09-16 Marek Polacek <polacek@redhat.com> + + * c-typeck.c (lvalue_p): Use true and false instead of 1 and 0. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * c-array-notation.c (create_cmp_incr): Use false instead of 0. + (fix_array_notation_expr): Likewise. + * c-decl.c (finish_decl): Likewise. + * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. + * c-typeck.c (array_to_pointer_conversion): Use true instead of 1. + (function_to_pointer_conversion): Use false instead of 0. + (convert_lvalue_to_rvalue): Likewise. + (parser_build_unary_op): Likewise. + (build_atomic_assign): Likewise. + (build_unary_op): Change nonconvert parameter type to bool, use + true/false instead of 1/0. + (build_binary_op): Use true instead of 1. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * c-parser.c (c_parser_declaration_or_fndef): Update for renaming + of add_fixit_insert to add_fixit_insert_before. + +2016-09-13 Marek Polacek <polacek@redhat.com> + + * c-typeck.c (build_unary_op): Rename FLAG parameter to NOCONVERT. Use + it. + +2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR c++/77496 + * c-parser.c (c_parser_conditional_expression): Pass the rightmost + COMPOUND_EXPR to warn_for_omitted_condop. + +2016-09-07 David Malcolm <dmalcolm@redhat.com> + + * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use + c_get_substring_location for this new langhook. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR c/65467 + * c-parser.c (c_parser_declspecs): Don't sorry about _Atomic if + flag_openmp. + (c_parser_omp_variable_list): Use convert_lvalue_to_rvalue + instead of mark_exp_read on low_bound/length expression. + (c_parser_omp_clause_num_gangs, c_parser_omp_clause_num_threads, + c_parser_omp_clause_num_tasks, c_parser_omp_clause_grainsize, + c_parser_omp_clause_priority, c_parser_omp_clause_hint, + c_parser_omp_clause_num_workers, c_parser_oacc_shape_clause, + c_parser_oacc_clause_tile, c_parser_omp_clause_schedule, + c_parser_omp_clause_vector_length, c_parser_omp_clause_num_teams, + c_parser_omp_clause_thread_limit, c_parser_omp_clause_aligned, + c_parser_omp_clause_linear, c_parser_omp_clause_safelen, + c_parser_omp_clause_simdlen, c_parser_omp_clause_device, + c_parser_omp_clause_dist_schedule): Use convert_lvalue_to_rvalue + instead of mark_expr_read. + (c_parser_omp_declare_reduction): Reject _Atomic qualified types. + * c-objc-common.h (LANG_HOOKS_OMP_CLAUSE_COPY_CTOR, + LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP): Redefine. + * c-tree.h (c_omp_clause_copy_ctor): New prototype. + * c-typeck.c (handle_omp_array_sections_1): Diagnose _Atomic qualified + array section bases outside of depend clause, for depend clause + use convert_lvalue_to_rvalue on the base. + (c_finish_omp_clauses): Reject _Atomic qualified vars in reduction, + linear, aligned, map, to and from clauses. + (c_omp_clause_copy_ctor): New function. + +2016-09-01 Marek Polacek <polacek@redhat.com> + + PR c/7652 + * c-typeck.c (composite_type): Add FALLTHRU comment. + 2016-08-31 David Malcolm <dmalcolm@redhat.com> * c-parser.c (c_parser_declaration_or_fndef): Add trailing space @@ -244,7 +318,7 @@ * c-typeck.c (build_conditional_expr): Return error_mark_node if c_common_type returns error_mark_node. -2016-06-19 Martin Sebor <msebor@redhat.com> +2016-06-19 Martin Sebor <msebor@redhat.com> PR c/69507 * c-parser.c (c_parser_alignof_expression): Avoid diagnosing @@ -1993,7 +2067,7 @@ * c-typeck.c (build_array_ref): Pass loc down to warn_array_subscript_with_type_char. -2014-12-20 Martin Uecker <uecker@eecs.berkeley.edu> +2014-12-20 Martin Uecker <uecker@eecs.berkeley.edu> * c-typeck.c: New behavious for pointers to arrays with qualifiers (common-pointer-type): For pointers to arrays take qualifiers from @@ -2315,7 +2389,7 @@ Likewise. (c_parser_postfix_expression) <case RID_C99_FUNCTION_NAME>: Likewise. -2014-08-10 Marek Polacek <polacek@redhat.com> +2014-08-10 Marek Polacek <polacek@redhat.com> PR c/51849 * c-decl.c (build_array_declarator): Remove check for !flag_isoc99. @@ -2402,7 +2476,7 @@ function parameter. 2014-07-02 Jan Hubicka <hubicka@ucw.cz> - Chen Gang <gang.chen.5i5j@gmail.com> + Chen Gang <gang.chen.5i5j@gmail.com> * c-decl.c (duplicate_decls): CLear DECL_STRUCT_FUNCTION before releasing symbol. diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index c7cf66a2c81..ce609112089 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -104,7 +104,7 @@ create_cmp_incr (location_t loc, vec<an_loop_parts> *node, size_t rank, { tree var = (*node)[ii].var; tree length = an_info[0][ii].length; - (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, 0); + (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, false); (*node)[ii].cmp = build2 (LT_EXPR, boolean_type_node, var, length); } } @@ -1088,7 +1088,7 @@ fix_array_notation_expr (location_t location, enum tree_code code, arg = default_function_array_read_conversion (location, arg); if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) - arg.value = build_unary_op (location, code, arg.value, 0); + arg.value = build_unary_op (location, code, arg.value, false); else if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR) arg = parser_build_unary_op (location, code, arg); diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 8f49c35237d..d15b8f89b0a 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5102,7 +5102,7 @@ finish_decl (tree decl, location_t init_loc, tree init, vec<tree, va_gc> *v; /* Build "cleanup(&decl)" for the destructor. */ - cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0); + cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false); vec_alloc (v, 1); v->quick_push (cleanup); cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl), diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.c index b26be6ad92c..b4096d064ee 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.c @@ -43,6 +43,9 @@ enum c_language_kind c_language = clk_c; #define LANG_HOOKS_RUN_LANG_SELFTESTS selftest::run_c_tests #endif /* #if CHECKING_P */ +#undef LANG_HOOKS_GET_SUBSTRING_LOCATION +#define LANG_HOOKS_GET_SUBSTRING_LOCATION c_get_substring_location + /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index ccb4903ee42..14554ace114 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -100,6 +100,12 @@ along with GCC; see the file COPYING3. If not see #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING #define LANG_HOOKS_OMP_PREDETERMINED_SHARING c_omp_predetermined_sharing +#undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR +#define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR c_omp_clause_copy_ctor + +#undef LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP +#define LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP c_omp_clause_copy_ctor + #undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p #endif /* GCC_C_OBJC_COMMON */ diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 0581899e307..58424a9e8e5 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1685,7 +1685,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, if (tag_exists_p (RECORD_TYPE, name)) { /* This is not C++ with its implicit typedef. */ - richloc.add_fixit_insert ("struct "); + richloc.add_fixit_insert_before ("struct "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use %<struct%> keyword to refer to the type", @@ -1693,7 +1693,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, } else if (tag_exists_p (UNION_TYPE, name)) { - richloc.add_fixit_insert ("union "); + richloc.add_fixit_insert_before ("union "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use %<union%> keyword to refer to the type", @@ -1701,7 +1701,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, } else if (tag_exists_p (ENUMERAL_TYPE, name)) { - richloc.add_fixit_insert ("enum "); + richloc.add_fixit_insert_before ("enum "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use %<enum%> keyword to refer to the type", @@ -2600,10 +2600,6 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, and objc_types_are_equivalent may also need updates. */ if (c_dialect_objc ()) sorry ("%<_Atomic%> in Objective-C"); - /* C parser handling of OpenMP constructs needs checking for - correct lvalue-to-rvalue conversions. */ - if (flag_openmp) - sorry ("%<_Atomic%> with OpenMP"); if (flag_isoc99) pedwarn_c99 (loc, OPT_Wpedantic, "ISO C99 does not support the %<_Atomic%> qualifier"); @@ -6429,14 +6425,17 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after, tree eptype = NULL_TREE; middle_loc = c_parser_peek_token (parser)->location; - pedwarn (middle_loc, OPT_Wpedantic, + pedwarn (middle_loc, OPT_Wpedantic, "ISO C forbids omitting the middle term of a ?: expression"); - warn_for_omitted_condop (middle_loc, cond.value); if (TREE_CODE (cond.value) == EXCESS_PRECISION_EXPR) { eptype = TREE_TYPE (cond.value); cond.value = TREE_OPERAND (cond.value, 0); } + tree e = cond.value; + while (TREE_CODE (e) == COMPOUND_EXPR) + e = TREE_OPERAND (e, 1); + warn_for_omitted_condop (middle_loc, e); /* Make sure first operand is calculated only once. */ exp1.value = c_save_expr (default_conversion (cond.value)); if (eptype) @@ -8479,8 +8478,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else { expr = default_function_array_read_conversion (expr_loc, expr); - expr.value = build_unary_op (op_loc, - POSTINCREMENT_EXPR, expr.value, 0); + expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR, + expr.value, false); } set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; @@ -8498,8 +8497,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else { expr = default_function_array_read_conversion (expr_loc, expr); - expr.value = build_unary_op (op_loc, - POSTDECREMENT_EXPR, expr.value, 0); + expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR, + expr.value, false); } set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; @@ -10718,8 +10717,12 @@ c_parser_omp_variable_list (c_parser *parser, c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_COLON)) { - low_bound = c_parser_expression (parser).value; - mark_exp_read (low_bound); + location_t expr_loc + = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, + false, true); + low_bound = expr.value; } if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) length = integer_one_node; @@ -10734,8 +10737,12 @@ c_parser_omp_variable_list (c_parser *parser, } if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) { - length = c_parser_expression (parser).value; - mark_exp_read (length); + location_t expr_loc + = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, + false, true); + length = expr.value; } } /* Look for the closing `]'. */ @@ -11257,8 +11264,9 @@ c_parser_omp_clause_num_gangs (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11301,8 +11309,9 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11345,8 +11354,9 @@ c_parser_omp_clause_num_tasks (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11389,8 +11399,9 @@ c_parser_omp_clause_grainsize (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11433,8 +11444,9 @@ c_parser_omp_clause_priority (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11477,8 +11489,10 @@ c_parser_omp_clause_hint (c_parser *parser, tree list) location_t hint_loc = c_parser_peek_token (parser)->location; if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11581,8 +11595,9 @@ c_parser_omp_clause_num_workers (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11703,11 +11718,12 @@ c_parser_oacc_shape_clause (c_parser *parser, omp_clause_code kind, } location_t expr_loc = c_parser_peek_token (parser)->location; - tree expr = c_parser_expr_no_commas (parser, NULL).value; + c_expr cexpr = c_parser_expr_no_commas (parser, NULL); + cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true); + tree expr = cexpr.value; if (expr == error_mark_node) goto cleanup_error; - mark_exp_read (expr); expr = c_fully_fold (expr, false, NULL); /* Attempt to statically determine when the number isn't a @@ -11842,7 +11858,9 @@ c_parser_oacc_clause_tile (c_parser *parser, tree list) else { expr_loc = c_parser_peek_token (parser)->location; - expr = c_parser_expr_no_commas (parser, NULL).value; + c_expr cexpr = c_parser_expr_no_commas (parser, NULL); + cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true); + expr = cexpr.value; if (expr == error_mark_node) { @@ -11857,7 +11875,6 @@ c_parser_oacc_clause_tile (c_parser *parser, tree list) return list; } - mark_exp_read (expr); expr = c_fully_fold (expr, false, NULL); /* Attempt to statically determine when expr isn't positive. */ @@ -12180,8 +12197,9 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list) c_parser_consume_token (parser); here = c_parser_peek_token (parser)->location; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (here, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME) @@ -12266,8 +12284,9 @@ c_parser_omp_clause_vector_length (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12369,8 +12388,9 @@ c_parser_omp_clause_num_teams (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12412,8 +12432,9 @@ c_parser_omp_clause_thread_limit (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12465,8 +12486,10 @@ c_parser_omp_clause_aligned (c_parser *parser, tree list) if (c_parser_next_token_is (parser, CPP_COLON)) { c_parser_consume_token (parser); - tree alignment = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (alignment); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree alignment = expr.value; alignment = c_fully_fold (alignment, false, NULL); if (TREE_CODE (alignment) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (alignment)) @@ -12528,8 +12551,10 @@ c_parser_omp_clause_linear (c_parser *parser, tree list, bool is_cilk_simd_fn) if (c_parser_next_token_is (parser, CPP_COLON)) { c_parser_consume_token (parser); - step = c_parser_expression (parser).value; - mark_exp_read (step); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + step = expr.value; step = c_fully_fold (step, false, NULL); if (is_cilk_simd_fn && TREE_CODE (step) == PARM_DECL) { @@ -12569,8 +12594,10 @@ c_parser_omp_clause_safelen (c_parser *parser, tree list) if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return list; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (TREE_CODE (t) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (t)) @@ -12605,8 +12632,10 @@ c_parser_omp_clause_simdlen (c_parser *parser, tree list) if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return list; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (TREE_CODE (t) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (t)) @@ -12921,8 +12950,10 @@ c_parser_omp_clause_device (c_parser *parser, tree list) location_t clause_loc = c_parser_peek_token (parser)->location; if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - tree c, t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12970,8 +13001,10 @@ c_parser_omp_clause_dist_schedule (c_parser *parser, tree list) { c_parser_consume_token (parser); - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); } @@ -16876,6 +16909,9 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) || TREE_CODE (type) == ARRAY_TYPE) error_at (loc, "function or array type in " "%<#pragma omp declare reduction%>"); + else if (TYPE_ATOMIC (type)) + error_at (loc, "%<_Atomic%> qualified type in " + "%<#pragma omp declare reduction%>"); else if (TYPE_QUALS_NO_ADDR_SPACE (type)) error_at (loc, "const, volatile or restrict qualified type in " "%<#pragma omp declare reduction%>"); diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 5a8ab6df483..e8060f8b197 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -682,6 +682,7 @@ extern tree c_finish_transaction (location_t, tree, int); extern bool c_tree_equal (tree, tree); extern tree c_build_function_call_vec (location_t, vec<location_t>, tree, vec<tree, va_gc> *, vec<tree, va_gc> *); +extern tree c_omp_clause_copy_ctor (tree, tree, tree); /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 51940273d69..059ad1fc2e0 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -605,8 +605,8 @@ composite_type (tree t1, tree t2) t1 = build_function_type (valtype, newargs); t1 = qualify_type (t1, t2); - /* ... falls through ... */ } + /* FALLTHRU */ default: return build_type_attribute_variant (t1, attributes); @@ -1880,7 +1880,7 @@ array_to_pointer_conversion (location_t loc, tree exp) "is ill-formed in C++"); } - adr = build_unary_op (loc, ADDR_EXPR, exp, 1); + adr = build_unary_op (loc, ADDR_EXPR, exp, true); return convert (ptrtype, adr); } @@ -1897,7 +1897,7 @@ function_to_pointer_conversion (location_t loc, tree exp) if (TREE_NO_WARNING (orig_exp)) TREE_NO_WARNING (exp) = 1; - return build_unary_op (loc, ADDR_EXPR, exp, 0); + return build_unary_op (loc, ADDR_EXPR, exp, false); } /* Mark EXP as read, not just set, for set but not used -Wunused @@ -2042,7 +2042,7 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp, vec<tree, va_gc> *params; tree nonatomic_type, tmp, tmp_addr, fndecl, func_call; tree expr_type = TREE_TYPE (exp.value); - tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, 0); + tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false); tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); gcc_assert (TYPE_ATOMIC (expr_type)); @@ -2055,7 +2055,7 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp, create the VAL temp variable to hold the RHS. */ nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED); tmp = create_tmp_var_raw (nonatomic_type); - tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, 0); + tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false); TREE_ADDRESSABLE (tmp) = 1; TREE_NO_WARNING (tmp) = 1; @@ -3575,7 +3575,7 @@ parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg) } else { - result.value = build_unary_op (loc, code, arg.value, 0); + result.value = build_unary_op (loc, code, arg.value, false); if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value)) overflow_warning (loc, result.value); @@ -3872,7 +3872,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, tree loop_label, loop_decl, done_label, done_decl; tree lhs_type = TREE_TYPE (lhs); - tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, 0); + tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false); tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); tree rhs_type = TREE_TYPE (rhs); @@ -3909,7 +3909,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, if (modifycode == NOP_EXPR) { /* Build __atomic_store (&lhs, &val, SEQ_CST) */ - rhs = build_unary_op (loc, ADDR_EXPR, val, 0); + rhs = build_unary_op (loc, ADDR_EXPR, val, false); fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE); params->quick_push (lhs_addr); params->quick_push (rhs); @@ -4014,12 +4014,12 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, cas_loop: /* Create the variables and labels required for the op= form. */ old = create_tmp_var_raw (nonatomic_lhs_type); - old_addr = build_unary_op (loc, ADDR_EXPR, old, 0); + old_addr = build_unary_op (loc, ADDR_EXPR, old, false); TREE_ADDRESSABLE (old) = 1; TREE_NO_WARNING (old) = 1; newval = create_tmp_var_raw (nonatomic_lhs_type); - newval_addr = build_unary_op (loc, ADDR_EXPR, newval, 0); + newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false); TREE_ADDRESSABLE (newval) = 1; TREE_NO_WARNING (newval) = 1; @@ -4112,17 +4112,17 @@ cas_loop: /* Construct and perhaps optimize a tree representation for a unary operation. CODE, a tree_code, specifies the operation and XARG is the operand. - For any CODE other than ADDR_EXPR, FLAG nonzero suppresses - the default promotions (such as from short to int). - For ADDR_EXPR, the default promotions are not applied; FLAG nonzero - allows non-lvalues; this is only used to handle conversion of non-lvalue - arrays to pointers in C99. + For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default + promotions (such as from short to int). + For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows + non-lvalues; this is only used to handle conversion of non-lvalue arrays + to pointers in C99. LOCATION is the location of the operator. */ tree -build_unary_op (location_t location, - enum tree_code code, tree xarg, int flag) +build_unary_op (location_t location, enum tree_code code, tree xarg, + bool noconvert) { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ tree arg = xarg; @@ -4131,7 +4131,6 @@ build_unary_op (location_t location, tree val; tree ret = error_mark_node; tree eptype = NULL_TREE; - int noconvert = flag; const char *invalid_op_diag; bool int_operands; @@ -4276,7 +4275,8 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR) { tree inner = build_unary_op (location, code, - C_MAYBE_CONST_EXPR_EXPR (arg), flag); + C_MAYBE_CONST_EXPR_EXPR (arg), + noconvert); if (inner == error_mark_node) return error_mark_node; ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner), @@ -4324,9 +4324,11 @@ build_unary_op (location_t location, if (!atomic_op) { arg = stabilize_reference (arg); - real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, 1); - imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, 1); - real = build_unary_op (EXPR_LOCATION (arg), code, real, 1); + real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, + true); + imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, + true); + real = build_unary_op (EXPR_LOCATION (arg), code, real, true); if (real == error_mark_node || imag == error_mark_node) return error_mark_node; ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg), @@ -4486,7 +4488,7 @@ build_unary_op (location_t location, /* Anything not already handled and not a true memory reference or a non-lvalue array is an error. */ - if (typecode != FUNCTION_TYPE && !flag + if (typecode != FUNCTION_TYPE && !noconvert && !lvalue_or_else (location, arg, lv_addressof)) return error_mark_node; @@ -4495,7 +4497,8 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR) { tree inner = build_unary_op (location, code, - C_MAYBE_CONST_EXPR_EXPR (arg), flag); + C_MAYBE_CONST_EXPR_EXPR (arg), + noconvert); ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner), C_MAYBE_CONST_EXPR_PRE (arg), inner); gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg)); @@ -4628,7 +4631,7 @@ lvalue_p (const_tree ref) case COMPOUND_LITERAL_EXPR: case STRING_CST: - return 1; + return true; case INDIRECT_REF: case ARRAY_REF: @@ -4644,7 +4647,7 @@ lvalue_p (const_tree ref) return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE; default: - return 0; + return false; } } @@ -11512,9 +11515,9 @@ build_binary_op (location_t location, enum tree_code code, { op0 = c_save_expr (op0); real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR, - op0, 1); + op0, true); imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR, - op0, 1); + op0, true); switch (code) { case MULT_EXPR: @@ -11534,9 +11537,9 @@ build_binary_op (location_t location, enum tree_code code, { op1 = c_save_expr (op1); real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR, - op1, 1); + op1, true); imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR, - op1, 1); + op1, true); switch (code) { case MULT_EXPR: @@ -12072,6 +12075,13 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types, if (error_operand_p (t)) return error_mark_node; ret = t; + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND + && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t)))) + { + error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause", + t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; + } if (TREE_CODE (t) == COMPONENT_REF && ort == C_ORT_OMP && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP @@ -12109,13 +12119,35 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types, return error_mark_node; } else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND - && VAR_P (t) && DECL_THREAD_LOCAL_P (t)) + && TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause", + t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; + } + else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND + && VAR_P (t) + && DECL_THREAD_LOCAL_P (t)) { error_at (OMP_CLAUSE_LOCATION (c), "%qD is threadprivate variable in %qs clause", t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND + && TYPE_ATOMIC (TREE_TYPE (t)) + && POINTER_TYPE_P (TREE_TYPE (t))) + { + /* If the array section is pointer based and the pointer + itself is _Atomic qualified, we need to atomically load + the pointer. */ + c_expr expr; + memset (&expr, 0, sizeof (expr)); + expr.value = ret; + expr = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c), + expr, false, false); + ret = expr.value; + } return ret; } @@ -12675,7 +12707,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) oacc_async = true; break; } - + for (pc = &clauses, c = clauses; c ; c = *pc) { bool remove = false; @@ -12750,6 +12782,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0)); OMP_CLAUSE_DECL (c) = t; } + if (TYPE_ATOMIC (type)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %<reduction%> clause", t); + remove = true; + break; + } if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE && (FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)) @@ -12964,6 +13003,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) remove = true; break; } + if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qD in %<linear%> clause", t); + remove = true; + break; + } } if (ort == C_ORT_OMP_DECLARE_SIMD) { @@ -13112,6 +13158,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "an array", t); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qD in %<aligned%> clause", t); + remove = true; + break; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error_at (OMP_CLAUSE_LOCATION (c), @@ -13197,6 +13250,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } while (TREE_CODE (t) == ARRAY_REF) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == COMPONENT_REF @@ -13251,6 +13311,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } while (TREE_CODE (t) == COMPONENT_REF) { if (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) @@ -13304,6 +13371,15 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TREE_TYPE (t) == error_mark_node) + remove = true; + else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t)))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_POINTER) { @@ -13644,6 +13720,50 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) return clauses; } +/* Return code to initialize DST with a copy constructor from SRC. + C doesn't have copy constructors nor assignment operators, only for + _Atomic vars we need to perform __atomic_load from src into a temporary + followed by __atomic_store of the temporary to dst. */ + +tree +c_omp_clause_copy_ctor (tree clause, tree dst, tree src) +{ + if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src)) + return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); + + location_t loc = OMP_CLAUSE_LOCATION (clause); + tree type = TREE_TYPE (dst); + tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED); + tree tmp = create_tmp_var (nonatomic_type); + tree tmp_addr = build_fold_addr_expr (tmp); + TREE_ADDRESSABLE (tmp) = 1; + TREE_NO_WARNING (tmp) = 1; + tree src_addr = build_fold_addr_expr (src); + tree dst_addr = build_fold_addr_expr (dst); + tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); + vec<tree, va_gc> *params; + /* Expansion of a generic atomic load may require an addition + element, so allocate enough to prevent a resize. */ + vec_alloc (params, 4); + + /* Build __atomic_load (&src, &tmp, SEQ_CST); */ + tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD); + params->quick_push (src_addr); + params->quick_push (tmp_addr); + params->quick_push (seq_cst); + tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL); + + vec_alloc (params, 4); + + /* Build __atomic_store (&dst, &tmp, SEQ_CST); */ + fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE); + params->quick_push (dst_addr); + params->quick_push (tmp_addr); + params->quick_push (seq_cst); + tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL); + return build2 (COMPOUND_EXPR, void_type_node, load, store); +} + /* Create a transaction node. */ tree diff --git a/gcc/calls.c b/gcc/calls.c index 4ad3e34d677..86369e9cfdc 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1805,7 +1805,7 @@ compute_argument_addresses (struct arg_data *args, rtx argblock, int num_actuals else if (CONST_INT_P (offset)) { align = INTVAL (offset) * BITS_PER_UNIT | boundary; - align = align & -align; + align = least_bit_hwi (align); } set_mem_align (args[i].stack, align); @@ -5026,7 +5026,7 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, int pad = used - size; if (pad) { - unsigned int pad_align = (pad & -pad) * BITS_PER_UNIT; + unsigned int pad_align = least_bit_hwi (pad) * BITS_PER_UNIT; parm_align = MIN (parm_align, pad_align); } } @@ -5086,7 +5086,7 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, parm_align = BITS_PER_UNIT; else if (excess) { - unsigned int excess_align = (excess & -excess) * BITS_PER_UNIT; + unsigned int excess_align = least_bit_hwi (excess) * BITS_PER_UNIT; parm_align = MIN (parm_align, excess_align); } } diff --git a/gcc/cfg.c b/gcc/cfg.c index 0e317809f4c..cab66c67d4a 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -1075,7 +1075,7 @@ free_original_copy_tables (void) delete bb_copy; bb_copy = NULL; delete bb_original; - bb_copy = NULL; + bb_original = NULL; delete loop_copy; loop_copy = NULL; delete original_copy_bb_pool; diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 130a16b1d7d..4190f7f0aed 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -815,16 +815,15 @@ update_alias_info_with_stack_vars (void) if (decls_to_partitions) { unsigned i; + tree name; hash_set<bitmap> visited; bitmap temp = BITMAP_ALLOC (&stack_var_bitmap_obstack); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); struct ptr_info_def *pi; - if (name - && POINTER_TYPE_P (TREE_TYPE (name)) + if (POINTER_TYPE_P (TREE_TYPE (name)) && ((pi = SSA_NAME_PTR_INFO (name)) != NULL)) add_partitioned_vars_to_ptset (&pi->pt, decls_to_partitions, &visited, temp); @@ -1009,7 +1008,7 @@ expand_one_stack_var_at (tree decl, rtx base, unsigned base_align, important, we'll simply use the alignment that is already set. */ if (base == virtual_stack_vars_rtx) offset -= frame_phase; - align = offset & -offset; + align = least_bit_hwi (offset); align *= BITS_PER_UNIT; if (align == 0 || align > base_align) align = base_align; @@ -6270,16 +6269,15 @@ pass_expand::execute (function *fun) /* Now propagate the RTL assignment of each partition to the underlying var of each SSA_NAME. */ - for (i = 1; i < num_ssa_names; i++) - { - tree name = ssa_name (i); + tree name; - if (!name - /* We might have generated new SSA names in - update_alias_info_with_stack_vars. They will have a NULL - defining statements, and won't be part of the partitioning, - so ignore those. */ - || !SSA_NAME_DEF_STMT (name)) + FOR_EACH_SSA_NAME (i, name, cfun) + { + /* We might have generated new SSA names in + update_alias_info_with_stack_vars. They will have a NULL + defining statements, and won't be part of the partitioning, + so ignore those. */ + if (!SSA_NAME_DEF_STMT (name)) continue; adjust_one_expanded_partition_var (name); @@ -6288,17 +6286,15 @@ pass_expand::execute (function *fun) /* Clean up RTL of variables that straddle across multiple partitions, and check that the rtl of any PARM_DECLs that are not cleaned up is that of their default defs. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); int part; - if (!name - /* We might have generated new SSA names in - update_alias_info_with_stack_vars. They will have a NULL - defining statements, and won't be part of the partitioning, - so ignore those. */ - || !SSA_NAME_DEF_STMT (name)) + /* We might have generated new SSA names in + update_alias_info_with_stack_vars. They will have a NULL + defining statements, and won't be part of the partitioning, + so ignore those. */ + if (!SSA_NAME_DEF_STMT (name)) continue; part = var_to_partition (SA.map, name); if (part == NO_PARTITION) diff --git a/gcc/combine.c b/gcc/combine.c index 1b262f94fed..b22a2748029 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2251,7 +2251,7 @@ contains_muldiv (rtx x) case MULT: return ! (CONST_INT_P (XEXP (x, 1)) - && exact_log2 (UINTVAL (XEXP (x, 1))) >= 0); + && pow2p_hwi (UINTVAL (XEXP (x, 1)))); default: if (BINARY_P (x)) return contains_muldiv (XEXP (x, 0)) @@ -5100,7 +5100,7 @@ find_split_point (rtx *loc, rtx_insn *insn, bool set_src) instead if this isn't a multiply by a power of two. */ if (set_src && code == MINUS && GET_CODE (XEXP (x, 1)) == MULT && GET_CODE (XEXP (XEXP (x, 1), 1)) == CONST_INT - && exact_log2 (INTVAL (XEXP (XEXP (x, 1), 1))) < 0) + && !pow2p_hwi (INTVAL (XEXP (XEXP (x, 1), 1)))) { machine_mode mode = GET_MODE (x); unsigned HOST_WIDE_INT this_int = INTVAL (XEXP (XEXP (x, 1), 1)); @@ -5916,7 +5916,7 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, (and <foo> (const_int pow2-1)) */ if (GET_CODE (XEXP (x, 1)) == AND && CONST_INT_P (XEXP (XEXP (x, 1), 1)) - && exact_log2 (-UINTVAL (XEXP (XEXP (x, 1), 1))) >= 0 + && pow2p_hwi (-UINTVAL (XEXP (XEXP (x, 1), 1))) && rtx_equal_p (XEXP (XEXP (x, 1), 0), XEXP (x, 0))) return simplify_and_const_int (NULL_RTX, mode, XEXP (x, 0), -INTVAL (XEXP (XEXP (x, 1), 1)) - 1); @@ -6236,7 +6236,7 @@ simplify_if_then_else (rtx x) not equal to zero. Similarly if it is known to be -1 or 0. */ if (true_code == EQ && true_val == const0_rtx - && exact_log2 (nzb = nonzero_bits (from, GET_MODE (from))) >= 0) + && pow2p_hwi (nzb = nonzero_bits (from, GET_MODE (from)))) { false_code = EQ; false_val = gen_int_mode (nzb, GET_MODE (from)); @@ -6673,7 +6673,7 @@ simplify_set (rtx x) || (old_code == EQ && new_code == NE)) && ! other_changed_previously && op1 == const0_rtx && HWI_COMPUTABLE_MODE_P (GET_MODE (op0)) - && exact_log2 (mask = nonzero_bits (op0, GET_MODE (op0))) >= 0) + && pow2p_hwi (mask = nonzero_bits (op0, GET_MODE (op0)))) { rtx pat = PATTERN (other_insn), note = 0; @@ -8525,7 +8525,7 @@ force_to_mode (rtx x, machine_mode mode, unsigned HOST_WIDE_INT mask, smask |= HOST_WIDE_INT_M1U << width; if (CONST_INT_P (XEXP (x, 1)) - && exact_log2 (- smask) >= 0 + && pow2p_hwi (- smask) && (nonzero_bits (XEXP (x, 0), mode) & ~smask) == 0 && (INTVAL (XEXP (x, 1)) & ~smask) != 0) return force_to_mode (plus_constant (GET_MODE (x), XEXP (x, 0), @@ -8557,7 +8557,7 @@ force_to_mode (rtx x, machine_mode mode, unsigned HOST_WIDE_INT mask, /* If X is (minus C Y) where C's least set bit is larger than any bit in the mask, then we may replace with (neg Y). */ if (CONST_INT_P (XEXP (x, 0)) - && ((UINTVAL (XEXP (x, 0)) & -UINTVAL (XEXP (x, 0))) > mask)) + && least_bit_hwi (UINTVAL (XEXP (x, 0))) > mask) { x = simplify_gen_unary (NEG, GET_MODE (x), XEXP (x, 1), GET_MODE (x)); @@ -8701,7 +8701,7 @@ force_to_mode (rtx x, machine_mode mode, unsigned HOST_WIDE_INT mask, && ((INTVAL (XEXP (x, 1)) + num_sign_bit_copies (XEXP (x, 0), GET_MODE (XEXP (x, 0)))) >= GET_MODE_PRECISION (GET_MODE (x))) - && exact_log2 (mask + 1) >= 0 + && pow2p_hwi (mask + 1) /* Number of bits left after the shift must be more than the mask needs. */ && ((INTVAL (XEXP (x, 1)) + exact_log2 (mask + 1)) @@ -8875,7 +8875,7 @@ force_to_mode (rtx x, machine_mode mode, unsigned HOST_WIDE_INT mask, if ((mask & ~STORE_FLAG_VALUE) == 0 && XEXP (x, 1) == const0_rtx && GET_MODE (XEXP (x, 0)) == mode - && exact_log2 (nonzero_bits (XEXP (x, 0), mode)) >= 0 + && pow2p_hwi (nonzero_bits (XEXP (x, 0), mode)) && (nonzero_bits (XEXP (x, 0), mode) == (unsigned HOST_WIDE_INT) STORE_FLAG_VALUE)) return force_to_mode (XEXP (x, 0), mode, mask, next_select); @@ -9105,7 +9105,7 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse) /* Likewise for 0 or a single bit. */ else if (HWI_COMPUTABLE_MODE_P (mode) - && exact_log2 (nz = nonzero_bits (x, mode)) >= 0) + && pow2p_hwi (nz = nonzero_bits (x, mode))) { *ptrue = gen_int_mode (nz, mode), *pfalse = const0_rtx; return x; @@ -9793,7 +9793,7 @@ simplify_and_const_int_1 (machine_mode mode, rtx varop, may eliminate it. */ if (GET_CODE (varop) == PLUS - && exact_log2 (constop + 1) >= 0) + && pow2p_hwi (constop + 1)) { rtx o0, o1; @@ -11335,7 +11335,7 @@ simplify_compare_const (enum rtx_code code, machine_mode mode, && (code == EQ || code == NE || code == GE || code == GEU || code == LT || code == LTU) && mode_width - 1 < HOST_BITS_PER_WIDE_INT - && exact_log2 (const_op & GET_MODE_MASK (mode)) >= 0 + && pow2p_hwi (const_op & GET_MODE_MASK (mode)) && (nonzero_bits (op0, mode) == (unsigned HOST_WIDE_INT) (const_op & GET_MODE_MASK (mode)))) { @@ -14393,6 +14393,8 @@ rest_of_handle_combine (void) instructions. */ if (rebuild_jump_labels_after_combine) { + if (dom_info_available_p (CDI_DOMINATORS)) + free_dominance_info (CDI_DOMINATORS); timevar_push (TV_JUMP); rebuild_jump_labels (get_insns ()); cleanup_cfg (0); diff --git a/gcc/common.opt b/gcc/common.opt index fd1ac87ddab..fa1c0365e3c 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1196,6 +1196,10 @@ fdiagnostics-parseable-fixits Common Var(flag_diagnostics_parseable_fixits) Print fixit hints in machine-readable form. +fdiagnostics-generate-patch +Common Var(flag_diagnostics_generate_patch) +Print fix-it hints to stderr in unified diff format. + fdiagnostics-show-option Common Var(flag_diagnostics_show_option) Init(1) Amend appropriate diagnostic messages with the command line option that controls them. diff --git a/gcc/config.gcc b/gcc/config.gcc index e544d767b4e..fc91ba79abf 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1985,6 +1985,8 @@ mips*-img-linux*) extra_options="${extra_options} linux-android.opt" tmake_file="${tmake_file} mips/t-img-linux" tm_defines="${tm_defines} MIPS_ISA_DEFAULT=37 MIPS_ABI_DEFAULT=ABI_32" + with_arch_32="mips32r6" + with_arch_64="mips64r6" gnu_ld=yes gas=yes ;; @@ -1993,6 +1995,8 @@ mips*-mti-linux*) extra_options="${extra_options} linux-android.opt" tmake_file="${tmake_file} mips/t-mti-linux" tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33 MIPS_ABI_DEFAULT=ABI_32" + with_arch_32="mips32r2" + with_arch_64="mips64r2" gnu_ld=yes gas=yes ;; @@ -2047,11 +2051,15 @@ mips*-mti-elf*) tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h mips/n32-elf.h mips/sde.h mips/mti-elf.h" tmake_file="mips/t-mti-elf" tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33 MIPS_ABI_DEFAULT=ABI_32" + with_arch_32="mips32r2" + with_arch_64="mips64r2" ;; mips*-img-elf*) tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h mips/n32-elf.h mips/sde.h mips/mti-elf.h" tmake_file="mips/t-img-elf" tm_defines="${tm_defines} MIPS_ISA_DEFAULT=37 MIPS_ABI_DEFAULT=ABI_32" + with_arch_32="mips32r6" + with_arch_64="mips64r6" ;; mips*-sde-elf*) tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h mips/n32-elf.h mips/sde.h" diff --git a/gcc/config.in b/gcc/config.in index fc3321cb146..a736de3a82b 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1538,6 +1538,12 @@ #endif +/* Define if your linker supports --push-state/--pop-state */ +#ifndef USED_FOR_TARGET +#undef HAVE_LD_PUSHPOPSTATE_SUPPORT +#endif + + /* Define if your linker links a mix of read-only and read-write sections into a read-write section. */ #ifndef USED_FOR_TARGET diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c index 9136910cd32..822d608a5b3 100644 --- a/gcc/config/aarch64/aarch64-builtins.c +++ b/gcc/config/aarch64/aarch64-builtins.c @@ -762,16 +762,16 @@ aarch64_init_simd_builtins (void) if (qualifiers & qualifier_unsigned) { - type_signature[arg_num] = 'u'; + type_signature[op_num] = 'u'; print_type_signature_p = true; } else if (qualifiers & qualifier_poly) { - type_signature[arg_num] = 'p'; + type_signature[op_num] = 'p'; print_type_signature_p = true; } else - type_signature[arg_num] = 's'; + type_signature[op_num] = 's'; /* Skip an internal operand for vget_{low, high}. */ if (qualifiers & qualifier_internal) diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def b/gcc/config/aarch64/aarch64-tuning-flags.def index 048c2a3e3f7..68b5ba0ad0e 100644 --- a/gcc/config/aarch64/aarch64-tuning-flags.def +++ b/gcc/config/aarch64/aarch64-tuning-flags.def @@ -29,3 +29,8 @@ AARCH64_TUNE_ to give an enum name. */ AARCH64_EXTRA_TUNING_OPTION ("rename_fma_regs", RENAME_FMA_REGS) + +/* Don't create non-8 byte aligned load/store pair. That is if the +two load/stores are not at least 8 byte aligned don't create load/store +pairs. */ +AARCH64_EXTRA_TUNING_OPTION ("slow_unaligned_ldpw", SLOW_UNALIGNED_LDPW) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 3e663eb5f13..6078b163548 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -712,7 +712,7 @@ static const struct tune_params thunderx_tunings = 0, /* max_case_values. */ 0, /* cache_line_size. */ tune_params::AUTOPREFETCHER_OFF, /* autoprefetcher_model. */ - (AARCH64_EXTRA_TUNE_NONE) /* tune_flags. */ + (AARCH64_EXTRA_TUNE_SLOW_UNALIGNED_LDPW) /* tune_flags. */ }; static const struct tune_params xgene1_tunings = @@ -4191,6 +4191,24 @@ aarch64_legitimate_address_p (machine_mode mode, rtx x, return aarch64_classify_address (&addr, x, mode, outer_code, strict_p); } +/* Split an out-of-range address displacement into a base and offset. + Use 4KB range for 1- and 2-byte accesses and a 16KB range otherwise + to increase opportunities for sharing the base address of different sizes. + For TI/TFmode and unaligned accesses use a 256-byte range. */ +static bool +aarch64_legitimize_address_displacement (rtx *disp, rtx *off, machine_mode mode) +{ + HOST_WIDE_INT mask = GET_MODE_SIZE (mode) < 4 ? 0xfff : 0x3fff; + + if (mode == TImode || mode == TFmode || + (INTVAL (*disp) & (GET_MODE_SIZE (mode) - 1)) != 0) + mask = 0xff; + + *off = GEN_INT (INTVAL (*disp) & ~mask); + *disp = GEN_INT (INTVAL (*disp) & mask); + return true; +} + /* Return TRUE if rtx X is immediate constant 0.0 */ bool aarch64_float_const_zero_rtx_p (rtx x) @@ -4264,6 +4282,14 @@ aarch64_select_cc_mode (RTX_CODE code, rtx x, rtx y) && (GET_MODE (x) == HImode || GET_MODE (x) == QImode)) return CC_NZmode; + /* Similarly, comparisons of zero_extends from shorter modes can + be performed using an ANDS with an immediate mask. */ + if (y == const0_rtx && GET_CODE (x) == ZERO_EXTEND + && (GET_MODE (x) == SImode || GET_MODE (x) == DImode) + && (GET_MODE (XEXP (x, 0)) == HImode || GET_MODE (XEXP (x, 0)) == QImode) + && (code == EQ || code == NE)) + return CC_NZmode; + if ((GET_MODE (x) == SImode || GET_MODE (x) == DImode) && y == const0_rtx && (code == EQ || code == NE || code == LT || code == GE) @@ -5056,9 +5082,19 @@ aarch64_legitimize_address (rtx x, rtx /* orig_x */, machine_mode mode) /* For offsets aren't a multiple of the access size, the limit is -256...255. */ else if (offset & (GET_MODE_SIZE (mode) - 1)) - base_offset = (offset + 0x100) & ~0x1ff; + { + base_offset = (offset + 0x100) & ~0x1ff; + + /* BLKmode typically uses LDP of X-registers. */ + if (mode == BLKmode) + base_offset = (offset + 512) & ~0x3ff; + } + /* Small negative offsets are supported. */ + else if (IN_RANGE (offset, -256, 0)) + base_offset = 0; + /* Use 12-bit offset by access size. */ else - base_offset = offset & ~0xfff; + base_offset = offset & (~0xfff * GET_MODE_SIZE (mode)); if (base_offset != 0) { @@ -13593,6 +13629,15 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load, if (MEM_VOLATILE_P (mem_1) || MEM_VOLATILE_P (mem_2)) return false; + /* If we have SImode and slow unaligned ldp, + check the alignment to be at least 8 byte. */ + if (mode == SImode + && (aarch64_tune_params.extra_tuning_flags + & AARCH64_EXTRA_TUNE_SLOW_UNALIGNED_LDPW) + && !optimize_size + && MEM_ALIGN (mem_1) < 8 * BITS_PER_UNIT) + return false; + /* Check if the addresses are in the form of [base+offset]. */ extract_base_offset_in_addr (mem_1, &base_1, &offset_1); if (base_1 == NULL_RTX || offset_1 == NULL_RTX) @@ -13752,6 +13797,15 @@ aarch64_operands_adjust_ok_for_ldpstp (rtx *operands, bool load, return false; } + /* If we have SImode and slow unaligned ldp, + check the alignment to be at least 8 byte. */ + if (mode == SImode + && (aarch64_tune_params.extra_tuning_flags + & AARCH64_EXTRA_TUNE_SLOW_UNALIGNED_LDPW) + && !optimize_size + && MEM_ALIGN (mem_1) < 8 * BITS_PER_UNIT) + return false; + if (REG_P (reg_1) && FP_REGNUM_P (REGNO (reg_1))) rclass_1 = FP_REGS; else @@ -14127,12 +14181,13 @@ aarch64_optab_supported_p (int op, machine_mode mode1, machine_mode, #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P aarch64_legitimate_constant_p +#undef TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT +#define TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT \ + aarch64_legitimize_address_displacement + #undef TARGET_LIBGCC_CMP_RETURN_MODE #define TARGET_LIBGCC_CMP_RETURN_MODE aarch64_libgcc_cmp_return_mode -#undef TARGET_LRA_P -#define TARGET_LRA_P hook_bool_void_true - #undef TARGET_MANGLE_TYPE #define TARGET_MANGLE_TYPE aarch64_mangle_type diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index c95258b7103..6afaf906915 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -3811,6 +3811,18 @@ [(set_attr "type" "alus_imm")] ) +(define_insn "*ands<mode>_compare0" + [(set (reg:CC_NZ CC_REGNUM) + (compare:CC_NZ + (zero_extend:GPI (match_operand:SHORT 1 "register_operand" "r")) + (const_int 0))) + (set (match_operand:GPI 0 "register_operand" "=r") + (zero_extend:GPI (match_dup 1)))] + "" + "ands\\t%<GPI:w>0, %<GPI:w>1, <short_mask>" + [(set_attr "type" "alus_imm")] +) + (define_insn "*and<mode>3nr_compare0" [(set (reg:CC_NZ CC_REGNUM) (compare:CC_NZ diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 702cd277ede..6d4af04dd7d 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -5754,8 +5754,29 @@ static bool alpha_pass_by_reference (cumulative_args_t ca ATTRIBUTE_UNUSED, machine_mode mode, const_tree type ATTRIBUTE_UNUSED, - bool named ATTRIBUTE_UNUSED) + bool named) { + /* Pass float and _Complex float variable arguments by reference. + This avoids 64-bit store from a FP register to a pretend args save area + and subsequent 32-bit load from the saved location to a FP register. + + Note that 32-bit loads and stores to/from a FP register on alpha reorder + bits to form a canonical 64-bit value in the FP register. This fact + invalidates compiler assumption that 32-bit FP value lives in the lower + 32-bits of the passed 64-bit FP value, so loading the 32-bit value from + the stored 64-bit location using 32-bit FP load is invalid on alpha. + + This introduces sort of ABI incompatibility, but until _Float32 was + introduced, C-family languages promoted 32-bit float variable arg to + a 64-bit double, and it was not allowed to pass float as a varible + argument. Passing _Complex float as a variable argument never + worked on alpha. Thus, we have no backward compatibility issues + to worry about, and passing unpromoted _Float32 and _Complex float + as a variable argument will actually work in the future. */ + + if (mode == SFmode || mode == SCmode) + return !named; + return mode == TFmode || mode == TCmode; } @@ -10039,6 +10060,9 @@ alpha_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) #define TARGET_MANGLE_TYPE alpha_mangle_type #endif +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P alpha_legitimate_address_p diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 946f308ca84..1183d45d497 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -355,9 +355,6 @@ static const struct attribute_spec arm_attribute_table[] = #undef TARGET_LEGITIMIZE_ADDRESS #define TARGET_LEGITIMIZE_ADDRESS arm_legitimize_address -#undef TARGET_LRA_P -#define TARGET_LRA_P hook_bool_void_true - #undef TARGET_ATTRIBUTE_TABLE #define TARGET_ATTRIBUTE_TABLE arm_attribute_table diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index f6d73423728..148a61df721 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -13843,6 +13843,9 @@ avr_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, tree *arg, #undef TARGET_CONVERT_TO_TYPE #define TARGET_CONVERT_TO_TYPE avr_convert_to_type +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ADDR_SPACE_SUBSET_P #define TARGET_ADDR_SPACE_SUBSET_P avr_addr_space_subset_p diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 086d5482706..e1e39459201 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -5805,6 +5805,9 @@ bfin_conditional_register_usage (void) #undef TARGET_RETURN_IN_MEMORY #define TARGET_RETURN_IN_MEMORY bfin_return_in_memory +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P bfin_legitimate_address_p diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index d75948260fc..cd7c1bb4559 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -6748,6 +6748,9 @@ c6x_debug_unwind_info (void) #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P c6x_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_IN_SMALL_DATA_P #define TARGET_IN_SMALL_DATA_P c6x_in_small_data_p #undef TARGET_ASM_SELECT_RTX_SECTION diff --git a/gcc/config/cr16/cr16.c b/gcc/config/cr16/cr16.c index 141b8bc895f..2f75ca2301b 100644 --- a/gcc/config/cr16/cr16.c +++ b/gcc/config/cr16/cr16.c @@ -172,6 +172,9 @@ static void cr16_print_operand_address (FILE *, machine_mode, rtx); #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P cr16_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + /* Returning function value. */ #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE cr16_function_value diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 971d07fb12a..203819381e1 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -212,6 +212,9 @@ int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION; #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS cris_init_libfuncs +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P cris_legitimate_address_p @@ -1282,8 +1285,7 @@ cris_return_address_on_stack_for_return (void) : cris_return_address_on_stack (); } -/* This used to be the INITIAL_FRAME_POINTER_OFFSET worker; now only - handles FP -> SP elimination offset. */ +/* This handles FP -> SP elimination offset. */ static int cris_initial_frame_pointer_offset (void) diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index 62c72596461..7eb096b4577 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -91,9 +91,9 @@ extern void darwin_globalize_label (FILE *, const char *); extern void darwin_assemble_visibility (tree, int); extern void darwin_asm_output_dwarf_delta (FILE *, int, const char *, - const char *); + const char *, HOST_WIDE_INT); extern void darwin_asm_output_dwarf_offset (FILE *, int, const char *, - section *); + HOST_WIDE_INT, section *); extern void darwin_asm_declare_object_name (FILE *, const char *, tree); extern void darwin_asm_declare_constant_name (FILE *, const char *, diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 0055d805441..f8da9591be8 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -2790,7 +2790,8 @@ static int darwin_dwarf_label_counter; void darwin_asm_output_dwarf_delta (FILE *file, int size, - const char *lab1, const char *lab2) + const char *lab1, const char *lab2, + HOST_WIDE_INT offset) { int islocaldiff = (lab1[0] == '*' && lab1[1] == 'L' && lab2[0] == '*' && lab2[1] == 'L'); @@ -2804,6 +2805,8 @@ darwin_asm_output_dwarf_delta (FILE *file, int size, assemble_name_raw (file, lab1); fprintf (file, "-"); assemble_name_raw (file, lab2); + if (offset != 0) + fprintf (file, "+" HOST_WIDE_INT_PRINT_DEC, offset); if (islocaldiff) fprintf (file, "\n\t%s L$set$%d", directive, darwin_dwarf_label_counter++); } @@ -2815,7 +2818,7 @@ darwin_asm_output_dwarf_delta (FILE *file, int size, void darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab, - section *base) + HOST_WIDE_INT offset, section *base) { char sname[64]; int namelen; @@ -2826,7 +2829,7 @@ darwin_asm_output_dwarf_offset (FILE *file, int size, const char * lab, namelen = strchr (base->named.name + 8, ',') - (base->named.name + 8); sprintf (sname, "*Lsection%.*s", namelen, base->named.name + 8); - darwin_asm_output_dwarf_delta (file, size, lab, sname); + darwin_asm_output_dwarf_delta (file, size, lab, sname, offset); } /* Called from the within the TARGET_ASM_FILE_START for each target. */ diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 944548a7416..3782eb34047 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -835,10 +835,10 @@ enum machopic_addr_class { ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr) #define ASM_OUTPUT_DWARF_DELTA(FILE,SIZE,LABEL1,LABEL2) \ - darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2) + darwin_asm_output_dwarf_delta (FILE, SIZE, LABEL1, LABEL2, 0) -#define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,BASE) \ - darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, BASE) +#define ASM_OUTPUT_DWARF_OFFSET(FILE,SIZE,LABEL,OFFSET,BASE) \ + darwin_asm_output_dwarf_offset (FILE, SIZE, LABEL, OFFSET, BASE) #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(ASM_OUT_FILE, ENCODING, SIZE, ADDR, DONE) \ if (ENCODING == ASM_PREFERRED_EH_DATA_FORMAT (2, 1)) { \ diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c index 25cbdfc6982..b871ccb3feb 100644 --- a/gcc/config/epiphany/epiphany.c +++ b/gcc/config/epiphany/epiphany.c @@ -102,6 +102,8 @@ static rtx_insn *frame_insn (rtx); #define TARGET_SCHED_ISSUE_RATE epiphany_issue_rate #define TARGET_SCHED_ADJUST_COST epiphany_adjust_cost +#define TARGET_LRA_P hook_bool_void_false + #define TARGET_LEGITIMATE_ADDRESS_P epiphany_legitimate_address_p #define TARGET_SECONDARY_RELOAD epiphany_secondary_reload diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c index f4fef2b3f04..741a0136640 100644 --- a/gcc/config/fr30/fr30.c +++ b/gcc/config/fr30/fr30.c @@ -179,6 +179,9 @@ static int fr30_num_arg_regs (machine_mode, const_tree); #undef TARGET_CAN_ELIMINATE #define TARGET_CAN_ELIMINATE fr30_can_eliminate +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ASM_TRAMPOLINE_TEMPLATE #define TARGET_ASM_TRAMPOLINE_TEMPLATE fr30_asm_trampoline_template #undef TARGET_TRAMPOLINE_INIT diff --git a/gcc/config/fr30/fr30.h b/gcc/config/fr30/fr30.h index 51a05db9c2d..82366e35415 100644 --- a/gcc/config/fr30/fr30.h +++ b/gcc/config/fr30/fr30.h @@ -460,9 +460,8 @@ enum reg_class {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM} \ } -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It specifies the - initial difference between the specified pair of registers. This macro must - be defined if `ELIMINABLE_REGS' is defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ (OFFSET) = fr30_compute_frame_size (FROM, TO) diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 957ff0390a0..60c3863bbad 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -491,6 +491,9 @@ static bool frv_class_likely_spilled_p (reg_class_t); #undef TARGET_SECONDARY_RELOAD #define TARGET_SECONDARY_RELOAD frv_secondary_reload +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P frv_legitimate_address_p @@ -2076,9 +2079,8 @@ frv_can_eliminate (const int from, const int to) : true); } -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It specifies the - initial difference between the specified pair of registers. This macro must - be defined if `ELIMINABLE_REGS' is defined. */ +/* This function returns the initial difference between the specified + pair of registers. */ /* See frv_stack_info for more details on the frv stack frame. */ diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h index 8d41b6aa84a..e7f87b1ff88 100644 --- a/gcc/config/frv/frv.h +++ b/gcc/config/frv/frv.h @@ -1197,9 +1197,8 @@ typedef struct frv_stack { {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM} \ } -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It specifies the - initial difference between the specified pair of registers. This macro must - be defined if `ELIMINABLE_REGS' is defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ (OFFSET) = frv_initial_elimination_offset (FROM, TO) diff --git a/gcc/config/ft32/ft32.h b/gcc/config/ft32/ft32.h index dd40b1de0b6..6bfd4851fe6 100644 --- a/gcc/config/ft32/ft32.h +++ b/gcc/config/ft32/ft32.h @@ -250,8 +250,6 @@ enum reg_class pointer to a smaller address. */ #define STACK_GROWS_DOWNWARD 1 -#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0 - /* Offset from the frame pointer to the first local variable slot to be allocated. */ #define STARTING_FRAME_OFFSET 0 @@ -426,10 +424,8 @@ do { \ {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}} -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ do { \ (OFFSET) = ft32_initial_elimination_offset ((FROM), (TO)); \ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 1818684c72b..db8eeab3361 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -6097,6 +6097,9 @@ h8300_trampoline_init (rtx m_tramp, tree fndecl, rtx cxt) #undef TARGET_HARD_REGNO_SCRATCH_OK #define TARGET_HARD_REGNO_SCRATCH_OK h8300_hard_regno_scratch_ok +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P h8300_legitimate_address_p diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index d6c2254b800..60e11b481e9 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -102,13 +102,16 @@ along with GCC; see the file COPYING3. If not see /* Use section relative relocations for debugging offsets. Unlike other targets that fake this by putting the section VMA at 0, PE won't allow it. */ -#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION) \ +#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \ do { \ switch (SIZE) \ { \ case 4: \ fputs ("\t.secrel32\t", FILE); \ assemble_name (FILE, LABEL); \ + if ((OFFSET) != 0) \ + fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \ + (HOST_WIDE_INT) (OFFSET)) \ break; \ case 8: \ /* This is a hack. There is no 64-bit section relative \ @@ -118,6 +121,9 @@ along with GCC; see the file COPYING3. If not see Fake the 64-bit offset by zero-extending it. */ \ fputs ("\t.secrel32\t", FILE); \ assemble_name (FILE, LABEL); \ + if ((OFFSET) != 0) \ + fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \ + (HOST_WIDE_INT) (OFFSET)) \ fputs ("\n\t.long\t0", FILE); \ break; \ default: \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a229a738399..60b81bbb8ab 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2162,45 +2162,45 @@ const struct processor_costs *ix86_tune_cost = &pentium_cost; const struct processor_costs *ix86_cost = &pentium_cost; /* Processor feature/optimization bitmasks. */ -#define m_386 (1<<PROCESSOR_I386) -#define m_486 (1<<PROCESSOR_I486) -#define m_PENT (1<<PROCESSOR_PENTIUM) -#define m_LAKEMONT (1<<PROCESSOR_LAKEMONT) -#define m_PPRO (1<<PROCESSOR_PENTIUMPRO) -#define m_PENT4 (1<<PROCESSOR_PENTIUM4) -#define m_NOCONA (1<<PROCESSOR_NOCONA) +#define m_386 (1U<<PROCESSOR_I386) +#define m_486 (1U<<PROCESSOR_I486) +#define m_PENT (1U<<PROCESSOR_PENTIUM) +#define m_LAKEMONT (1U<<PROCESSOR_LAKEMONT) +#define m_PPRO (1U<<PROCESSOR_PENTIUMPRO) +#define m_PENT4 (1U<<PROCESSOR_PENTIUM4) +#define m_NOCONA (1U<<PROCESSOR_NOCONA) #define m_P4_NOCONA (m_PENT4 | m_NOCONA) -#define m_CORE2 (1<<PROCESSOR_CORE2) -#define m_NEHALEM (1<<PROCESSOR_NEHALEM) -#define m_SANDYBRIDGE (1<<PROCESSOR_SANDYBRIDGE) -#define m_HASWELL (1<<PROCESSOR_HASWELL) +#define m_CORE2 (1U<<PROCESSOR_CORE2) +#define m_NEHALEM (1U<<PROCESSOR_NEHALEM) +#define m_SANDYBRIDGE (1U<<PROCESSOR_SANDYBRIDGE) +#define m_HASWELL (1U<<PROCESSOR_HASWELL) #define m_CORE_ALL (m_CORE2 | m_NEHALEM | m_SANDYBRIDGE | m_HASWELL) -#define m_BONNELL (1<<PROCESSOR_BONNELL) -#define m_SILVERMONT (1<<PROCESSOR_SILVERMONT) -#define m_KNL (1<<PROCESSOR_KNL) -#define m_SKYLAKE_AVX512 (1<<PROCESSOR_SKYLAKE_AVX512) -#define m_INTEL (1<<PROCESSOR_INTEL) - -#define m_GEODE (1<<PROCESSOR_GEODE) -#define m_K6 (1<<PROCESSOR_K6) +#define m_BONNELL (1U<<PROCESSOR_BONNELL) +#define m_SILVERMONT (1U<<PROCESSOR_SILVERMONT) +#define m_KNL (1U<<PROCESSOR_KNL) +#define m_SKYLAKE_AVX512 (1U<<PROCESSOR_SKYLAKE_AVX512) +#define m_INTEL (1U<<PROCESSOR_INTEL) + +#define m_GEODE (1U<<PROCESSOR_GEODE) +#define m_K6 (1U<<PROCESSOR_K6) #define m_K6_GEODE (m_K6 | m_GEODE) -#define m_K8 (1<<PROCESSOR_K8) -#define m_ATHLON (1<<PROCESSOR_ATHLON) +#define m_K8 (1U<<PROCESSOR_K8) +#define m_ATHLON (1U<<PROCESSOR_ATHLON) #define m_ATHLON_K8 (m_K8 | m_ATHLON) -#define m_AMDFAM10 (1<<PROCESSOR_AMDFAM10) -#define m_BDVER1 (1<<PROCESSOR_BDVER1) -#define m_BDVER2 (1<<PROCESSOR_BDVER2) -#define m_BDVER3 (1<<PROCESSOR_BDVER3) -#define m_BDVER4 (1<<PROCESSOR_BDVER4) -#define m_ZNVER1 (1<<PROCESSOR_ZNVER1) -#define m_BTVER1 (1<<PROCESSOR_BTVER1) -#define m_BTVER2 (1<<PROCESSOR_BTVER2) +#define m_AMDFAM10 (1U<<PROCESSOR_AMDFAM10) +#define m_BDVER1 (1U<<PROCESSOR_BDVER1) +#define m_BDVER2 (1U<<PROCESSOR_BDVER2) +#define m_BDVER3 (1U<<PROCESSOR_BDVER3) +#define m_BDVER4 (1U<<PROCESSOR_BDVER4) +#define m_ZNVER1 (1U<<PROCESSOR_ZNVER1) +#define m_BTVER1 (1U<<PROCESSOR_BTVER1) +#define m_BTVER2 (1U<<PROCESSOR_BTVER2) #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4) #define m_BTVER (m_BTVER1 | m_BTVER2) #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \ | m_ZNVER1) -#define m_GENERIC (1<<PROCESSOR_GENERIC) +#define m_GENERIC (1U<<PROCESSOR_GENERIC) const char* ix86_tune_feature_names[X86_TUNE_LAST] = { #undef DEF_TUNE @@ -4516,6 +4516,7 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) const struct stringop_algs *default_algs; stringop_size_range input_ranges[MAX_STRINGOP_ALGS]; char *curr_range_str, *next_range_str; + const char *opt = is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="; int i = 0, n = 0; if (is_memset) @@ -4537,15 +4538,13 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) if (3 != sscanf (curr_range_str, "%20[^:]:%d:%10s", alg_name, &maxs, align)) { - error ("wrong arg %s to option %s", curr_range_str, - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("wrong argument %qs to option %qs", curr_range_str, opt); return; } if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1)) { - error ("size ranges of option %s should be increasing", - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("size ranges of option %qs should be increasing", opt); return; } @@ -4555,9 +4554,25 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) if (i == last_alg) { - error ("wrong stringop strategy name %s specified for option %s", - alg_name, - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("wrong strategy name %qs specified for option %qs", + alg_name, opt); + + auto_vec <const char *> candidates; + for (i = 0; i < last_alg; i++) + if ((stringop_alg) i != rep_prefix_8_byte || TARGET_64BIT) + candidates.safe_push (stringop_alg_names[i]); + + char *s; + const char *hint + = candidates_list_and_hint (alg_name, s, candidates); + if (hint) + inform (input_location, + "valid arguments to %qs are: %s; did you mean %qs?", + opt, s, hint); + else + inform (input_location, "valid arguments to %qs are: %s", + opt, s); + XDELETEVEC (s); return; } @@ -4565,10 +4580,8 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) && !TARGET_64BIT) { /* rep; movq isn't available in 32-bit code. */ - error ("stringop strategy name %s specified for option %s " - "not supported for 32-bit code", - alg_name, - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("strategy name %qs specified for option %qs " + "not supported for 32-bit code", alg_name, opt); return; } @@ -4580,8 +4593,7 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) input_ranges[n].noalign = true; else { - error ("unknown alignment %s specified for option %s", - align, is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("unknown alignment %qs specified for option %qs", align, opt); return; } n++; @@ -4592,15 +4604,13 @@ ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset) if (input_ranges[n - 1].max != -1) { error ("the max value for the last size range should be -1" - " for option %s", - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + " for option %qs", opt); return; } if (n > MAX_STRINGOP_ALGS) { - error ("too many size ranges specified in option %s", - is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy="); + error ("too many size ranges specified in option %qs", opt); return; } @@ -4731,9 +4741,6 @@ ix86_option_override_internal (bool main_args_p, int i; unsigned int ix86_arch_mask; const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL); - const char *prefix; - const char *suffix; - const char *sw; #define PTA_3DNOW (HOST_WIDE_INT_1 << 0) #define PTA_3DNOW_A (HOST_WIDE_INT_1 << 1) @@ -5031,21 +5038,6 @@ ix86_option_override_internal (bool main_args_p, int const pta_size = ARRAY_SIZE (processor_alias_table); - /* Set up prefix/suffix so the error messages refer to either the command - line argument, or the attribute(target). */ - if (main_args_p) - { - prefix = "-m"; - suffix = ""; - sw = "switch"; - } - else - { - prefix = "option(\""; - suffix = "\")"; - sw = "attribute"; - } - /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */ if (TARGET_64BIT_DEFAULT && !TARGET_64BIT_P (opts->x_ix86_isa_flags)) @@ -5118,9 +5110,13 @@ ix86_option_override_internal (bool main_args_p, opts->x_ix86_tune_string = "generic"; } else if (!strcmp (opts->x_ix86_tune_string, "x86-64")) - warning (OPT_Wdeprecated, "%stune=x86-64%s is deprecated; use " - "%stune=k8%s or %stune=generic%s instead as appropriate", - prefix, suffix, prefix, suffix, prefix, suffix); + warning (OPT_Wdeprecated, + main_args_p + ? "%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> " + "or %<-mtune=generic%> instead as appropriate" + : "%<target(\"tune=x86-64\")%> is deprecated; use " + "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%> " + "instead as appropriate"); } else { @@ -5474,14 +5470,48 @@ ix86_option_override_internal (bool main_args_p, error ("Intel MPX does not support x32"); if (!strcmp (opts->x_ix86_arch_string, "generic")) - error ("generic CPU can be used only for %stune=%s %s", - prefix, suffix, sw); + error (main_args_p + ? "%<generic%> CPU can be used only for %<-mtune=%> switch" + : "%<generic%> CPU can be used only for " + "%<target(\"tune=\")%> attribute"); else if (!strcmp (opts->x_ix86_arch_string, "intel")) - error ("intel CPU can be used only for %stune=%s %s", - prefix, suffix, sw); + error (main_args_p + ? "%<intel%> CPU can be used only for %<-mtune=%> switch" + : "%<intel%> CPU can be used only for " + "%<target(\"tune=\")%> attribute"); else if (i == pta_size) - error ("bad value (%s) for %sarch=%s %s", - opts->x_ix86_arch_string, prefix, suffix, sw); + { + error (main_args_p + ? "bad value (%qs) for %<-march=%> switch" + : "bad value (%qs) for %<target(\"arch=\")%> attribute", + opts->x_ix86_arch_string); + + auto_vec <const char *> candidates; + for (i = 0; i < pta_size; i++) + if (strcmp (processor_alias_table[i].name, "generic") + && strcmp (processor_alias_table[i].name, "intel") + && (!TARGET_64BIT_P (opts->x_ix86_isa_flags) + || (processor_alias_table[i].flags & PTA_64BIT))) + candidates.safe_push (processor_alias_table[i].name); + + char *s; + const char *hint + = candidates_list_and_hint (opts->x_ix86_arch_string, s, candidates); + if (hint) + inform (input_location, + main_args_p + ? "valid arguments to %<-march=%> switch are: " + "%s; did you mean %qs?" + : "valid arguments to %<target(\"arch=\")%> attribute are: " + "%s; did you mean %qs?", s, hint); + else + inform (input_location, + main_args_p + ? "valid arguments to %<-march=%> switch are: %s" + : "valid arguments to %<target(\"arch=\")%> attribute are: %s", + s); + XDELETEVEC (s); + } ix86_arch_mask = 1u << ix86_arch; for (i = 0; i < X86_ARCH_LAST; ++i) @@ -5523,8 +5553,36 @@ ix86_option_override_internal (bool main_args_p, } if (ix86_tune_specified && i == pta_size) - error ("bad value (%s) for %stune=%s %s", - opts->x_ix86_tune_string, prefix, suffix, sw); + { + error (main_args_p + ? "bad value (%qs) for %<-mtune=%> switch" + : "bad value (%qs) for %<target(\"tune=\")%> attribute", + opts->x_ix86_tune_string); + + auto_vec <const char *> candidates; + for (i = 0; i < pta_size; i++) + if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) + || (processor_alias_table[i].flags & PTA_64BIT)) + candidates.safe_push (processor_alias_table[i].name); + + char *s; + const char *hint + = candidates_list_and_hint (opts->x_ix86_tune_string, s, candidates); + if (hint) + inform (input_location, + main_args_p + ? "valid arguments to %<-mtune=%> switch are: " + "%s; did you mean %qs?" + : "valid arguments to %<target(\"tune=\")%> attribute are: " + "%s; did you mean %qs?", s, hint); + else + inform (input_location, + main_args_p + ? "valid arguments to %<-mtune=%> switch are: %s" + : "valid arguments to %<target(\"tune=\")%> attribute are: %s", + s); + XDELETEVEC (s); + } set_ix86_tune_features (ix86_tune, opts->x_ix86_dump_tunes); @@ -5623,7 +5681,9 @@ ix86_option_override_internal (bool main_args_p, & ~opts->x_ix86_isa_flags_explicit); if (TARGET_RTD_P (opts->x_target_flags)) - warning (0, "%srtd%s is ignored in 64bit mode", prefix, suffix); + warning (0, + main_args_p ? "%<-mrtd%> is ignored in 64bit mode" + : "%<target(\"rtd\")%> is ignored in 64bit mode"); } else { @@ -5744,7 +5804,9 @@ ix86_option_override_internal (bool main_args_p, /* Accept -msseregparm only if at least SSE support is enabled. */ if (TARGET_SSEREGPARM_P (opts->x_target_flags) && ! TARGET_SSE_P (opts->x_ix86_isa_flags)) - error ("%ssseregparm%s used without SSE enabled", prefix, suffix); + error (main_args_p + ? "%<-msseregparm%> used without SSE enabled" + : "%<target(\"sseregparm\")%> used without SSE enabled"); if (opts_set->x_ix86_fpmath) { @@ -5809,8 +5871,12 @@ ix86_option_override_internal (bool main_args_p, && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)) { if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS) - warning (0, "stack probing requires %saccumulate-outgoing-args%s " - "for correctness", prefix, suffix); + warning (0, + main_args_p + ? "stack probing requires %<-maccumulate-outgoing-args%> " + "for correctness" + : "stack probing requires " + "%<target(\"accumulate-outgoing-args\")%> for correctness"); opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS; } @@ -5820,8 +5886,11 @@ ix86_option_override_internal (bool main_args_p, && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)) { if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS) - warning (0, "fixed ebp register requires %saccumulate-outgoing-args%s", - prefix, suffix); + warning (0, + main_args_p + ? "fixed ebp register requires %<-maccumulate-outgoing-args%>" + : "fixed ebp register requires " + "%<target(\"accumulate-outgoing-args\")%>"); opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS; } @@ -5957,11 +6026,12 @@ ix86_option_override_internal (bool main_args_p, if (!(opts_set->x_target_flags & MASK_STV)) opts->x_target_flags |= MASK_STV; /* Disable STV if -mpreferred-stack-boundary={2,3} or - -mincoming-stack-boundary={2,3} - the needed + -mincoming-stack-boundary={2,3} or -mstackrealign - the needed stack realignment will be extra cost the pass doesn't take into account and the pass can't realign the stack. */ if (ix86_preferred_stack_boundary < 128 - || ix86_incoming_stack_boundary < 128) + || ix86_incoming_stack_boundary < 128 + || opts->x_ix86_force_align_arg_pointer) opts->x_target_flags &= ~MASK_STV; if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL] && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD)) @@ -34861,7 +34931,6 @@ ix86_expand_args_builtin (const struct builtin_description *d, case V4DI_FTYPE_V4DI_V4DI_V4DI_INT_UQI: case V4SI_FTYPE_V4SI_V4SI_V4SI_INT_UQI: case V2DI_FTYPE_V2DI_V2DI_V2DI_INT_UQI: - nargs = 5; nargs = 5; mask_pos = 1; nargs_constant = 1; @@ -36107,7 +36176,7 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, error ("%qE needs isa option %s", fndecl, opts); free (opts); } - return const0_rtx; + return expand_call (exp, target, ignore); } switch (fcode) @@ -48562,14 +48631,6 @@ ix86_fn_abi_va_list (tree fndecl) static tree ix86_canonical_va_list_type (tree type) { - /* Resolve references and pointers to va_list type. */ - if (TREE_CODE (type) == MEM_REF) - type = TREE_TYPE (type); - else if (POINTER_TYPE_P (type) && POINTER_TYPE_P (TREE_TYPE(type))) - type = TREE_TYPE (type); - else if (POINTER_TYPE_P (type) && TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE) - type = TREE_TYPE (type); - if (TARGET_64BIT) { if (lookup_attribute ("ms_abi va_list", TYPE_ATTRIBUTES (type))) @@ -50628,9 +50689,6 @@ ix86_addr_space_zero_address_valid (addr_space_t as) #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P ix86_legitimate_address_p -#undef TARGET_LRA_P -#define TARGET_LRA_P hook_bool_void_true - #undef TARGET_REGISTER_PRIORITY #define TARGET_REGISTER_PRIORITY ix86_register_priority diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 0deecb1b366..e3c9eadde85 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -799,7 +799,7 @@ sse2,sse2_noavx,sse3,sse4,sse4_noavx,avx,noavx, avx2,noavx2,bmi,bmi2,fma4,fma,avx512f,noavx512f, fma_avx512f,avx512bw,noavx512bw,avx512dq,noavx512dq, - avx512vl,noavx512vl,x64_avx512dq" + avx512vl,noavx512vl,x64_avx512dq,x64_avx512bw" (const_string "base")) (define_attr "enabled" "" @@ -812,6 +812,8 @@ (symbol_ref "TARGET_64BIT && TARGET_AVX") (eq_attr "isa" "x64_avx512dq") (symbol_ref "TARGET_64BIT && TARGET_AVX512DQ") + (eq_attr "isa" "x64_avx512bw") + (symbol_ref "TARGET_64BIT && TARGET_AVX512BW") (eq_attr "isa" "nox64") (symbol_ref "!TARGET_64BIT") (eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2") (eq_attr "isa" "sse2_noavx") @@ -3735,12 +3737,14 @@ [(set (attr "isa") (cond [(eq_attr "alternative" "0,1,2") (const_string "nox64") - (eq_attr "alternative" "3,7,11") + (eq_attr "alternative" "3,7") (const_string "x64") (eq_attr "alternative" "8") (const_string "x64_sse4") (eq_attr "alternative" "10") (const_string "sse2") + (eq_attr "alternative" "11") + (const_string "x64_avx512bw") ] (const_string "*"))) (set (attr "type") @@ -3804,6 +3808,9 @@ (set (match_dup 4) (const_int 0))] "split_double_mode (DImode, &operands[0], 1, &operands[3], &operands[4]);") +(define_mode_attr kmov_isa + [(QI "avx512dq") (HI "avx512f") (SI "avx512bw") (DI "avx512bw")]) + (define_insn "zero_extend<mode>di2" [(set (match_operand:DI 0 "register_operand" "=r,*r") (zero_extend:DI @@ -3812,7 +3819,8 @@ "@ movz{<imodesuffix>l|x}\t{%1, %k0|%k0, %1} kmov<mskmodesuffix>\t{%1, %k0|%k0, %1}" - [(set_attr "type" "imovx,mskmov") + [(set_attr "isa" "*,<kmov_isa>") + (set_attr "type" "imovx,mskmov") (set_attr "mode" "SI")]) (define_expand "zero_extend<mode>si2" @@ -3863,7 +3871,8 @@ "@ movz{<imodesuffix>l|x}\t{%1, %0|%0, %1} kmov<mskmodesuffix>\t{%1, %0|%0, %1}" - [(set_attr "type" "imovx,mskmov") + [(set_attr "isa" "*,<kmov_isa>") + (set_attr "type" "imovx,mskmov") (set_attr "mode" "SI,<MODE>")]) (define_expand "zero_extendqihi2" @@ -3914,6 +3923,7 @@ movz{bl|x}\t{%1, %k0|%k0, %1} kmovb\t{%1, %k0|%k0, %1}" [(set_attr "type" "imovx,mskmov") + (set_attr "isa" "*,avx512dq") (set_attr "mode" "SI,QI")]) (define_insn_and_split "*zext<mode>_doubleword_and" diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index 4b9910fa902..22731706a25 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -79,13 +79,23 @@ along with GCC; see the file COPYING3. If not see #endif #endif +#ifdef HAVE_LD_PUSHPOPSTATE_SUPPORT +#define MPX_LD_AS_NEEDED_GUARD_PUSH "--push-state --no-as-needed" +#define MPX_LD_AS_NEEDED_GUARD_POP "--pop-state" +#else +#define MPX_LD_AS_NEEDED_GUARD_PUSH "" +#define MPX_LD_AS_NEEDED_GUARD_POP "" +#endif + #ifndef LIBMPX_SPEC #if defined(HAVE_LD_STATIC_DYNAMIC) #define LIBMPX_SPEC "\ %{mmpx:%{fcheck-pointer-bounds:\ %{static:--whole-archive -lmpx --no-whole-archive" LIBMPX_LIBS "}\ %{!static:%{static-libmpx:" LD_STATIC_OPTION " --whole-archive}\ - -lmpx %{static-libmpx:--no-whole-archive " LD_DYNAMIC_OPTION \ + %{!static-libmpx:" MPX_LD_AS_NEEDED_GUARD_PUSH "} -lmpx \ + %{!static-libmpx:" MPX_LD_AS_NEEDED_GUARD_POP "} \ + %{static-libmpx:--no-whole-archive " LD_DYNAMIC_OPTION \ LIBMPX_LIBS "}}}}" #else #define LIBMPX_SPEC "\ @@ -98,8 +108,8 @@ along with GCC; see the file COPYING3. If not see #define LIBMPXWRAPPERS_SPEC "\ %{mmpx:%{fcheck-pointer-bounds:%{!fno-chkp-use-wrappers:\ %{static:-lmpxwrappers}\ - %{!static:%{static-libmpxwrappers:" LD_STATIC_OPTION " --whole-archive}\ - -lmpxwrappers %{static-libmpxwrappers:--no-whole-archive "\ + %{!static:%{static-libmpxwrappers:" LD_STATIC_OPTION "}\ + -lmpxwrappers %{static-libmpxwrappers: "\ LD_DYNAMIC_OPTION "}}}}}" #else #define LIBMPXWRAPPERS_SPEC "\ diff --git a/gcc/config/i386/x86-tune.def b/gcc/config/i386/x86-tune.def index 31a87b913b2..8c7a14d9022 100644 --- a/gcc/config/i386/x86-tune.def +++ b/gcc/config/i386/x86-tune.def @@ -535,15 +535,15 @@ DEF_TUNE (X86_TUNE_AVOID_FALSE_DEP_FOR_BMI, "avoid_false_dep_for_bmi", on simulation result. But after P4 was made, no performance benefit was observed with branch hints. It also increases the code size. As a result, icc never generates branch hints. */ -DEF_TUNE (X86_TUNE_BRANCH_PREDICTION_HINTS, "branch_prediction_hints", 0) +DEF_TUNE (X86_TUNE_BRANCH_PREDICTION_HINTS, "branch_prediction_hints", 0U) /* X86_TUNE_QIMODE_MATH: Enable use of 8bit arithmetic. */ -DEF_TUNE (X86_TUNE_QIMODE_MATH, "qimode_math", ~0) +DEF_TUNE (X86_TUNE_QIMODE_MATH, "qimode_math", ~0U) /* X86_TUNE_PROMOTE_QI_REGS: This enables generic code that promotes all 8bit arithmetic to 32bit via PROMOTE_MODE macro. This code generation scheme is usually used for RISC targets. */ -DEF_TUNE (X86_TUNE_PROMOTE_QI_REGS, "promote_qi_regs", 0) +DEF_TUNE (X86_TUNE_PROMOTE_QI_REGS, "promote_qi_regs", 0U) /* X86_TUNE_ADJUST_UNROLL: This enables adjusting the unroll factor based on hardware capabilities. Bdver3 hardware has a loop buffer which makes diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index ebd2c86b8d8..5f0bf43a103 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -603,6 +603,9 @@ static const struct attribute_spec ia64_attribute_table[] = #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P ia64_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_CANNOT_FORCE_CONST_MEM #define TARGET_CANNOT_FORCE_CONST_MEM ia64_cannot_force_const_mem diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index 4e1b7af6ab7..ac0cb864209 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -961,10 +961,8 @@ enum reg_class {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ } -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ ((OFFSET) = ia64_initial_elimination_offset ((FROM), (TO))) @@ -1583,11 +1581,14 @@ do { \ /* Use section-relative relocations for debugging offsets. Unlike other targets that fake this by putting the section VMA at 0, IA-64 has proper relocations for them. */ -#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION) \ +#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, OFFSET, SECTION) \ do { \ fputs (integer_asm_op (SIZE, FALSE), FILE); \ fputs ("@secrel(", FILE); \ assemble_name (FILE, LABEL); \ + if ((OFFSET) != 0) \ + fprintf (FILE, "+" HOST_WIDE_INT_PRINT_DEC, \ + (HOST_WIDE_INT) (OFFSET)); \ fputc (')', FILE); \ } while (0) diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 73b9cdb3fe0..c7e5f199b8f 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -237,6 +237,9 @@ static bool iq2000_print_operand_punct_valid_p (unsigned char code); #undef TARGET_EXPAND_BUILTIN_VA_START #define TARGET_EXPAND_BUILTIN_VA_START iq2000_va_start +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P iq2000_legitimate_address_p diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index 4a8079f4a74..8a102207f0d 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -99,6 +99,8 @@ static void lm32_function_arg_advance (cumulative_args_t cum, #define TARGET_MAX_ANCHOR_OFFSET 0x7fff #undef TARGET_CAN_ELIMINATE #define TARGET_CAN_ELIMINATE lm32_can_eliminate +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P lm32_legitimate_address_p diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index 6f6d7e4e45e..1db1ef7ade1 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -1632,6 +1632,9 @@ m32c_trampoline_init (rtx m_tramp, tree fndecl, rtx chainval) #undef A0 } +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + /* Addressing Modes */ /* The r8c/m32c family supports a wide range of non-orthogonal diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index b40c53ca189..943f8c7e253 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -119,6 +119,9 @@ static const struct attribute_spec m32r_attribute_table[] = #undef TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P #define TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P m32r_attribute_identifier +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P m32r_legitimate_address_p #undef TARGET_LEGITIMIZE_ADDRESS diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 2ff4a459dc4..cd74cfcf3b5 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -581,15 +581,6 @@ extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER]; /* Eliminating the frame and arg pointers. */ -#if 0 -/* C statement to store the difference between the frame pointer - and the stack pointer values immediately after the function prologue. - If `ELIMINABLE_REGS' is defined, this macro will be not be used and - need not be defined. */ -#define INITIAL_FRAME_POINTER_OFFSET(VAR) \ -((VAR) = m32r_compute_frame_size (get_frame_size ())) -#endif - /* If defined, this macro specifies a table of register pairs used to eliminate unneeded registers that point into the stack frame. If it is not defined, the only elimination attempted by the compiler @@ -604,10 +595,8 @@ extern enum reg_class m32r_regno_reg_class[FIRST_PSEUDO_REGISTER]; { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \ { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM }} -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ do \ diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 7cee0f59529..a104193c23c 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -289,6 +289,9 @@ static void m68k_init_sync_libfuncs (void) ATTRIBUTE_UNUSED; #define TARGET_ASM_OUTPUT_DWARF_DTPREL m68k_output_dwarf_dtprel #endif +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P m68k_legitimate_address_p diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index c9d0506afd5..3afe42c0c86 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -232,6 +232,9 @@ static const struct attribute_spec mcore_attribute_table[] = #undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P #define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P mcore_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_WARN_FUNC_RETURN #define TARGET_WARN_FUNC_RETURN mcore_warn_func_return diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 735dff52db2..e32fa0eca75 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -3810,6 +3810,9 @@ microblaze_machine_dependent_reorg (void) #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P microblaze_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_FRAME_POINTER_REQUIRED #define TARGET_FRAME_POINTER_REQUIRED microblaze_frame_pointer_required diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 3fffdc2e9af..bf06e3b1933 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -260,6 +260,9 @@ static void mmix_conditional_register_usage (void); #undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS mmix_preferred_output_reload_class +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P mmix_legitimate_address_p #undef TARGET_LEGITIMATE_CONSTANT_P diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index 6e590cd6a33..e384796873a 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -3379,6 +3379,9 @@ mn10300_reorg (void) #undef TARGET_CASE_VALUES_THRESHOLD #define TARGET_CASE_VALUES_THRESHOLD mn10300_case_values_threshold +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P mn10300_legitimate_address_p #undef TARGET_DELEGITIMIZE_ADDRESS diff --git a/gcc/config/moxie/moxie.c b/gcc/config/moxie/moxie.c index 4e38a57f828..9d376f1959b 100644 --- a/gcc/config/moxie/moxie.c +++ b/gcc/config/moxie/moxie.c @@ -624,6 +624,9 @@ moxie_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, #undef TARGET_FUNCTION_ARG_ADVANCE #define TARGET_FUNCTION_ARG_ADVANCE moxie_function_arg_advance +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P #define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P moxie_legitimate_address_p diff --git a/gcc/config/moxie/moxie.h b/gcc/config/moxie/moxie.h index b9cb38bf139..204e23c405b 100644 --- a/gcc/config/moxie/moxie.h +++ b/gcc/config/moxie/moxie.h @@ -243,8 +243,6 @@ enum reg_class pointer to a smaller address. */ #define STACK_GROWS_DOWNWARD 1 -#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0 - /* Offset from the frame pointer to the first local variable slot to be allocated. */ #define STARTING_FRAME_OFFSET 0 @@ -386,10 +384,8 @@ enum reg_class {{ FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }} -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ do { \ (OFFSET) = moxie_initial_elimination_offset ((FROM), (TO)); \ diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index dba4d198776..93431765562 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1490,6 +1490,9 @@ msp430_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, return addr; } +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + /* Addressing Modes */ #undef TARGET_LEGITIMATE_ADDRESS_P @@ -2108,6 +2111,13 @@ msp430_start_function (FILE *file, const char *name, tree decl) { char buf[101]; + /* Interrupt vector sections should be unique, but use of weak + functions implies multiple definitions. */ + if (DECL_WEAK (decl)) + { + error ("argument to interrupt attribute is unsupported for weak functions"); + } + intr_vector = TREE_VALUE (intr_vector); /* The interrupt attribute has a vector value. Turn this into a diff --git a/gcc/config/msp430/msp430.md b/gcc/config/msp430/msp430.md index bdec202660f..720dd7cc2ef 100644 --- a/gcc/config/msp430/msp430.md +++ b/gcc/config/msp430/msp430.md @@ -1459,7 +1459,7 @@ (match_operand 1 "immediate_operand" "i") ] UNS_DELAY_32X)] "" - "PUSHM.A #2,r13 + "PUSHM.A #2,r14 MOV.W %A0, r13 MOV.W %B0, r14 1: SUB.W #1, r13 @@ -1467,7 +1467,7 @@ JNE 1b TST.W r13 JNE 1b - POPM.A #2,r13" + POPM.A #2,r14" ) (define_insn "delay_cycles_16" diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index c47c122a817..8dbeba56576 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -3547,9 +3547,6 @@ nds32_target_alignment (rtx label) #undef TARGET_CLASS_MAX_NREGS #define TARGET_CLASS_MAX_NREGS nds32_class_max_nregs -#undef TARGET_LRA_P -#define TARGET_LRA_P hook_bool_void_true - #undef TARGET_REGISTER_PRIORITY #define TARGET_REGISTER_PRIORITY nds32_register_priority diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c index 18fcbb3266e..632adadb072 100644 --- a/gcc/config/nios2/nios2.c +++ b/gcc/config/nios2/nios2.c @@ -5038,6 +5038,9 @@ nios2_adjust_reg_alloc_order (void) #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P nios2_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_PREFERRED_RELOAD_CLASS #define TARGET_PREFERRED_RELOAD_CLASS nios2_preferred_reload_class diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 23b5078919e..16e04a4f726 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -4856,6 +4856,9 @@ nvptx_goacc_reduction (gcall *call) #undef TARGET_ATTRIBUTE_TABLE #define TARGET_ATTRIBUTE_TABLE nvptx_attribute_table +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P nvptx_legitimate_address_p diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md index e48412de6a6..d117343c531 100644 --- a/gcc/config/nvptx/nvptx.md +++ b/gcc/config/nvptx/nvptx.md @@ -541,7 +541,7 @@ [(set (pc) (if_then_else (match_operator 0 "nvptx_comparison_operator" [(match_operand:HSDIM 1 "nvptx_register_operand" "") - (match_operand:HSDIM 2 "nvptx_register_operand" "")]) + (match_operand:HSDIM 2 "nvptx_nonmemory_operand" "")]) (label_ref (match_operand 3 "" "")) (pc)))] "" @@ -556,7 +556,7 @@ [(set (pc) (if_then_else (match_operator 0 "nvptx_float_comparison_operator" [(match_operand:SDFM 1 "nvptx_register_operand" "") - (match_operand:SDFM 2 "nvptx_register_operand" "")]) + (match_operand:SDFM 2 "nvptx_nonmemory_operand" "")]) (label_ref (match_operand 3 "" "")) (pc)))] "" diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 251c1ada392..18b73249d27 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -397,6 +397,9 @@ static size_t n_deferred_plabels = 0; #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P pa_legitimate_address_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + struct gcc_target targetm = TARGET_INITIALIZER; /* Parse the -mfixed-range= option string. */ diff --git a/gcc/config/pa/pa64-linux.h b/gcc/config/pa/pa64-linux.h index 540bfa64c6c..4bf1f795c5e 100644 --- a/gcc/config/pa/pa64-linux.h +++ b/gcc/config/pa/pa64-linux.h @@ -28,10 +28,8 @@ along with GCC; see the file COPYING3. If not see {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \ } -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ do \ { \ diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 35d57c72488..7fa08cbf66a 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -208,6 +208,9 @@ static bool pdp11_scalar_mode_supported_p (machine_mode); #undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS pdp11_preferred_output_reload_class +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P pdp11_legitimate_address_p diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c index 3ddb19865b8..ecbf6f9b5f9 100644 --- a/gcc/config/rl78/rl78.c +++ b/gcc/config/rl78/rl78.c @@ -1071,6 +1071,9 @@ rl78_is_legitimate_constant (machine_mode mode ATTRIBUTE_UNUSED, rtx x ATTRIBUTE return true; } +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P #define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P rl78_as_legitimate_address diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md index c39a0b655b4..857f257edda 100644 --- a/gcc/config/rs6000/altivec.md +++ b/gcc/config/rs6000/altivec.md @@ -371,7 +371,7 @@ (define_insn "get_vrsave_internal" [(set (match_operand:SI 0 "register_operand" "=r") - (unspec:SI [(reg:SI 109)] UNSPEC_GET_VRSAVE))] + (unspec:SI [(reg:SI VRSAVE_REGNO)] UNSPEC_GET_VRSAVE))] "TARGET_ALTIVEC" { if (TARGET_MACHO) @@ -383,9 +383,9 @@ (define_insn "*set_vrsave_internal" [(match_parallel 0 "vrsave_operation" - [(set (reg:SI 109) + [(set (reg:SI VRSAVE_REGNO) (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r") - (reg:SI 109)] UNSPECV_SET_VRSAVE))])] + (reg:SI VRSAVE_REGNO)] UNSPECV_SET_VRSAVE))])] "TARGET_ALTIVEC" { if (TARGET_MACHO) @@ -397,7 +397,7 @@ (define_insn "*save_world" [(match_parallel 0 "save_world_operation" - [(clobber (reg:SI 65)) + [(clobber (reg:SI LR_REGNO)) (use (match_operand:SI 1 "call_operand" "s"))])] "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT" "bl %z1" @@ -407,7 +407,7 @@ (define_insn "*restore_world" [(match_parallel 0 "restore_world_operation" [(return) - (use (reg:SI 65)) + (use (reg:SI LR_REGNO)) (use (match_operand:SI 1 "call_operand" "s")) (clobber (match_operand:SI 2 "gpc_reg_operand" "=r"))])] "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT" @@ -421,7 +421,7 @@ ;; to describe the operation to dwarf2out_frame_debug_expr. (define_insn "*save_vregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (clobber (reg:P 11)) (use (reg:P 0)) @@ -435,7 +435,7 @@ (define_insn "*save_vregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (clobber (reg:P 12)) (use (reg:P 0)) @@ -449,7 +449,7 @@ (define_insn "*restore_vregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (clobber (reg:P 11)) (use (reg:P 0)) @@ -463,7 +463,7 @@ (define_insn "*restore_vregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (clobber (reg:P 12)) (use (reg:P 0)) @@ -508,7 +508,7 @@ (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VADDU)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "<VI_unit>" "vaddu<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]) @@ -518,7 +518,7 @@ (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VADDS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)" "vadds<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]) @@ -554,7 +554,7 @@ (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VSUBU)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)" "vsubu<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]) @@ -564,7 +564,7 @@ (unspec:VI [(match_operand:VI 1 "register_operand" "v") (match_operand:VI 2 "register_operand" "v")] UNSPEC_VSUBS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)" "vsubs<VI_char>s %0,%1,%2" [(set_attr "type" "vecsimple")]) @@ -830,7 +830,7 @@ (match_operand:V8HI 2 "register_operand" "v") (match_operand:V4SI 3 "register_operand" "v")] UNSPEC_VMSUMUHS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vmsumuhs %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) @@ -841,7 +841,7 @@ (match_operand:V8HI 2 "register_operand" "v") (match_operand:V4SI 3 "register_operand" "v")] UNSPEC_VMSUMSHS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vmsumshs %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) @@ -902,7 +902,7 @@ (match_operand:V8HI 2 "register_operand" "v") (match_operand:V8HI 3 "register_operand" "v")] UNSPEC_VMHADDSHS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vmhaddshs %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) @@ -913,7 +913,7 @@ (match_operand:V8HI 2 "register_operand" "v") (match_operand:V8HI 3 "register_operand" "v")] UNSPEC_VMHRADDSHS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vmhraddshs %0,%1,%2,%3" [(set_attr "type" "veccomplex")]) @@ -1699,7 +1699,7 @@ (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUM4UBS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vsum4ubs %0,%1,%2" [(set_attr "type" "veccomplex")]) @@ -1709,7 +1709,7 @@ (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUM4S)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vsum4s<VI_char>s %0,%1,%2" [(set_attr "type" "veccomplex")]) @@ -1722,7 +1722,7 @@ (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUM2SWS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR)) + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR)) (clobber (match_scratch:V4SI 3 "=v"))] "TARGET_ALTIVEC" { @@ -1743,7 +1743,7 @@ (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUMSWS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR)) + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR)) (clobber (match_scratch:V4SI 3 "=v"))] "TARGET_ALTIVEC" { @@ -1764,7 +1764,7 @@ (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v") (match_operand:V4SI 2 "register_operand" "v")] UNSPEC_VSUMSWS_DIRECT)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vsumsws %0,%1,%2" [(set_attr "type" "veccomplex")]) @@ -2124,7 +2124,7 @@ (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v") (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_VCTUXS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vctuxs %0,%1,%2" [(set_attr "type" "vecfloat")]) @@ -2134,7 +2134,7 @@ (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v") (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_VCTSXS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] + (set (reg:SI VSCR_REGNO) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))] "TARGET_ALTIVEC" "vctsxs %0,%1,%2" [(set_attr "type" "vecfloat")]) @@ -2274,7 +2274,7 @@ ;; Compare vectors producing a vector result and a predicate, setting CR6 to ;; indicate a combined status (define_insn "*altivec_vcmpequ<VI_char>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(eq:CC (match_operand:VI2 1 "register_operand" "v") (match_operand:VI2 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2286,7 +2286,7 @@ [(set_attr "type" "veccmpfx")]) (define_insn "*altivec_vcmpgts<VI_char>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gt:CC (match_operand:VI2 1 "register_operand" "v") (match_operand:VI2 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2298,7 +2298,7 @@ [(set_attr "type" "veccmpfx")]) (define_insn "*altivec_vcmpgtu<VI_char>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gtu:CC (match_operand:VI2 1 "register_operand" "v") (match_operand:VI2 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2310,7 +2310,7 @@ [(set_attr "type" "veccmpfx")]) (define_insn "*altivec_vcmpeqfp_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(eq:CC (match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2322,7 +2322,7 @@ [(set_attr "type" "veccmp")]) (define_insn "*altivec_vcmpgtfp_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gt:CC (match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2334,7 +2334,7 @@ [(set_attr "type" "veccmp")]) (define_insn "*altivec_vcmpgefp_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(ge:CC (match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v"))] UNSPEC_PREDICATE)) @@ -2346,7 +2346,7 @@ [(set_attr "type" "veccmp")]) (define_insn "altivec_vcmpbfp_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(match_operand:V4SF 1 "register_operand" "v") (match_operand:V4SF 2 "register_operand" "v")] UNSPEC_VCMPBFP)) @@ -2359,7 +2359,7 @@ [(set_attr "type" "veccmp")]) (define_insn "altivec_mtvscr" - [(set (reg:SI 110) + [(set (reg:SI VSCR_REGNO) (unspec_volatile:SI [(match_operand:V4SI 0 "register_operand" "v")] UNSPECV_MTVSCR))] "TARGET_ALTIVEC" @@ -2368,7 +2368,7 @@ (define_insn "altivec_mfvscr" [(set (match_operand:V8HI 0 "register_operand" "=v") - (unspec_volatile:V8HI [(reg:SI 110)] UNSPECV_MFVSCR))] + (unspec_volatile:V8HI [(reg:SI VSCR_REGNO)] UNSPECV_MFVSCR))] "TARGET_ALTIVEC" "mfvscr %0" [(set_attr "type" "vecsimple")]) @@ -2757,7 +2757,8 @@ (unspec:VI [(match_dup 2) (match_operand:VI 1 "register_operand" "v")] UNSPEC_VSUBS)) - (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]) + (set (reg:SI VSCR_REGNO) + (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]) (set (match_operand:VI 0 "register_operand" "=v") (smax:VI (match_dup 1) (match_dup 3)))] "TARGET_ALTIVEC" @@ -3634,7 +3635,7 @@ (match_operand:V1TI 2 "register_operand" "") (match_operand:QI 3 "const_0_to_1_operand" "")] UNSPEC_BCD_ADD_SUB)) - (clobber (reg:CCFP 74))] + (clobber (reg:CCFP CR6_REGNO))] "TARGET_P8_VECTOR" "bcd<bcd_add_sub>. %0,%1,%2,%3" [(set_attr "length" "4") @@ -3646,7 +3647,7 @@ ;; probably should be one that can go in the VMX (Altivec) registers, so we ;; can't use DDmode or DFmode. (define_insn "*bcd<bcd_add_sub>_test" - [(set (reg:CCFP 74) + [(set (reg:CCFP CR6_REGNO) (compare:CCFP (unspec:V2DF [(match_operand:V1TI 1 "register_operand" "v") (match_operand:V1TI 2 "register_operand" "v") @@ -3665,7 +3666,7 @@ (match_operand:V1TI 2 "register_operand" "v") (match_operand:QI 3 "const_0_to_1_operand" "i")] UNSPEC_BCD_ADD_SUB)) - (set (reg:CCFP 74) + (set (reg:CCFP CR6_REGNO) (compare:CCFP (unspec:V2DF [(match_dup 1) (match_dup 2) @@ -3699,7 +3700,7 @@ [(set_attr "type" "integer")]) (define_expand "bcd<bcd_add_sub>_<code>" - [(parallel [(set (reg:CCFP 74) + [(parallel [(set (reg:CCFP CR6_REGNO) (compare:CCFP (unspec:V2DF [(match_operand:V1TI 1 "register_operand" "") (match_operand:V1TI 2 "register_operand" "") @@ -3708,7 +3709,7 @@ (match_dup 4))) (clobber (match_scratch:V1TI 5 ""))]) (set (match_operand:SI 0 "register_operand" "") - (BCD_TEST:SI (reg:CCFP 74) + (BCD_TEST:SI (reg:CCFP CR6_REGNO) (const_int 0)))] "TARGET_P8_VECTOR" { @@ -3727,8 +3728,8 @@ (match_operand:V1TI 2 "register_operand" "") (match_operand:QI 3 "const_0_to_1_operand" "")] UNSPEC_BCD_ADD_SUB)) - (clobber (reg:CCFP 74))]) - (parallel [(set (reg:CCFP 74) + (clobber (reg:CCFP CR6_REGNO))]) + (parallel [(set (reg:CCFP CR6_REGNO) (compare:CCFP (unspec:V2DF [(match_dup 1) (match_dup 2) @@ -3742,7 +3743,7 @@ (match_dup 2) (match_dup 3)] UNSPEC_BCD_ADD_SUB)) - (set (reg:CCFP 74) + (set (reg:CCFP CR6_REGNO) (compare:CCFP (unspec:V2DF [(match_dup 1) (match_dup 2) diff --git a/gcc/config/rs6000/darwin.md b/gcc/config/rs6000/darwin.md index 57ce30e0cd1..5870e0a762f 100644 --- a/gcc/config/rs6000/darwin.md +++ b/gcc/config/rs6000/darwin.md @@ -238,7 +238,7 @@ You should have received a copy of the GNU General Public License "") (define_expand "load_macho_picbase" - [(set (reg:SI 65) + [(set (reg:SI LR_REGNO) (unspec [(match_operand 0 "" "")] UNSPEC_LD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" @@ -252,7 +252,7 @@ You should have received a copy of the GNU General Public License }) (define_insn "load_macho_picbase_si" - [(set (reg:SI 65) + [(set (reg:SI LR_REGNO) (unspec:SI [(match_operand:SI 0 "immediate_operand" "s") (pc)] UNSPEC_LD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" @@ -268,7 +268,7 @@ You should have received a copy of the GNU General Public License (set_attr "length" "4")]) (define_insn "load_macho_picbase_di" - [(set (reg:DI 65) + [(set (reg:DI LR_REGNO) (unspec:DI [(match_operand:DI 0 "immediate_operand" "s") (pc)] UNSPEC_LD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT" @@ -325,7 +325,7 @@ You should have received a copy of the GNU General Public License [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l,c,*l")) (match_operand 1 "" "g,g,g,g")) (use (match_operand:SI 2 "immediate_operand" "O,O,n,n")) - (clobber (reg:SI 65))] + (clobber (reg:SI LR_REGNO))] "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT" { return "b%T0l"; @@ -337,7 +337,7 @@ You should have received a copy of the GNU General Public License [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s")) (match_operand 1 "" "g,g")) (use (match_operand:SI 2 "immediate_operand" "O,n")) - (clobber (reg:SI 65))] + (clobber (reg:SI LR_REGNO))] "(DEFAULT_ABI == ABI_DARWIN) && (INTVAL (operands[2]) & CALL_LONG) == 0" { @@ -355,7 +355,7 @@ You should have received a copy of the GNU General Public License (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l,c,*l")) (match_operand 2 "" "g,g,g,g"))) (use (match_operand:SI 3 "immediate_operand" "O,O,n,n")) - (clobber (reg:SI 65))] + (clobber (reg:SI LR_REGNO))] "DEFAULT_ABI == ABI_DARWIN" { return "b%T1l"; @@ -368,7 +368,7 @@ You should have received a copy of the GNU General Public License (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s")) (match_operand 2 "" "g,g"))) (use (match_operand:SI 3 "immediate_operand" "O,n")) - (clobber (reg:SI 65))] + (clobber (reg:SI LR_REGNO))] "(DEFAULT_ABI == ABI_DARWIN) && (INTVAL (operands[3]) & CALL_LONG) == 0" { @@ -382,7 +382,7 @@ You should have received a copy of the GNU General Public License (set_attr "length" "4,8")]) (define_expand "reload_macho_picbase" - [(set (reg:SI 65) + [(set (reg:SI LR_REGNO) (unspec [(match_operand 0 "" "")] UNSPEC_RELD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" @@ -396,7 +396,7 @@ You should have received a copy of the GNU General Public License }) (define_insn "reload_macho_picbase_si" - [(set (reg:SI 65) + [(set (reg:SI LR_REGNO) (unspec:SI [(match_operand:SI 0 "immediate_operand" "s") (pc)] UNSPEC_RELD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic" @@ -419,7 +419,7 @@ You should have received a copy of the GNU General Public License (set_attr "length" "4")]) (define_insn "reload_macho_picbase_di" - [(set (reg:DI 65) + [(set (reg:DI LR_REGNO) (unspec:DI [(match_operand:DI 0 "immediate_operand" "s") (pc)] UNSPEC_RELD_MPIC))] "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT" diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 2f15a053075..ed24d96006f 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -8409,7 +8409,7 @@ rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, pointer, so it works with both GPRs and VSX registers. */ /* Make sure both operands are registers. */ else if (GET_CODE (x) == PLUS - && (mode != TImode || !TARGET_QUAD_MEMORY)) + && (mode != TImode || !TARGET_VSX_TIMODE)) return gen_rtx_PLUS (Pmode, force_reg (Pmode, XEXP (x, 0)), force_reg (Pmode, XEXP (x, 1))); @@ -9418,12 +9418,16 @@ rs6000_legitimate_address_p (machine_mode mode, rtx x, bool reg_ok_strict) return 1; } - /* For TImode, if we have load/store quad and TImode in VSX registers, only - allow register indirect addresses. This will allow the values to go in - either GPRs or VSX registers without reloading. The vector types would - tend to go into VSX registers, so we allow REG+REG, while TImode seems + /* For TImode, if we have TImode in VSX registers, only allow register + indirect addresses. This will allow the values to go in either GPRs + or VSX registers without reloading. The vector types would tend to + go into VSX registers, so we allow REG+REG, while TImode seems somewhat split, in that some uses are GPR based, and some VSX based. */ - if (mode == TImode && TARGET_QUAD_MEMORY && TARGET_VSX_TIMODE) + /* FIXME: We could loosen this by changing the following to + if (mode == TImode && TARGET_QUAD_MEMORY && TARGET_VSX_TIMODE) + but currently we cannot allow REG+REG addressing for TImode. See + PR72827 for complete details on how this ends up hoodwinking DSE. */ + if (mode == TImode && TARGET_VSX_TIMODE) return 0; /* If not REG_OK_STRICT (before reload) let pass any stack offset. */ if (! reg_ok_strict @@ -39097,10 +39101,15 @@ rtx_is_swappable_p (rtx op, unsigned int *special) handling. */ if (GET_CODE (XEXP (op, 0)) == CONST_INT) return 1; - else if (GET_CODE (XEXP (op, 0)) == REG + else if (REG_P (XEXP (op, 0)) && GET_MODE_INNER (GET_MODE (op)) == GET_MODE (XEXP (op, 0))) /* This catches V2DF and V2DI splat, at a minimum. */ return 1; + else if (GET_CODE (XEXP (op, 0)) == TRUNCATE + && REG_P (XEXP (XEXP (op, 0), 0)) + && GET_MODE_INNER (GET_MODE (op)) == GET_MODE (XEXP (op, 0))) + /* This catches splat of a truncated value. */ + return 1; else if (GET_CODE (XEXP (op, 0)) == VEC_SELECT) /* If the duplicated item is from a select, defer to the select processing to see if we can change the lane for the splat. */ diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index d54eaa1b5a2..446d388469e 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -1958,7 +1958,7 @@ typedef struct rs6000_args #define TRAMPOLINE_SIZE rs6000_trampoline_size () /* Definitions for __builtin_return_address and __builtin_frame_address. - __builtin_return_address (0) should give link register (65), enable + __builtin_return_address (0) should give link register (LR_REGNO), enable this. */ /* This should be uncommented, so that the link register is used, but currently this would result in unmatched insns and spilling fixed diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 560cf1fd740..8d09c8cd2dd 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -4323,13 +4323,15 @@ ;; Split to create division from FRE/FRES/etc. and fixup instead of the normal ;; hardware division. This is only done before register allocation and with ;; -ffast-math. This must appear before the divsf3/divdf3 insns. +;; We used to also check optimize_insn_for_speed_p () but problems with guessed +;; frequencies (pr68212/pr77536) yields that unreliable so it was removed. (define_split [(set (match_operand:RECIPF 0 "gpc_reg_operand" "") (div:RECIPF (match_operand 1 "gpc_reg_operand" "") (match_operand 2 "gpc_reg_operand" "")))] "RS6000_RECIP_AUTO_RE_P (<MODE>mode) - && can_create_pseudo_p () && optimize_insn_for_speed_p () - && flag_finite_math_only && !flag_trapping_math && flag_reciprocal_math" + && can_create_pseudo_p () && flag_finite_math_only + && !flag_trapping_math && flag_reciprocal_math" [(const_int 0)] { rs6000_emit_swdiv (operands[0], operands[1], operands[2], true); @@ -12455,7 +12457,7 @@ (define_insn "*save_gpregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) (set (match_operand:P 2 "memory_operand" "=m") @@ -12467,7 +12469,7 @@ (define_insn "*save_gpregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 12)) (set (match_operand:P 2 "memory_operand" "=m") @@ -12479,7 +12481,7 @@ (define_insn "*save_gpregs_<mode>_r1" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 1)) (set (match_operand:P 2 "memory_operand" "=m") @@ -12491,7 +12493,7 @@ (define_insn "*save_fpregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) (set (match_operand:DF 2 "memory_operand" "=m") @@ -12503,7 +12505,7 @@ (define_insn "*save_fpregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 12)) (set (match_operand:DF 2 "memory_operand" "=m") @@ -12515,7 +12517,7 @@ (define_insn "*save_fpregs_<mode>_r1" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 1)) (set (match_operand:DF 2 "memory_operand" "=m") @@ -12620,141 +12622,139 @@ (define_insn "*restore_gpregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 11)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 11)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "bl %2" + "bl %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*restore_gpregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 12)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 12)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "bl %2" + "bl %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*restore_gpregs_<mode>_r1" [(match_parallel 0 "any_parallel_operand" - [(clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 1)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 1)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "bl %2" + "bl %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_gpregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 11)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 11)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_gpregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 12)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 12)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_gpregs_<mode>_r1" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 1)) - (set (match_operand:P 3 "gpc_reg_operand" "=r") - (match_operand:P 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 1)) + (set (match_operand:P 2 "gpc_reg_operand" "=r") + (match_operand:P 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_fpregs_<mode>_r11" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 11)) - (set (match_operand:DF 3 "gpc_reg_operand" "=d") - (match_operand:DF 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 11)) + (set (match_operand:DF 2 "gpc_reg_operand" "=d") + (match_operand:DF 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_fpregs_<mode>_r12" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 12)) - (set (match_operand:DF 3 "gpc_reg_operand" "=d") - (match_operand:DF 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 12)) + (set (match_operand:DF 2 "gpc_reg_operand" "=d") + (match_operand:DF 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_fpregs_<mode>_r1" [(match_parallel 0 "any_parallel_operand" - [(return) - (clobber (match_operand:P 1 "register_operand" "=l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) - (use (reg:P 1)) - (set (match_operand:DF 3 "gpc_reg_operand" "=d") - (match_operand:DF 4 "memory_operand" "m"))])] + [(return) + (clobber (reg:P LR_REGNO)) + (use (match_operand:P 1 "symbol_ref_operand" "s")) + (use (reg:P 1)) + (set (match_operand:DF 2 "gpc_reg_operand" "=d") + (match_operand:DF 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_fpregs_aix_<mode>_r11" [(match_parallel 0 "any_parallel_operand" [(return) - (use (match_operand:P 1 "register_operand" "l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) + (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) - (set (match_operand:DF 3 "gpc_reg_operand" "=d") - (match_operand:DF 4 "memory_operand" "m"))])] + (set (match_operand:DF 2 "gpc_reg_operand" "=d") + (match_operand:DF 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) (define_insn "*return_and_restore_fpregs_aix_<mode>_r1" [(match_parallel 0 "any_parallel_operand" [(return) - (use (match_operand:P 1 "register_operand" "l")) - (use (match_operand:P 2 "symbol_ref_operand" "s")) + (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 1)) - (set (match_operand:DF 3 "gpc_reg_operand" "=d") - (match_operand:DF 4 "memory_operand" "m"))])] + (set (match_operand:DF 2 "gpc_reg_operand" "=d") + (match_operand:DF 3 "memory_operand" "m"))])] "" - "b %2" + "b %1" [(set_attr "type" "branch") (set_attr "length" "4")]) diff --git a/gcc/config/rs6000/spe.md b/gcc/config/rs6000/spe.md index 87fb787a1c1..4b2220d38bb 100644 --- a/gcc/config/rs6000/spe.md +++ b/gcc/config/rs6000/spe.md @@ -3464,7 +3464,7 @@ ;; Out-of-line prologues and epilogues. (define_insn "*save_gpregs_spe" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) (set (match_operand:V2SI 2 "memory_operand" "=m") @@ -3476,7 +3476,7 @@ (define_insn "*restore_gpregs_spe" [(match_parallel 0 "any_parallel_operand" - [(clobber (reg:P 65)) + [(clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) (set (match_operand:V2SI 2 "gpc_reg_operand" "=r") @@ -3489,7 +3489,7 @@ (define_insn "*return_and_restore_gpregs_spe" [(match_parallel 0 "any_parallel_operand" [(return) - (clobber (reg:P 65)) + (clobber (reg:P LR_REGNO)) (use (match_operand:P 1 "symbol_ref_operand" "s")) (use (reg:P 11)) (set (match_operand:V2SI 2 "gpc_reg_operand" "=r") diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md index fbfa9bf12e4..d42de0f9d3c 100644 --- a/gcc/config/rs6000/vector.md +++ b/gcc/config/rs6000/vector.md @@ -670,7 +670,7 @@ ;; setting CR6 to indicate a combined status (define_expand "vector_eq_<mode>_p" [(parallel - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(eq:CC (match_operand:VEC_A 1 "vlogical_operand" "") (match_operand:VEC_A 2 "vlogical_operand" ""))] UNSPEC_PREDICATE)) @@ -682,7 +682,7 @@ (define_expand "vector_gt_<mode>_p" [(parallel - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gt:CC (match_operand:VEC_A 1 "vlogical_operand" "") (match_operand:VEC_A 2 "vlogical_operand" ""))] UNSPEC_PREDICATE)) @@ -694,7 +694,7 @@ (define_expand "vector_ge_<mode>_p" [(parallel - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(ge:CC (match_operand:VEC_F 1 "vfloat_operand" "") (match_operand:VEC_F 2 "vfloat_operand" ""))] UNSPEC_PREDICATE)) @@ -706,7 +706,7 @@ (define_expand "vector_gtu_<mode>_p" [(parallel - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gtu:CC (match_operand:VEC_I 1 "vint_operand" "") (match_operand:VEC_I 2 "vint_operand" ""))] UNSPEC_PREDICATE)) @@ -720,14 +720,14 @@ (define_expand "cr6_test_for_zero" [(set (match_operand:SI 0 "register_operand" "=r") - (eq:SI (reg:CC 74) + (eq:SI (reg:CC CR6_REGNO) (const_int 0)))] "TARGET_ALTIVEC || TARGET_VSX" "") (define_expand "cr6_test_for_zero_reverse" [(set (match_operand:SI 0 "register_operand" "=r") - (eq:SI (reg:CC 74) + (eq:SI (reg:CC CR6_REGNO) (const_int 0))) (set (match_dup 0) (xor:SI (match_dup 0) @@ -737,14 +737,14 @@ (define_expand "cr6_test_for_lt" [(set (match_operand:SI 0 "register_operand" "=r") - (lt:SI (reg:CC 74) + (lt:SI (reg:CC CR6_REGNO) (const_int 0)))] "TARGET_ALTIVEC || TARGET_VSX" "") (define_expand "cr6_test_for_lt_reverse" [(set (match_operand:SI 0 "register_operand" "=r") - (lt:SI (reg:CC 74) + (lt:SI (reg:CC CR6_REGNO) (const_int 0))) (set (match_dup 0) (xor:SI (match_dup 0) diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 60917c541c7..359e424d6b4 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -1499,7 +1499,7 @@ ;; Compare vectors producing a vector result and a predicate, setting CR6 to ;; indicate a combined status (define_insn "*vsx_eq_<mode>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(eq:CC (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,?<VSa>") (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,?<VSa>"))] @@ -1512,7 +1512,7 @@ [(set_attr "type" "<VStype_simple>")]) (define_insn "*vsx_gt_<mode>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(gt:CC (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,?<VSa>") (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,?<VSa>"))] @@ -1525,7 +1525,7 @@ [(set_attr "type" "<VStype_simple>")]) (define_insn "*vsx_ge_<mode>_p" - [(set (reg:CC 74) + [(set (reg:CC CR6_REGNO) (unspec:CC [(ge:CC (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,?<VSa>") (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,?<VSa>"))] diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index fecbb886d0f..f611dabd6ad 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -35,59 +35,6 @@ enum sh_function_kind { SFUNC_STATIC }; -/* Atomic model. */ -struct sh_atomic_model -{ - enum enum_type - { - none = 0, - soft_gusa, - hard_llcs, - soft_tcb, - soft_imask, - - num_models - }; - - /* If strict is set, disallow mixing of different models, as it would - happen on SH4A. */ - bool strict; - enum_type type; - - /* Name string as it was specified on the command line. */ - const char* name; - - /* Name string as it is used in C/C++ defines. */ - const char* cdef_name; - - /* GBR offset variable for TCB model. */ - int tcb_gbr_offset; -}; - -extern const sh_atomic_model& selected_atomic_model (void); - -/* Shortcuts to check the currently selected atomic model. */ -#define TARGET_ATOMIC_ANY \ - (selected_atomic_model ().type != sh_atomic_model::none) - -#define TARGET_ATOMIC_STRICT \ - (selected_atomic_model ().strict) - -#define TARGET_ATOMIC_SOFT_GUSA \ - (selected_atomic_model ().type == sh_atomic_model::soft_gusa) - -#define TARGET_ATOMIC_HARD_LLCS \ - (selected_atomic_model ().type == sh_atomic_model::hard_llcs) - -#define TARGET_ATOMIC_SOFT_TCB \ - (selected_atomic_model ().type == sh_atomic_model::soft_tcb) - -#define TARGET_ATOMIC_SOFT_TCB_GBR_OFFSET_RTX \ - GEN_INT (selected_atomic_model ().tcb_gbr_offset) - -#define TARGET_ATOMIC_SOFT_IMASK \ - (selected_atomic_model ().type == sh_atomic_model::soft_imask) - #ifdef RTX_CODE extern rtx sh_fsca_sf2int (void); extern rtx sh_fsca_int2sf (void); diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 0403616785a..25b6cee5852 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -333,6 +333,63 @@ extern enum sh_divide_strategy_e sh_div_strategy; #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL_DIV1 #endif +#ifdef __cplusplus + +/* Atomic model. */ +struct sh_atomic_model +{ + enum enum_type + { + none = 0, + soft_gusa, + hard_llcs, + soft_tcb, + soft_imask, + + num_models + }; + + /* If strict is set, disallow mixing of different models, as it would + happen on SH4A. */ + bool strict; + enum_type type; + + /* Name string as it was specified on the command line. */ + const char* name; + + /* Name string as it is used in C/C++ defines. */ + const char* cdef_name; + + /* GBR offset variable for TCB model. */ + int tcb_gbr_offset; +}; + +extern const sh_atomic_model& selected_atomic_model (void); + +/* Shortcuts to check the currently selected atomic model. */ +#define TARGET_ATOMIC_ANY \ + (selected_atomic_model ().type != sh_atomic_model::none) + +#define TARGET_ATOMIC_STRICT \ + (selected_atomic_model ().strict) + +#define TARGET_ATOMIC_SOFT_GUSA \ + (selected_atomic_model ().type == sh_atomic_model::soft_gusa) + +#define TARGET_ATOMIC_HARD_LLCS \ + (selected_atomic_model ().type == sh_atomic_model::hard_llcs) + +#define TARGET_ATOMIC_SOFT_TCB \ + (selected_atomic_model ().type == sh_atomic_model::soft_tcb) + +#define TARGET_ATOMIC_SOFT_TCB_GBR_OFFSET_RTX \ + GEN_INT (selected_atomic_model ().tcb_gbr_offset) + +#define TARGET_ATOMIC_SOFT_IMASK \ + (selected_atomic_model ().type == sh_atomic_model::soft_imask) + +#endif // __cplusplus + #define SUBTARGET_OVERRIDE_OPTIONS (void) 0 diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 254b72298a3..1932b1bad78 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -827,6 +827,9 @@ char sparc_hard_reg_printed[8]; #define TARGET_MANGLE_TYPE sparc_mangle_type #endif +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P sparc_legitimate_address_p diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index fc791f5515b..28173e5123c 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -7153,6 +7153,9 @@ static const struct attribute_spec spu_attribute_table[] = /* TARGET overrides. */ +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ADDR_SPACE_POINTER_MODE #define TARGET_ADDR_SPACE_POINTER_MODE spu_addr_space_pointer_mode diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 50af15bd7cc..1eb95f57f9f 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -2677,6 +2677,9 @@ xstormy16_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) #undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS #define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS xstormy16_preferred_reload_class +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P xstormy16_legitimate_address_p #undef TARGET_MODE_DEPENDENT_ADDRESS_P diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 5508ed8a724..d743c63bd59 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -5625,6 +5625,9 @@ tilegx_file_end (void) #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P tilegx_legitimate_constant_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P tilegx_legitimate_address_p diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index 7237a600333..33e49936536 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -5017,6 +5017,9 @@ tilepro_file_end (void) #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P tilepro_legitimate_constant_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P tilepro_legitimate_address_p diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index e0e4215e05f..f1716d1a9cd 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -3340,6 +3340,9 @@ v850_gen_movdi (rtx * operands) #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P v850_legitimate_constant_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P #define TARGET_ADDR_SPACE_LEGITIMATE_ADDRESS_P v850_legitimate_address_p diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index c326df92e69..ae5e9ce96e9 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -505,10 +505,8 @@ enum reg_class { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }} \ -/* This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ +/* This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ { \ diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 804f0c7a2e1..06ab5715ec3 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -96,6 +96,9 @@ static bool vax_mode_dependent_address_p (const_rtx, addr_space_t); #undef TARGET_BUILTIN_SETJMP_FRAME_VALUE #define TARGET_BUILTIN_SETJMP_FRAME_VALUE vax_builtin_setjmp_frame_value +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P vax_legitimate_address_p #undef TARGET_MODE_DEPENDENT_ADDRESS_P diff --git a/gcc/config/vax/vax.h b/gcc/config/vax/vax.h index a381039d008..77d9e7f0729 100644 --- a/gcc/config/vax/vax.h +++ b/gcc/config/vax/vax.h @@ -340,16 +340,6 @@ enum reg_class { NO_REGS, ALL_REGS, LIM_REG_CLASSES }; #define EXIT_IGNORE_STACK 1 -/* Store in the variable DEPTH the initial difference between the - frame pointer reg contents and the stack pointer reg contents, - as of the start of the function body. This depends on the layout - of the fixed parts of the stack frame and on how registers are saved. - - On the VAX, FRAME_POINTER_REQUIRED is always 1, so the definition of this - macro doesn't matter. But it must be defined. */ - -#define INITIAL_FRAME_POINTER_OFFSET(DEPTH) (DEPTH) = 0; - /* Length in units of the trampoline for entering a nested function. */ #define TRAMPOLINE_SIZE 15 diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 360a6740c78..af58f99aef1 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -264,6 +264,9 @@ static unsigned int visium_reorg (void); #undef TARGET_LEGITIMATE_CONSTANT_P #define TARGET_LEGITIMATE_CONSTANT_P visium_legitimate_constant_p +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P visium_legitimate_address_p diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h index 0f195c07c66..f7e3da4c069 100644 --- a/gcc/config/visium/visium.h +++ b/gcc/config/visium/visium.h @@ -963,10 +963,8 @@ enum reg_class /* `INITIAL_ELIMINATION_OFFSET (FROM-REG, TO-REG, OFFSET-VAR)' - This macro is similar to `INITIAL_FRAME_POINTER_OFFSET'. It - specifies the initial difference between the specified pair of - registers. This macro must be defined if `ELIMINABLE_REGS' is - defined. */ + This macro returns the initial difference between the specified pair + of registers. */ #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ (OFFSET = visium_initial_elimination_offset (FROM, TO)) diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 917ea94840f..07c9e8f1fb2 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -264,6 +264,9 @@ static void xtensa_conditional_register_usage (void); #undef TARGET_CANNOT_FORCE_CONST_MEM #define TARGET_CANNOT_FORCE_CONST_MEM xtensa_cannot_force_const_mem +#undef TARGET_LRA_P +#define TARGET_LRA_P hook_bool_void_false + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_P xtensa_legitimate_address_p diff --git a/gcc/configure b/gcc/configure index 871ed0c3d15..0eeee94307e 100755 --- a/gcc/configure +++ b/gcc/configure @@ -29609,6 +29609,30 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_bndplt_support" >&5 $as_echo "$ld_bndplt_support" >&6; } +# Check linker supports '--push-state'/'--pop-state' +ld_pushpopstate_support=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --push-state/--pop-state options" >&5 +$as_echo_n "checking linker --push-state/--pop-state options... " >&6; } +if test x"$ld_is_gold" = xno; then + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then + ld_pushpopstate_support=yes + fi + elif test x$gcc_cv_ld != x; then + # Check if linker supports --push-state/--pop-state options + if $gcc_cv_ld --help 2>/dev/null | grep -- '--push-state' > /dev/null; then + ld_pushpopstate_support=yes + fi + fi +fi +if test x"$ld_pushpopstate_support" = xyes; then + +$as_echo "#define HAVE_LD_PUSHPOPSTATE_SUPPORT 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_pushpopstate_support" >&5 +$as_echo "$ld_pushpopstate_support" >&6; } + # Configure the subdirectories # AC_CONFIG_SUBDIRS($subdirs) diff --git a/gcc/configure.ac b/gcc/configure.ac index 241e82dfc72..93af766a57c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -6237,6 +6237,27 @@ if test x"$ld_bndplt_support" = xyes; then fi AC_MSG_RESULT($ld_bndplt_support) +# Check linker supports '--push-state'/'--pop-state' +ld_pushpopstate_support=no +AC_MSG_CHECKING(linker --push-state/--pop-state options) +if test x"$ld_is_gold" = xno; then + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then + ld_pushpopstate_support=yes + fi + elif test x$gcc_cv_ld != x; then + # Check if linker supports --push-state/--pop-state options + if $gcc_cv_ld --help 2>/dev/null | grep -- '--push-state' > /dev/null; then + ld_pushpopstate_support=yes + fi + fi +fi +if test x"$ld_pushpopstate_support" = xyes; then + AC_DEFINE(HAVE_LD_PUSHPOPSTATE_SUPPORT, 1, + [Define if your linker supports --push-state/--pop-state]) +fi +AC_MSG_RESULT($ld_pushpopstate_support) + # Configure the subdirectories # AC_CONFIG_SUBDIRS($subdirs) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c553796d7bf..9d74bdbb8ba 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,115 @@ +2016-09-16 Jakub Jelinek <jakub@redhat.com> + + PR c++/77482 + * error.c (dump_simple_decl): Only check DECL_DECLARED_CONCEPT_P + if DECL_LANG_SPECIFIC is non-NULL. Fix up formatting. + + PR c++/77338 + * constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only + call is_really_empty_class on complete types. + + PR c++/77375 + * class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any + TYPE_HAS_MUTABLE_P for any bases. + +2016-09-16 Jason Merrill <jason@redhat.com> + + * class.c (check_bases, set_one_vmethod_tm_attributes): Use + least_bit_hwi. + * decl.c (cxx_init_decl_processing): Use pow2p_hwi. + * parser.c (cp_parser_cilk_simd_vectorlength): Use pow2p_hwi. + +2016-09-14 Jakub Jelinek <jakub@redhat.com> + + PR c++/77549 + * name-lookup.c (consider_binding_level): Look through TREE_LIST + and OVERLOAD. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * typeck.c (cp_build_unary_op): Diagnose incrementing boolean + expressions. Tweak an error message. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to + bool. + * decl2.c (one_static_initialization_or_destruction): Use true instead + of 1. + * init.c (build_vec_init): Use false instead of 0. + * pt.c (tsubst_copy_and_build): Likewise. + * semantics.c (simplify_loop_decl_cond): Likewise. + * typeck.c (rationalize_conditional_expr): Likewise. + (cp_build_binary_op): Use true instead of 1. + (cp_build_unary_op): Change nonconvert parameter type to bool. Use true + instead of 1. + (build_unary_op): Change nonconvert parameter type to bool. + (unary_complex_lvalue): Use false instead of 0. + +2016-09-13 Jakub Jelinek <jakub@redhat.com> + + Implement P0028R4, C++17 using attribute namespaces without repetition + * parser.c (cp_parser_std_attribute): Add ATTR_NS argument. Diagnose + non-NULL ATTR_NS with scoped attribute token. Handle non-NULL + ATTR_NS with non-scoped attribute tokens. Allow named ops in + identifier after ::. + (cp_parser_std_attribute_list): Add ATTR_NS argument, pass it down + to cp_parser_std_attribute calls. + (cp_parser_std_attribute_spec): Parse optional C++17 + attribute-using-prefix, adjust grammar in function comment. + + PR c++/77553 + * constexpr.c (cxx_fold_pointer_plus_expression): New function. + (cxx_eval_binary_expression): Use it for POINTER_PLUS_EXPR. + (cxx_eval_pointer_plus_expression): Remove. + (cxx_eval_constant_expression) <case POINTER_PLUS_EXPR>: Don't + call cxx_eval_pointer_plus_expression. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * parser.c (cp_parser_class_specifier_1): Update for renaming of + add_fixit_insert to add_fixit_insert_before. + (cp_parser_class_head): Likewise. + +2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR c++/77496 + * call.c (build_conditional_expr_1): Call warn_for_omitted_condop. + * class.c (instantiate_type): Look through the SAVE_EXPR. + +2016-09-09 Jason Merrill <jason@redhat.com> + + Implement P0035R4, C++17 new of over-aligned types. + * cp-tree.h (enum cp_tree_index): Add CPTI_ALIGN_TYPE. + (align_type_node): New macro. + * call.c (build_operator_new_call): Handle C++17 aligned new. + (second_parm_is_size_t, build_op_delete_call): Likewise. + (non_placement_deallocation_fn_p): Likewise. Rename to + usual_deallocation_fn_p. + (aligned_allocation_fn_p, aligned_deallocation_fn_p): New. + * decl.c (cxx_init_decl_processing): Add aligned new support. + * init.c (type_has_new_extended_alignment): New. + (build_new_1): Handle aligned new. + * tree.c (vec_copy_and_insert): New. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/77396 + * decl2.c (do_static_initialization_or_destruction): Only + call asan_dynamic_init_call if INITP is true. + +2016-09-01 Martin Sebor <msebor@redhat.com> + + * mangle.c: Increase buffer size to guarantee it fits the output + of the formatted function regardless of its arguments. + +2016-09-01 Marek Polacek <polacek@redhat.com> + + PR c/7652 + * error.c (dump_type): Fix falls through comment. + (dump_decl): Likewise. + (dump_expr): Likewise. + 2016-08-30 David Malcolm <dmalcolm@redhat.com> * parser.c (cp_parser_enclosed_template_argument_list): Add fix-it @@ -78,7 +190,7 @@ * semantics.c (finish_omp_clauses): Add FALLTHRU. * tree.c (lvalue_kind): Likewise. -2016-08-12 Alexandre Oliva <aoliva@redhat.com> +2016-08-12 Alexandre Oliva <aoliva@redhat.com> PR debug/63240 * cp-objcp-common.c (cp_function_decl_defaulted): New. @@ -287,7 +399,7 @@ * cp-gimplify.c (cp_fully_fold): Only maybe_constant_value in C++11 and up. -2016-07-30 Martin Sebor <msebor@redhat.com> +2016-07-30 Martin Sebor <msebor@redhat.com> PR c++/60760 PR c++/71091 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 024519d3601..393aab91bee 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4211,13 +4211,14 @@ build_new_function_call (tree fn, vec<tree, va_gc> **args, bool koenig_p, tree build_operator_new_call (tree fnname, vec<tree, va_gc> **args, - tree *size, tree *cookie_size, tree size_check, + tree *size, tree *cookie_size, + tree align_arg, tree size_check, tree *fn, tsubst_flags_t complain) { tree original_size = *size; tree fns; struct z_candidate *candidates; - struct z_candidate *cand; + struct z_candidate *cand = NULL; bool any_viable_p; if (fn) @@ -4247,9 +4248,20 @@ build_operator_new_call (tree fnname, vec<tree, va_gc> **args, we disregard block-scope declarations of "operator new". */ fns = lookup_function_nonclass (fnname, *args, /*block_p=*/false); + if (align_arg) + { + vec<tree, va_gc>* align_args + = vec_copy_and_insert (*args, align_arg, 1); + cand = perform_overload_resolution (fns, align_args, &candidates, + &any_viable_p, tf_none); + /* If no aligned allocation function matches, try again without the + alignment. */ + } + /* Figure out what function is being called. */ - cand = perform_overload_resolution (fns, *args, &candidates, &any_viable_p, - complain); + if (!cand) + cand = perform_overload_resolution (fns, *args, &candidates, &any_viable_p, + complain); /* If no suitable function could be found, issue an error message and give up. */ @@ -4653,9 +4665,12 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, if (!arg2) { if (complain & tf_error) - pedwarn (loc, OPT_Wpedantic, + pedwarn (loc, OPT_Wpedantic, "ISO C++ forbids omitting the middle term of a ?: expression"); + if ((complain & tf_warning) && !truth_value_p (TREE_CODE (arg1))) + warn_for_omitted_condop (loc, arg1); + /* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */ if (lvalue_p (arg1)) arg2 = arg1 = cp_stabilize_reference (arg1); @@ -5945,16 +5960,65 @@ static bool second_parm_is_size_t (tree fn) { tree t = FUNCTION_ARG_CHAIN (fn); - return (t - && same_type_p (TREE_VALUE (t), size_type_node) - && TREE_CHAIN (t) == void_list_node); + if (!t || !same_type_p (TREE_VALUE (t), size_type_node)) + return false; + t = TREE_CHAIN (t); + if (t == void_list_node) + return true; + if (aligned_new_threshhold && t + && same_type_p (TREE_VALUE (t), align_type_node) + && TREE_CHAIN (t) == void_list_node) + return true; + return false; +} + +/* True if T, an allocation function, has std::align_val_t as its second + argument. */ + +bool +aligned_allocation_fn_p (tree t) +{ + if (!aligned_new_threshhold) + return false; + + tree a = FUNCTION_ARG_CHAIN (t); + return (a && same_type_p (TREE_VALUE (a), align_type_node)); +} + +/* Returns true iff T, an element of an OVERLOAD chain, is a usual deallocation + function (3.7.4.2 [basic.stc.dynamic.deallocation]) with a parameter of + std::align_val_t. */ + +static bool +aligned_deallocation_fn_p (tree t) +{ + if (!aligned_new_threshhold) + return false; + + /* A template instance is never a usual deallocation function, + regardless of its signature. */ + if (TREE_CODE (t) == TEMPLATE_DECL + || primary_template_instantiation_p (t)) + return false; + + tree a = FUNCTION_ARG_CHAIN (t); + if (same_type_p (TREE_VALUE (a), align_type_node) + && TREE_CHAIN (a) == void_list_node) + return true; + if (!same_type_p (TREE_VALUE (a), size_type_node)) + return false; + a = TREE_CHAIN (a); + if (a && same_type_p (TREE_VALUE (a), align_type_node) + && TREE_CHAIN (a) == void_list_node) + return true; + return false; } /* Returns true iff T, an element of an OVERLOAD chain, is a usual deallocation function (3.7.4.2 [basic.stc.dynamic.deallocation]). */ bool -non_placement_deallocation_fn_p (tree t) +usual_deallocation_fn_p (tree t) { /* A template instance is never a usual deallocation function, regardless of its signature. */ @@ -5970,10 +6034,15 @@ non_placement_deallocation_fn_p (tree t) of which has type std::size_t (18.2), then this function is a usual deallocation function. */ bool global = DECL_NAMESPACE_SCOPE_P (t); - if (FUNCTION_ARG_CHAIN (t) == void_list_node + tree chain = FUNCTION_ARG_CHAIN (t); + if (!chain) + return false; + if (chain == void_list_node || ((!global || flag_sized_deallocation) && second_parm_is_size_t (t))) return true; + if (aligned_deallocation_fn_p (t)) + return true; return false; } @@ -6076,7 +6145,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, t; t = OVL_NEXT (t)) { tree elt = OVL_CURRENT (t); - if (non_placement_deallocation_fn_p (elt) + if (usual_deallocation_fn_p (elt) && FUNCTION_ARG_CHAIN (elt) == void_list_node) goto ok; } @@ -6118,51 +6187,62 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, t; t = OVL_NEXT (t)) { tree elt = OVL_CURRENT (t); - if (non_placement_deallocation_fn_p (elt)) + if (usual_deallocation_fn_p (elt)) { - fn = elt; - /* "If a class T has a member deallocation function named - operator delete with exactly one parameter, then that - function is a usual (non-placement) deallocation - function. If class T does not declare such an operator - delete but does declare a member deallocation function named - operator delete with exactly two parameters, the second of - which has type std::size_t (18.2), then this function is a - usual deallocation function." - - So in a class (void*) beats (void*, size_t). */ - if (DECL_CLASS_SCOPE_P (fn)) + if (!fn) { - if (FUNCTION_ARG_CHAIN (fn) == void_list_node) - break; + fn = elt; + continue; } - /* At global scope (in C++14 and above) the rules are different: - - If deallocation function lookup finds both a usual - deallocation function with only a pointer parameter and a - usual deallocation function with both a pointer parameter - and a size parameter, the function to be called is selected - as follows: - - * If the type is complete and if, for the second alternative - (delete array) only, the operand is a pointer to a class - type with a non-trivial destructor or a (possibly - multi-dimensional) array thereof, the function with two - parameters is selected. - - * Otherwise, it is unspecified which of the two deallocation - functions is selected. */ + + /* -- If the type has new-extended alignment, a function with a + parameter of type std::align_val_t is preferred; otherwise a + function without such a parameter is preferred. If exactly one + preferred function is found, that function is selected and the + selection process terminates. If more than one preferred + function is found, all non-preferred functions are eliminated + from further consideration. */ + if (aligned_new_threshhold) + { + bool want_align = type_has_new_extended_alignment (type); + bool fn_align = aligned_deallocation_fn_p (fn); + bool elt_align = aligned_deallocation_fn_p (elt); + + if (elt_align != fn_align) + { + if (want_align == elt_align) + fn = elt; + continue; + } + } + + /* -- If the deallocation functions have class scope, the one + without a parameter of type std::size_t is selected. */ + bool want_size; + if (DECL_CLASS_SCOPE_P (fn)) + want_size = false; + + /* -- If the type is complete and if, for the second alternative + (delete array) only, the operand is a pointer to a class type + with a non-trivial destructor or a (possibly multi-dimensional) + array thereof, the function with a parameter of type std::size_t + is selected. + + -- Otherwise, it is unspecified whether a deallocation function + with a parameter of type std::size_t is selected. */ else { - bool want_size = COMPLETE_TYPE_P (type); + want_size = COMPLETE_TYPE_P (type); if (code == VEC_DELETE_EXPR && !TYPE_VEC_NEW_USES_COOKIE (type)) /* We need a cookie to determine the array size. */ want_size = false; - bool have_size = (FUNCTION_ARG_CHAIN (fn) != void_list_node); - if (want_size == have_size) - break; } + bool fn_size = second_parm_is_size_t (fn); + bool elt_size = second_parm_is_size_t (elt); + gcc_assert (fn_size != elt_size); + if (want_size == elt_size) + fn = elt; } } @@ -6200,8 +6280,13 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, tree ret; vec<tree, va_gc> *args = make_tree_vector (); args->quick_push (addr); - if (FUNCTION_ARG_CHAIN (fn) != void_list_node) + if (second_parm_is_size_t (fn)) args->quick_push (size); + if (aligned_deallocation_fn_p (fn)) + { + tree al = build_int_cst (align_type_node, TYPE_ALIGN_UNIT (type)); + args->quick_push (al); + } ret = cp_build_function_call_vec (fn, &args, complain); release_tree_vector (args); return ret; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a4f3c6b6aba..7362c732646 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1796,6 +1796,8 @@ check_bases (tree t, SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, CLASSTYPE_REF_FIELDS_NEED_INIT (t) | CLASSTYPE_REF_FIELDS_NEED_INIT (basetype)); + if (TYPE_HAS_MUTABLE_P (basetype)) + CLASSTYPE_HAS_MUTABLE (t) = 1; /* A standard-layout class is a class that: ... @@ -1843,7 +1845,7 @@ check_bases (tree t, doesn't define its own, then the current class inherits one. */ if (seen_tm_mask && !find_tm_attribute (TYPE_ATTRIBUTES (t))) { - tree tm_attr = tm_mask_to_attr (seen_tm_mask & -seen_tm_mask); + tree tm_attr = tm_mask_to_attr (least_bit_hwi (seen_tm_mask)); TYPE_ATTRIBUTES (t) = tree_cons (tm_attr, NULL, TYPE_ATTRIBUTES (t)); } } @@ -5074,7 +5076,7 @@ set_one_vmethod_tm_attributes (tree type, tree fndecl) restrictive one. */ else if (tm_attr == NULL) { - apply_tm_attr (fndecl, tm_mask_to_attr (found & -found)); + apply_tm_attr (fndecl, tm_mask_to_attr (least_bit_hwi (found))); } /* Otherwise validate that we're not weaker than a function that is being overridden. */ @@ -8262,7 +8264,12 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t complain) return error_mark_node; } - /* There only a few kinds of expressions that may have a type + /* If we instantiate a template, and it is a A ?: C expression + with omitted B, look through the SAVE_EXPR. */ + if (TREE_CODE (rhs) == SAVE_EXPR) + rhs = TREE_OPERAND (rhs, 0); + + /* There are only a few kinds of expressions that may have a type dependent on overload resolution. */ gcc_assert (TREE_CODE (rhs) == ADDR_EXPR || TREE_CODE (rhs) == COMPONENT_REF diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 5d97a4be4f1..9308c548621 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1813,6 +1813,63 @@ cxx_eval_unary_expression (const constexpr_ctx *ctx, tree t, return r; } +/* Helper function for cxx_eval_binary_expression. Try to optimize + original POINTER_PLUS_EXPR T, LHS p+ RHS, return NULL_TREE if the + generic folding should be used. */ + +static tree +cxx_fold_pointer_plus_expression (const constexpr_ctx *ctx, tree t, + tree lhs, tree rhs, bool *non_constant_p, + bool *overflow_p) +{ + STRIP_NOPS (lhs); + if (TREE_CODE (lhs) != ADDR_EXPR) + return NULL_TREE; + + lhs = TREE_OPERAND (lhs, 0); + + /* &A[i] p+ j => &A[i + j] */ + if (TREE_CODE (lhs) == ARRAY_REF + && TREE_CODE (TREE_OPERAND (lhs, 1)) == INTEGER_CST + && TREE_CODE (rhs) == INTEGER_CST + && TYPE_SIZE_UNIT (TREE_TYPE (lhs)) + && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (lhs))) == INTEGER_CST) + { + tree orig_type = TREE_TYPE (t); + location_t loc = EXPR_LOCATION (t); + tree type = TREE_TYPE (lhs); + + t = fold_convert_loc (loc, ssizetype, TREE_OPERAND (lhs, 1)); + tree nelts = array_type_nelts_top (TREE_TYPE (TREE_OPERAND (lhs, 0))); + nelts = cxx_eval_constant_expression (ctx, nelts, false, non_constant_p, + overflow_p); + if (*non_constant_p) + return NULL_TREE; + /* Don't fold an out-of-bound access. */ + if (!tree_int_cst_le (t, nelts)) + return NULL_TREE; + rhs = cp_fold_convert (ssizetype, rhs); + /* Don't fold if rhs can't be divided exactly by TYPE_SIZE_UNIT. + constexpr int A[1]; ... (char *)&A[0] + 1 */ + if (!integer_zerop (fold_build2_loc (loc, TRUNC_MOD_EXPR, sizetype, + rhs, TYPE_SIZE_UNIT (type)))) + return NULL_TREE; + /* Make sure to treat the second operand of POINTER_PLUS_EXPR + as signed. */ + rhs = fold_build2_loc (loc, EXACT_DIV_EXPR, ssizetype, rhs, + TYPE_SIZE_UNIT (type)); + t = size_binop_loc (loc, PLUS_EXPR, rhs, t); + t = build4_loc (loc, ARRAY_REF, type, TREE_OPERAND (lhs, 0), + t, NULL_TREE, NULL_TREE); + t = cp_build_addr_expr (t, tf_warning_or_error); + t = cp_fold_convert (orig_type, t); + return cxx_eval_constant_expression (ctx, t, /*lval*/false, + non_constant_p, overflow_p); + } + + return NULL_TREE; +} + /* Subroutine of cxx_eval_constant_expression. Like cxx_eval_unary_expression, except for binary expressions. */ @@ -1865,6 +1922,9 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t, error ("arithmetic involving a null pointer in %qE", lhs); return t; } + else if (code == POINTER_PLUS_EXPR) + r = cxx_fold_pointer_plus_expression (ctx, t, lhs, rhs, non_constant_p, + overflow_p); if (r == NULL_TREE) r = fold_binary_loc (loc, code, type, lhs, rhs); @@ -3579,69 +3639,6 @@ cxx_eval_switch_expr (const constexpr_ctx *ctx, tree t, return NULL_TREE; } -/* Subroutine of cxx_eval_constant_expression. - Attempt to reduce a POINTER_PLUS_EXPR expression T. */ - -static tree -cxx_eval_pointer_plus_expression (const constexpr_ctx *ctx, tree t, - bool lval, bool *non_constant_p, - bool *overflow_p) -{ - tree orig_type = TREE_TYPE (t); - tree op00 = TREE_OPERAND (t, 0); - tree op01 = TREE_OPERAND (t, 1); - location_t loc = EXPR_LOCATION (t); - - op00 = cxx_eval_constant_expression (ctx, op00, lval, - non_constant_p, overflow_p); - - STRIP_NOPS (op00); - if (TREE_CODE (op00) != ADDR_EXPR) - return NULL_TREE; - - op01 = cxx_eval_constant_expression (ctx, op01, lval, - non_constant_p, overflow_p); - op00 = TREE_OPERAND (op00, 0); - - /* &A[i] p+ j => &A[i + j] */ - if (TREE_CODE (op00) == ARRAY_REF - && TREE_CODE (TREE_OPERAND (op00, 1)) == INTEGER_CST - && TREE_CODE (op01) == INTEGER_CST - && TYPE_SIZE_UNIT (TREE_TYPE (op00)) - && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (op00))) == INTEGER_CST) - { - tree type = TREE_TYPE (op00); - t = fold_convert_loc (loc, ssizetype, TREE_OPERAND (op00, 1)); - tree nelts = array_type_nelts_top (TREE_TYPE (TREE_OPERAND (op00, 0))); - nelts = cxx_eval_constant_expression (ctx, nelts, false, non_constant_p, - overflow_p); - if (*non_constant_p) - return NULL_TREE; - /* Don't fold an out-of-bound access. */ - if (!tree_int_cst_le (t, nelts)) - return NULL_TREE; - op01 = cp_fold_convert (ssizetype, op01); - /* Don't fold if op01 can't be divided exactly by TYPE_SIZE_UNIT. - constexpr int A[1]; ... (char *)&A[0] + 1 */ - if (!integer_zerop (fold_build2_loc (loc, TRUNC_MOD_EXPR, sizetype, - op01, TYPE_SIZE_UNIT (type)))) - return NULL_TREE; - /* Make sure to treat the second operand of POINTER_PLUS_EXPR - as signed. */ - op01 = fold_build2_loc (loc, EXACT_DIV_EXPR, ssizetype, op01, - TYPE_SIZE_UNIT (type)); - t = size_binop_loc (loc, PLUS_EXPR, op01, t); - t = build4_loc (loc, ARRAY_REF, type, TREE_OPERAND (op00, 0), - t, NULL_TREE, NULL_TREE); - t = cp_build_addr_expr (t, tf_warning_or_error); - t = cp_fold_convert (orig_type, t); - return cxx_eval_constant_expression (ctx, t, lval, non_constant_p, - overflow_p); - } - - return NULL_TREE; -} - /* Attempt to reduce the expression T to a constant value. On failure, issue diagnostic and return error_mark_node. */ /* FIXME unify with c_fully_fold */ @@ -3747,7 +3744,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, /* Defer in case this is only used for its type. */; else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) /* Defer, there's no lvalue->rvalue conversion. */; - else if (is_really_empty_class (TREE_TYPE (t))) + else if (COMPLETE_TYPE_P (TREE_TYPE (t)) + && is_really_empty_class (TREE_TYPE (t))) { /* If the class is empty, we aren't actually loading anything. */ r = build_constructor (TREE_TYPE (t), NULL); @@ -3984,12 +3982,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, break; case POINTER_PLUS_EXPR: - r = cxx_eval_pointer_plus_expression (ctx, t, lval, non_constant_p, - overflow_p); - if (r) - break; - /* fall through */ - case PLUS_EXPR: case MINUS_EXPR: case MULT_EXPR: diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5bcb98b9756..f40334092a0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1147,6 +1147,8 @@ enum cp_tree_index CPTI_NULLPTR, CPTI_NULLPTR_TYPE, + CPTI_ALIGN_TYPE, + CPTI_MAX }; @@ -1182,6 +1184,8 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; #define current_aggr cp_global_trees[CPTI_AGGR_TAG] #define nullptr_node cp_global_trees[CPTI_NULLPTR] #define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE] +/* std::align_val_t */ +#define align_type_node cp_global_trees[CPTI_ALIGN_TYPE] /* We cache these tree nodes so as to call get_identifier less frequently. */ @@ -5561,7 +5565,7 @@ extern tree build_user_type_conversion (tree, tree, int, extern tree build_new_function_call (tree, vec<tree, va_gc> **, bool, tsubst_flags_t); extern tree build_operator_new_call (tree, vec<tree, va_gc> **, tree *, - tree *, tree, tree *, + tree *, tree, tree, tree *, tsubst_flags_t); extern tree build_new_method_call (tree, tree, vec<tree, va_gc> **, tree, int, tree *, @@ -5573,7 +5577,8 @@ extern tree build_new_op (location_t, enum tree_code, tsubst_flags_t); extern tree build_op_call (tree, vec<tree, va_gc> **, tsubst_flags_t); -extern bool non_placement_deallocation_fn_p (tree); +extern bool aligned_allocation_fn_p (tree); +extern bool usual_deallocation_fn_p (tree); extern tree build_op_delete_call (enum tree_code, tree, tree, bool, tree, tree, tsubst_flags_t); @@ -5966,6 +5971,7 @@ extern tree get_nsdmi (tree, bool); extern tree build_offset_ref (tree, tree, bool, tsubst_flags_t); extern tree throw_bad_array_new_length (void); +extern bool type_has_new_extended_alignment (tree); extern tree build_new (vec<tree, va_gc> **, tree, tree, vec<tree, va_gc> **, int, tsubst_flags_t); @@ -6528,6 +6534,7 @@ extern tree build_min_nt_loc (location_t, enum tree_code, extern tree build_min_non_dep (enum tree_code, tree, ...); extern tree build_min_non_dep_op_overload (enum tree_code, tree, tree, ...); extern tree build_min_non_dep_call_vec (tree, tree, vec<tree, va_gc> *); +extern vec<tree, va_gc>* vec_copy_and_insert (vec<tree, va_gc>*, tree, unsigned); extern tree build_cplus_new (tree, tree, tsubst_flags_t); extern tree build_aggr_init_expr (tree, tree); extern tree get_target_expr (tree); @@ -6666,7 +6673,7 @@ extern tree build_x_unary_op (location_t, enum tree_code, cp_expr, tsubst_flags_t); extern tree cp_build_addr_expr (tree, tsubst_flags_t); -extern tree cp_build_unary_op (enum tree_code, tree, int, +extern tree cp_build_unary_op (enum tree_code, tree, bool, tsubst_flags_t); extern tree unary_complex_lvalue (enum tree_code, tree); extern tree build_x_conditional_expr (location_t, tree, tree, tree, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 43cf3df36ba..2f444656842 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4132,6 +4132,17 @@ cxx_init_decl_processing (void) /* Now, C++. */ current_lang_name = lang_name_cplusplus; + if (aligned_new_threshhold > 1 + && !pow2p_hwi (aligned_new_threshhold)) + { + error ("-faligned-new=%d is not a power of two", aligned_new_threshhold); + aligned_new_threshhold = 1; + } + if (aligned_new_threshhold == -1) + aligned_new_threshhold = (cxx_dialect >= cxx1z) ? 1 : 0; + if (aligned_new_threshhold == 1) + aligned_new_threshhold = max_align_t_align () / BITS_PER_UNIT; + { tree newattrs, extvisattr; tree newtype, deltype; @@ -4199,6 +4210,47 @@ cxx_init_decl_processing (void) push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW); } + if (aligned_new_threshhold) + { + push_namespace (std_identifier); + tree align_id = get_identifier ("align_val_t"); + align_type_node = start_enum (align_id, NULL_TREE, size_type_node, + NULL_TREE, /*scoped*/true, NULL); + pop_namespace (); + + /* operator new (size_t, align_val_t); */ + newtype = build_function_type_list (ptr_type_node, size_type_node, + align_type_node, NULL_TREE); + newtype = cp_build_type_attribute_variant (newtype, newattrs); + newtype = build_exception_variant (newtype, new_eh_spec); + opnew = push_cp_library_fn (NEW_EXPR, newtype, 0); + DECL_IS_MALLOC (opnew) = 1; + DECL_IS_OPERATOR_NEW (opnew) = 1; + opnew = push_cp_library_fn (VEC_NEW_EXPR, newtype, 0); + DECL_IS_MALLOC (opnew) = 1; + DECL_IS_OPERATOR_NEW (opnew) = 1; + + /* operator delete (void *, align_val_t); */ + deltype = build_function_type_list (void_type_node, ptr_type_node, + align_type_node, NULL_TREE); + deltype = cp_build_type_attribute_variant (deltype, extvisattr); + deltype = build_exception_variant (deltype, empty_except_spec); + push_cp_library_fn (DELETE_EXPR, deltype, ECF_NOTHROW); + push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW); + + if (flag_sized_deallocation) + { + /* operator delete (void *, size_t, align_val_t); */ + deltype = build_function_type_list (void_type_node, ptr_type_node, + size_type_node, align_type_node, + NULL_TREE); + deltype = cp_build_type_attribute_variant (deltype, extvisattr); + deltype = build_exception_variant (deltype, empty_except_spec); + push_cp_library_fn (DELETE_EXPR, deltype, ECF_NOTHROW); + push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW); + } + } + nullptr_type_node = make_node (NULLPTR_TYPE); TYPE_SIZE (nullptr_type_node) = bitsize_int (GET_MODE_BITSIZE (ptr_mode)); TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode)); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 55bb987ebbe..4bdac94a8e0 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3775,7 +3775,7 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp) EQ_EXPR, cp_build_unary_op (PREINCREMENT_EXPR, guard, - /*noconvert=*/1, + /*noconvert=*/true, tf_warning_or_error), integer_one_node, tf_warning_or_error); @@ -3785,7 +3785,7 @@ one_static_initialization_or_destruction (tree decl, tree init, bool initp) EQ_EXPR, cp_build_unary_op (PREDECREMENT_EXPR, guard, - /*noconvert=*/1, + /*noconvert=*/true, tf_warning_or_error), integer_zero_node, tf_warning_or_error); @@ -3861,7 +3861,7 @@ do_static_initialization_or_destruction (tree vars, bool initp) in other compilation units, or at least those that haven't been initialized yet. Variables that need dynamic construction in the current compilation unit are kept accessible. */ - if (flag_sanitize & SANITIZE_ADDRESS) + if (initp && (flag_sanitize & SANITIZE_ADDRESS)) finish_expr_stmt (asan_dynamic_init_call (/*after_p=*/false)); node = vars; @@ -3914,7 +3914,7 @@ do_static_initialization_or_destruction (tree vars, bool initp) /* Revert what __asan_before_dynamic_init did by calling __asan_after_dynamic_init. */ - if (flag_sanitize & SANITIZE_ADDRESS) + if (initp && (flag_sanitize & SANITIZE_ADDRESS)) finish_expr_stmt (asan_dynamic_init_call (/*after_p=*/true)); /* Finish up the init/destruct if-stmt body. */ @@ -4488,7 +4488,7 @@ maybe_warn_sized_delete (enum tree_code code) { tree fn = OVL_CURRENT (ovl); /* We're only interested in usual deallocation functions. */ - if (!non_placement_deallocation_fn_p (fn)) + if (!usual_deallocation_fn_p (fn)) continue; if (FUNCTION_ARG_CHAIN (fn) == void_list_node) unsized = fn; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 58cd48c0a14..ca7360fa602 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -575,7 +575,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); - /* Fall through to error. */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("<type error>")); @@ -959,14 +959,13 @@ dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags) { if (flags & TFF_DECL_SPECIFIERS) { - if (VAR_P (t) - && DECL_DECLARED_CONSTEXPR_P (t)) - { - if (DECL_DECLARED_CONCEPT_P (t)) - pp_cxx_ws_string (pp, "concept"); - else - pp_cxx_ws_string (pp, "constexpr"); - } + if (VAR_P (t) && DECL_DECLARED_CONSTEXPR_P (t)) + { + if (DECL_LANG_SPECIFIC (t) && DECL_DECLARED_CONCEPT_P (t)) + pp_cxx_ws_string (pp, "concept"); + else + pp_cxx_ws_string (pp, "constexpr"); + } dump_type_prefix (pp, type, flags & ~TFF_UNQUALIFIED_NAME); pp_maybe_space (pp); } @@ -1276,7 +1275,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); - /* Fall through to error. */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("<declaration error>")); @@ -2777,7 +2776,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) `report_error_function'. That could cause an infinite loop. */ default: pp_unsupported_tree (pp, t); - /* fall through to ERROR_MARK... */ + /* Fall through. */ case ERROR_MARK: pp_string (pp, M_("<expression error>")); break; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1a5766a42b7..e869542e757 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2569,6 +2569,15 @@ warn_placement_new_too_small (tree type, tree nelts, tree size, tree oper) } } +/* True if alignof(T) > __STDCPP_DEFAULT_NEW_ALIGNMENT__. */ + +bool +type_has_new_extended_alignment (tree t) +{ + return (aligned_new_threshhold + && TYPE_ALIGN_UNIT (t) > (unsigned)aligned_new_threshhold); +} + /* Generate code for a new-expression, including calling the "operator new" function, initializing the object, and, if an exception occurs during construction, cleaning up. The arguments are as for @@ -2840,6 +2849,10 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, } } + tree align_arg = NULL_TREE; + if (type_has_new_extended_alignment (elt_type)) + align_arg = build_int_cst (align_type_node, TYPE_ALIGN_UNIT (elt_type)); + alloc_fn = NULL_TREE; /* If PLACEMENT is a single simple pointer type not passed by @@ -2954,12 +2967,28 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, } return error_mark_node; } - alloc_call = build_new_method_call (build_dummy_object (elt_type), - fns, placement, - /*conversion_path=*/NULL_TREE, - LOOKUP_NORMAL, - &alloc_fn, - complain); + tree dummy = build_dummy_object (elt_type); + alloc_call = NULL_TREE; + if (align_arg) + { + vec<tree, va_gc> *align_args + = vec_copy_and_insert (*placement, align_arg, 1); + alloc_call + = build_new_method_call (dummy, fns, &align_args, + /*conversion_path=*/NULL_TREE, + LOOKUP_NORMAL, &alloc_fn, tf_none); + /* If no matching function is found and the allocated object type + has new-extended alignment, the alignment argument is removed + from the argument list, and overload resolution is performed + again. */ + if (alloc_call == error_mark_node) + alloc_call = NULL_TREE; + } + if (!alloc_call) + alloc_call = build_new_method_call (dummy, fns, placement, + /*conversion_path=*/NULL_TREE, + LOOKUP_NORMAL, + &alloc_fn, complain); } else { @@ -2976,6 +3005,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, alloc_call = build_operator_new_call (fnname, placement, &size, &cookie_size, + align_arg, outer_nelts_check, &alloc_fn, complain); } @@ -2986,6 +3016,20 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, gcc_assert (alloc_fn != NULL_TREE); + if (warn_aligned_new + && TYPE_ALIGN (elt_type) > max_align_t_align () + && (warn_aligned_new > 1 + || CP_DECL_CONTEXT (alloc_fn) == global_namespace) + && !aligned_allocation_fn_p (alloc_fn)) + { + warning (OPT_Waligned_new_, "%<new%> of type %qT with extended " + "alignment %d", elt_type, TYPE_ALIGN_UNIT (elt_type)); + inform (input_location, "uses %qD, which does not have an alignment " + "parameter", alloc_fn); + inform (input_location, "use %<-faligned-new%> to enable C++17 " + "over-aligned new support"); + } + /* If we found a simple case of PLACEMENT_EXPR above, then copy it into a temporary variable. */ if (!processing_template_decl @@ -4052,13 +4096,14 @@ build_vec_init (tree base, tree maxindex, tree init, finish_expr_stmt (one_init); current_stmt_tree ()->stmts_are_full_exprs_p = 0; - one_init = cp_build_unary_op (PREINCREMENT_EXPR, base, 0, complain); + one_init = cp_build_unary_op (PREINCREMENT_EXPR, base, false, + complain); if (one_init == error_mark_node) errors = true; else finish_expr_stmt (one_init); - one_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, 0, + one_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, false, complain); if (one_init == error_mark_node) errors = true; @@ -4111,7 +4156,7 @@ build_vec_init (tree base, tree maxindex, tree init, finish_for_cond (build2 (GT_EXPR, boolean_type_node, iterator, build_int_cst (TREE_TYPE (iterator), -1)), for_stmt, false); - elt_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, 0, + elt_init = cp_build_unary_op (PREDECREMENT_EXPR, iterator, false, complain); if (elt_init == error_mark_node) errors = true; @@ -4228,10 +4273,10 @@ build_vec_init (tree base, tree maxindex, tree init, finish_expr_stmt (elt_init); current_stmt_tree ()->stmts_are_full_exprs_p = 0; - finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base, 0, + finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base, false, complain)); if (base2) - finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base2, 0, + finish_expr_stmt (cp_build_unary_op (PREINCREMENT_EXPR, base2, false, complain)); finish_for_stmt (for_stmt); diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index d34743c9c68..bd23260c088 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1740,7 +1740,9 @@ static void write_real_cst (const tree value) { long target_real[4]; /* largest supported float */ - char buffer[9]; /* eight hex digits in a 32-bit number */ + /* Buffer for eight hex digits in a 32-bit number but big enough + even for 64-bit long to avoid warnings. */ + char buffer[17]; int i, limit, dir; tree type = TREE_TYPE (value); diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 022ab6a2c09..952d8b799ab 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4707,19 +4707,29 @@ consider_binding_level (tree name, best_match <tree, tree> &bm, for (tree t = lvl->names; t; t = TREE_CHAIN (t)) { + tree d = t; + + /* OVERLOADs or decls from using declaration are wrapped into + TREE_LIST. */ + if (TREE_CODE (d) == TREE_LIST) + { + d = TREE_VALUE (d); + d = OVL_CURRENT (d); + } + /* Don't use bindings from implicitly declared functions, as they were likely misspellings themselves. */ - if (TREE_TYPE (t) == error_mark_node) + if (TREE_TYPE (d) == error_mark_node) continue; /* Skip anticipated decls of builtin functions. */ - if (TREE_CODE (t) == FUNCTION_DECL - && DECL_BUILT_IN (t) - && DECL_ANTICIPATED (t)) + if (TREE_CODE (d) == FUNCTION_DECL + && DECL_BUILT_IN (d) + && DECL_ANTICIPATED (d)) continue; - if (DECL_NAME (t)) - bm.consider (DECL_NAME (t)); + if (DECL_NAME (d)) + bm.consider (DECL_NAME (d)); } } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index ca9f8b9761a..fb88021e237 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2392,7 +2392,7 @@ static tree cp_parser_gnu_attributes_opt static tree cp_parser_gnu_attribute_list (cp_parser *); static tree cp_parser_std_attribute - (cp_parser *); + (cp_parser *, tree); static tree cp_parser_std_attribute_spec (cp_parser *); static tree cp_parser_std_attribute_spec_seq @@ -21594,7 +21594,7 @@ cp_parser_class_specifier_1 (cp_parser* parser) next_loc = linemap_position_for_loc_and_offset (line_table, loc, 1); rich_location richloc (line_table, next_loc); - richloc.add_fixit_insert (next_loc, ";"); + richloc.add_fixit_insert_before (next_loc, ";"); if (CLASSTYPE_DECLARED_CLASS (type)) error_at_rich_loc (&richloc, @@ -22037,7 +22037,8 @@ cp_parser_class_head (cp_parser* parser, class_head_start_location, get_finish (type_start_token->location)); rich_location richloc (line_table, reported_loc); - richloc.add_fixit_insert (class_head_start_location, "template <> "); + richloc.add_fixit_insert_before (class_head_start_location, + "template <> "); error_at_rich_loc (&richloc, "an explicit specialization must be preceded by %<template <>%>"); @@ -24055,9 +24056,9 @@ cp_parser_gnu_attribute_list (cp_parser* parser) { balanced-token-seq }. */ static tree -cp_parser_std_attribute (cp_parser *parser) +cp_parser_std_attribute (cp_parser *parser, tree attr_ns) { - tree attribute, attr_ns = NULL_TREE, attr_id = NULL_TREE, arguments; + tree attribute, attr_id = NULL_TREE, arguments; cp_token *token; /* First, parse name of the attribute, a.k.a attribute-token. */ @@ -24081,6 +24082,9 @@ cp_parser_std_attribute (cp_parser *parser) /* We are seeing a scoped attribute token. */ cp_lexer_consume_token (parser->lexer); + if (attr_ns) + error_at (token->location, "attribute using prefix used together " + "with scoped attribute token"); attr_ns = attr_id; token = cp_lexer_consume_token (parser->lexer); @@ -24088,6 +24092,8 @@ cp_parser_std_attribute (cp_parser *parser) attr_id = token->u.value; else if (token->type == CPP_KEYWORD) attr_id = ridpointers[(int) token->keyword]; + else if (token->flags & NAMED_OP) + attr_id = get_identifier (cpp_type2name (token->type, token->flags)); else { error_at (token->location, @@ -24098,6 +24104,9 @@ cp_parser_std_attribute (cp_parser *parser) NULL_TREE); token = cp_lexer_peek_token (parser->lexer); } + else if (attr_ns) + attribute = build_tree_list (build_tree_list (attr_ns, attr_id), + NULL_TREE); else { attribute = build_tree_list (build_tree_list (NULL_TREE, attr_id), @@ -24191,14 +24200,14 @@ cp_parser_check_std_attribute (tree attributes, tree attribute) */ static tree -cp_parser_std_attribute_list (cp_parser *parser) +cp_parser_std_attribute_list (cp_parser *parser, tree attr_ns) { tree attributes = NULL_TREE, attribute = NULL_TREE; cp_token *token = NULL; while (true) { - attribute = cp_parser_std_attribute (parser); + attribute = cp_parser_std_attribute (parser, attr_ns); if (attribute == error_mark_node) break; if (attribute != NULL_TREE) @@ -24226,9 +24235,12 @@ cp_parser_std_attribute_list (cp_parser *parser) /* Parse a standard C++-11 attribute specifier. attribute-specifier: - [ [ attribute-list ] ] + [ [ attribute-using-prefix [opt] attribute-list ] ] alignment-specifier + attribute-using-prefix: + using attribute-namespace : + alignment-specifier: alignas ( type-id ... [opt] ) alignas ( alignment-expression ... [opt] ). */ @@ -24242,10 +24254,39 @@ cp_parser_std_attribute_spec (cp_parser *parser) if (token->type == CPP_OPEN_SQUARE && cp_lexer_peek_nth_token (parser->lexer, 2)->type == CPP_OPEN_SQUARE) { + tree attr_ns = NULL_TREE; + cp_lexer_consume_token (parser->lexer); cp_lexer_consume_token (parser->lexer); - attributes = cp_parser_std_attribute_list (parser); + if (cp_lexer_next_token_is_keyword (parser->lexer, RID_USING)) + { + token = cp_lexer_peek_nth_token (parser->lexer, 2); + if (token->type == CPP_NAME) + attr_ns = token->u.value; + else if (token->type == CPP_KEYWORD) + attr_ns = ridpointers[(int) token->keyword]; + else if (token->flags & NAMED_OP) + attr_ns = get_identifier (cpp_type2name (token->type, + token->flags)); + if (attr_ns + && cp_lexer_nth_token_is (parser->lexer, 3, CPP_COLON)) + { + if (cxx_dialect < cxx1z + && !in_system_header_at (input_location)) + pedwarn (input_location, 0, + "attribute using prefix only available " + "with -std=c++1z or -std=gnu++1z"); + + cp_lexer_consume_token (parser->lexer); + cp_lexer_consume_token (parser->lexer); + cp_lexer_consume_token (parser->lexer); + } + else + attr_ns = NULL_TREE; + } + + attributes = cp_parser_std_attribute_list (parser, attr_ns); if (!cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE) || !cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE)) @@ -37712,7 +37753,7 @@ cp_parser_cilk_simd_vectorlength (cp_parser *parser, tree clauses, || !INTEGRAL_TYPE_P (TREE_TYPE (expr))) error_at (loc, "vectorlength must be an integer constant"); else if (TREE_CONSTANT (expr) - && exact_log2 (TREE_INT_CST_LOW (expr)) == -1) + && !pow2p_hwi (TREE_INT_CST_LOW (expr))) error_at (loc, "vectorlength must be a power of 2"); else { diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b0f06649c58..29d8beb33dd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16257,7 +16257,7 @@ tsubst_copy_and_build (tree t, case FIX_TRUNC_EXPR: RETURN (cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)), - 0, complain)); + false, complain)); case ADDR_EXPR: op1 = TREE_OPERAND (t, 0); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9ab8439077a..e4157325a36 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -588,7 +588,7 @@ simplify_loop_decl_cond (tree *cond_p, tree body) *cond_p = boolean_true_node; if_stmt = begin_if_stmt (); - cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, 0, tf_warning_or_error); + cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, false, tf_warning_or_error); finish_if_stmt_cond (cond, if_stmt); finish_break_stmt (); finish_then_clause (if_stmt); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6d254ddbf14..bd2e8f66739 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2920,6 +2920,30 @@ build_min_non_dep_op_overload (enum tree_code op, return call; } +/* Return a new tree vec copied from VEC, with ELT inserted at index IDX. */ + +vec<tree, va_gc> * +vec_copy_and_insert (vec<tree, va_gc> *old_vec, tree elt, unsigned idx) +{ + unsigned len = vec_safe_length (old_vec); + gcc_assert (idx <= len); + + vec<tree, va_gc> *new_vec = NULL; + vec_alloc (new_vec, len + 1); + + unsigned i; + for (i = 0; i < len; ++i) + { + if (i == idx) + new_vec->quick_push (elt); + new_vec->quick_push ((*old_vec)[i]); + } + if (i == idx) + new_vec->quick_push (elt); + + return new_vec; +} + tree get_type_decl (tree t) { diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a591d291602..c53a85a16e0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -2208,16 +2208,16 @@ rationalize_conditional_expr (enum tree_code code, tree t, op1, TREE_CODE (op1), /*overload=*/NULL, complain), - cp_build_unary_op (code, op0, 0, complain), - cp_build_unary_op (code, op1, 0, complain), + cp_build_unary_op (code, op0, false, complain), + cp_build_unary_op (code, op1, false, complain), complain); } return build_conditional_expr (loc, TREE_OPERAND (t, 0), - cp_build_unary_op (code, TREE_OPERAND (t, 1), 0, + cp_build_unary_op (code, TREE_OPERAND (t, 1), false, complain), - cp_build_unary_op (code, TREE_OPERAND (t, 2), 0, + cp_build_unary_op (code, TREE_OPERAND (t, 2), false, complain), complain); } @@ -5036,8 +5036,8 @@ cp_build_binary_op (location_t location, if (first_complex) { op0 = save_expr (op0); - real = cp_build_unary_op (REALPART_EXPR, op0, 1, complain); - imag = cp_build_unary_op (IMAGPART_EXPR, op0, 1, complain); + real = cp_build_unary_op (REALPART_EXPR, op0, true, complain); + imag = cp_build_unary_op (IMAGPART_EXPR, op0, true, complain); switch (code) { case MULT_EXPR: @@ -5056,8 +5056,8 @@ cp_build_binary_op (location_t location, else { op1 = save_expr (op1); - real = cp_build_unary_op (REALPART_EXPR, op1, 1, complain); - imag = cp_build_unary_op (IMAGPART_EXPR, op1, 1, complain); + real = cp_build_unary_op (REALPART_EXPR, op1, true, complain); + imag = cp_build_unary_op (IMAGPART_EXPR, op1, true, complain); switch (code) { case MULT_EXPR: @@ -5784,11 +5784,10 @@ cp_build_addr_expr_strict (tree arg, tsubst_flags_t complain) from aggregates to types we don't yet know we want? (Or are those cases typically errors which should be reported?) - NOCONVERT nonzero suppresses the default promotions - (such as from short to int). */ + NOCONVERT suppresses the default promotions (such as from short to int). */ tree -cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, +cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, tsubst_flags_t complain) { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ @@ -5920,9 +5919,9 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, tree real, imag; arg = cp_stabilize_reference (arg); - real = cp_build_unary_op (REALPART_EXPR, arg, 1, complain); - imag = cp_build_unary_op (IMAGPART_EXPR, arg, 1, complain); - real = cp_build_unary_op (code, real, 1, complain); + real = cp_build_unary_op (REALPART_EXPR, arg, true, complain); + imag = cp_build_unary_op (IMAGPART_EXPR, arg, true, complain); + real = cp_build_unary_op (code, real, true, complain); if (real == error_mark_node || imag == error_mark_node) return error_mark_node; return build2 (COMPLEX_EXPR, TREE_TYPE (arg), @@ -6030,16 +6029,32 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, complain)) return error_mark_node; - /* Forbid using -- on `bool'. */ + /* Forbid using -- or ++ in C++17 on `bool'. */ if (TREE_CODE (declared_type) == BOOLEAN_TYPE) { if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR) { if (complain & tf_error) - error ("invalid use of Boolean expression as operand " - "to %<operator--%>"); + error ("use of an operand of type %qT in %<operator--%> " + "is forbidden", boolean_type_node); return error_mark_node; } + else + { + if (cxx_dialect >= cxx1z) + { + if (complain & tf_error) + error ("use of an operand of type %qT in " + "%<operator++%> is forbidden in C++1z", + boolean_type_node); + return error_mark_node; + } + /* Otherwise, [depr.incr.bool] says this is deprecated. */ + else if (!in_system_header_at (input_location)) + warning (OPT_Wdeprecated, "use of an operand of type %qT " + "in %<operator++%> is deprecated", + boolean_type_node); + } val = boolean_increment (code, arg); } else if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) @@ -6076,7 +6091,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, /* Hook for the c-common bits that build a unary op. */ tree build_unary_op (location_t /*location*/, - enum tree_code code, tree xarg, int noconvert) + enum tree_code code, tree xarg, bool noconvert) { return cp_build_unary_op (code, xarg, noconvert, tf_warning_or_error); } @@ -6100,7 +6115,7 @@ unary_complex_lvalue (enum tree_code code, tree arg) /* Handle (a, b) used as an "lvalue". */ if (TREE_CODE (arg) == COMPOUND_EXPR) { - tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 1), 0, + tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 1), false, tf_warning_or_error); return build2 (COMPOUND_EXPR, TREE_TYPE (real_result), TREE_OPERAND (arg, 0), real_result); @@ -6134,7 +6149,7 @@ unary_complex_lvalue (enum tree_code code, tree arg) if (TREE_CODE (arg) == MODIFY_EXPR || TREE_CODE (arg) == INIT_EXPR) { - tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 0), 0, + tree real_result = cp_build_unary_op (code, TREE_OPERAND (arg, 0), false, tf_warning_or_error); arg = build2 (COMPOUND_EXPR, TREE_TYPE (real_result), arg, real_result); diff --git a/gcc/cse.c b/gcc/cse.c index 0bfd7ff1669..99949f0abd5 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -3643,13 +3643,13 @@ fold_rtx (rtx x, rtx_insn *insn) if (code == PLUS && const_arg1 == inner_const && ((HAVE_PRE_INCREMENT - && exact_log2 (INTVAL (const_arg1)) >= 0) + && pow2p_hwi (INTVAL (const_arg1))) || (HAVE_POST_INCREMENT - && exact_log2 (INTVAL (const_arg1)) >= 0) + && pow2p_hwi (INTVAL (const_arg1))) || (HAVE_PRE_DECREMENT - && exact_log2 (- INTVAL (const_arg1)) >= 0) + && pow2p_hwi (- INTVAL (const_arg1))) || (HAVE_POST_DECREMENT - && exact_log2 (- INTVAL (const_arg1)) >= 0))) + && pow2p_hwi (- INTVAL (const_arg1))))) break; /* ??? Vector mode shifts by scalar diff --git a/gcc/df-scan.c b/gcc/df-scan.c index 9cd647a3213..c8dbf8ddb00 100644 --- a/gcc/df-scan.c +++ b/gcc/df-scan.c @@ -3829,10 +3829,9 @@ static bool initialized = false; void df_hard_reg_init (void) { -#ifdef ELIMINABLE_REGS int i; static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS; -#endif + if (initialized) return; @@ -3840,12 +3839,8 @@ df_hard_reg_init (void) mark_used_regs. */ CLEAR_HARD_REG_SET (elim_reg_set); -#ifdef ELIMINABLE_REGS for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++) SET_HARD_REG_BIT (elim_reg_set, eliminables[i].from); -#else - SET_HARD_REG_BIT (elim_reg_set, FRAME_POINTER_REGNUM); -#endif initialized = true; } diff --git a/gcc/diagnostic-color.c b/gcc/diagnostic-color.c index 42aa1b60226..0bd8170253d 100644 --- a/gcc/diagnostic-color.c +++ b/gcc/diagnostic-color.c @@ -170,6 +170,10 @@ static struct color_cap color_dict[] = { "quote", SGR_SEQ (COLOR_BOLD), 5, false }, { "fixit-insert", SGR_SEQ (COLOR_FG_GREEN), 12, false }, { "fixit-delete", SGR_SEQ (COLOR_FG_RED), 12, false }, + { "diff-filename", SGR_SEQ (COLOR_BOLD), 13, false }, + { "diff-hunk", SGR_SEQ (COLOR_FG_CYAN), 9, false }, + { "diff-delete", SGR_SEQ (COLOR_FG_RED), 11, false }, + { "diff-insert", SGR_SEQ (COLOR_FG_GREEN), 11, false }, { NULL, NULL, 0, false } }; @@ -200,7 +204,8 @@ colorize_stop (bool show_color) /* Parse GCC_COLORS. The default would look like: GCC_COLORS='error=01;31:warning=01;35:note=01;36:\ range1=32:range2=34:locus=01:quote=01:\ - fixit-insert=32:fixit-delete=31' + fixit-insert=32:fixit-delete=31'\ + diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32' No character escaping is needed or supported. */ static bool parse_gcc_colors (void) diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c index 00a95a19cc0..f6bfcc9c8f3 100644 --- a/gcc/diagnostic-show-locus.c +++ b/gcc/diagnostic-show-locus.c @@ -1661,12 +1661,12 @@ test_one_liner_multiple_carets_and_ranges () /* Insertion fix-it hint: adding an "&" to the front of "bar.field". */ static void -test_one_liner_fixit_insert () +test_one_liner_fixit_insert_before () { test_diagnostic_context dc; location_t caret = linemap_position_for_column (line_table, 7); rich_location richloc (line_table, caret); - richloc.add_fixit_insert ("&"); + richloc.add_fixit_insert_before ("&"); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("\n" " foo = bar.field;\n" @@ -1675,6 +1675,25 @@ test_one_liner_fixit_insert () pp_formatted_text (dc.printer)); } +/* Insertion fix-it hint: adding a "[0]" after "foo". */ + +static void +test_one_liner_fixit_insert_after () +{ + test_diagnostic_context dc; + location_t start = linemap_position_for_column (line_table, 1); + location_t finish = linemap_position_for_column (line_table, 3); + location_t foo = make_location (start, start, finish); + rich_location richloc (line_table, foo); + richloc.add_fixit_insert_after ("[0]"); + diagnostic_show_locus (&dc, &richloc, DK_ERROR); + ASSERT_STREQ ("\n" + " foo = bar.field;\n" + " ^~~\n" + " [0]\n", + pp_formatted_text (dc.printer)); +} + /* Removal fix-it hint: removal of the ".field". */ static void @@ -1785,7 +1804,7 @@ test_one_liner_fixit_validation_adhoc_locations () /* Insert. */ { rich_location richloc (line_table, loc); - richloc.add_fixit_insert (loc, "test"); + richloc.add_fixit_insert_before (loc, "test"); /* It should not have been discarded by the validator. */ ASSERT_EQ (1, richloc.get_num_fixit_hints ()); @@ -1843,7 +1862,7 @@ test_one_liner_many_fixits () location_t equals = linemap_position_for_column (line_table, 5); rich_location richloc (line_table, equals); for (int i = 0; i < 19; i++) - richloc.add_fixit_insert ("a"); + richloc.add_fixit_insert_before ("a"); ASSERT_EQ (19, richloc.get_num_fixit_hints ()); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("\n" @@ -1898,7 +1917,8 @@ test_diagnostic_show_locus_one_liner (const line_table_case &case_) test_one_liner_simple_caret (); test_one_liner_caret_and_range (); test_one_liner_multiple_carets_and_ranges (); - test_one_liner_fixit_insert (); + test_one_liner_fixit_insert_before (); + test_one_liner_fixit_insert_after (); test_one_liner_fixit_remove (); test_one_liner_fixit_replace (); test_one_liner_fixit_replace_non_equal_range (); @@ -1949,7 +1969,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_) const location_t colon = linemap_position_for_line_and_column (line_table, ord_map, 2, 25); rich_location richloc (line_table, colon); - richloc.add_fixit_insert (x, "."); + richloc.add_fixit_insert_before (x, "."); richloc.add_fixit_replace (colon, "="); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("\n" @@ -1970,7 +1990,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_) const location_t colon = linemap_position_for_line_and_column (line_table, ord_map, 6, 25); rich_location richloc (line_table, colon); - richloc.add_fixit_insert (y, "."); + richloc.add_fixit_insert_before (y, "."); richloc.add_fixit_replace (colon, "="); diagnostic_show_locus (&dc, &richloc, DK_ERROR); ASSERT_STREQ ("\n" @@ -2012,8 +2032,8 @@ test_fixit_consolidation (const line_table_case &case_) /* Insert + insert. */ { rich_location richloc (line_table, caret); - richloc.add_fixit_insert (c10, "foo"); - richloc.add_fixit_insert (c15, "bar"); + richloc.add_fixit_insert_before (c10, "foo"); + richloc.add_fixit_insert_before (c15, "bar"); if (c15 > LINE_MAP_MAX_LOCATION_WITH_COLS) /* Bogus column info for 2nd fixit, so no fixits. */ @@ -2026,7 +2046,7 @@ test_fixit_consolidation (const line_table_case &case_) /* Insert + replace. */ { rich_location richloc (line_table, caret); - richloc.add_fixit_insert (c10, "foo"); + richloc.add_fixit_insert_before (c10, "foo"); richloc.add_fixit_replace (source_range::from_locations (c15, c17), "bar"); @@ -2043,7 +2063,7 @@ test_fixit_consolidation (const line_table_case &case_) rich_location richloc (line_table, caret); richloc.add_fixit_replace (source_range::from_locations (c10, c15), "bar"); - richloc.add_fixit_insert (c17, "foo"); + richloc.add_fixit_insert_before (c17, "foo"); if (c17 > LINE_MAP_MAX_LOCATION_WITH_COLS) /* Bogus column info for 2nd fixit, so no fixits. */ @@ -2140,6 +2160,87 @@ test_fixit_consolidation (const line_table_case &case_) } } +/* Insertion fix-it hint: adding a "break;" on a line by itself. + This will fail, as newlines aren't yet supported. */ + +static void +test_fixit_insert_containing_newline (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = (" case 'a':\n" /* line 1. */ + " x = a;\n" /* line 2. */ + " case 'b':\n" /* line 3. */ + " x = b;\n");/* line 4. */ + + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 3); + + /* Add a "break;" on a line by itself before line 3 i.e. before + column 1 of line 3. */ + location_t case_start = linemap_position_for_column (line_table, 5); + location_t case_finish = linemap_position_for_column (line_table, 13); + location_t case_loc = make_location (case_start, case_start, case_finish); + rich_location richloc (line_table, case_loc); + location_t line_start = linemap_position_for_column (line_table, 1); + richloc.add_fixit_insert_before (line_start, " break;\n"); + + /* Newlines are not yet supported within fix-it hints, so + the fix-it should not be displayed. */ + ASSERT_TRUE (richloc.seen_impossible_fixit_p ()); + + if (case_finish > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + test_diagnostic_context dc; + diagnostic_show_locus (&dc, &richloc, DK_ERROR); + ASSERT_STREQ ("\n" + " case 'b':\n" + " ^~~~~~~~~\n", + pp_formatted_text (dc.printer)); +} + +/* Replacement fix-it hint containing a newline. + This will fail, as newlines aren't yet supported. */ + +static void +test_fixit_replace_containing_newline (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111. + .........................1234567890123. */ + const char *old_content = "foo = bar ();\n"; + + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 1); + + /* Replace the " = " with "\n = ", as if we were reformatting an + overly long line. */ + location_t start = linemap_position_for_column (line_table, 4); + location_t finish = linemap_position_for_column (line_table, 6); + location_t loc = linemap_position_for_column (line_table, 13); + rich_location richloc (line_table, loc); + source_range range = source_range::from_locations (start, finish); + richloc.add_fixit_replace (range, "\n ="); + + /* Newlines are not yet supported within fix-it hints, so + the fix-it should not be displayed. */ + ASSERT_TRUE (richloc.seen_impossible_fixit_p ()); + + if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + test_diagnostic_context dc; + diagnostic_show_locus (&dc, &richloc, DK_ERROR); + ASSERT_STREQ ("\n" + " foo = bar ();\n" + " ^\n", + pp_formatted_text (dc.printer)); +} + /* Run all of the selftests within this file. */ void @@ -2156,6 +2257,8 @@ diagnostic_show_locus_c_tests () for_each_line_table_case (test_diagnostic_show_locus_one_liner); for_each_line_table_case (test_diagnostic_show_locus_fixit_lines); for_each_line_table_case (test_fixit_consolidation); + for_each_line_table_case (test_fixit_insert_containing_newline); + for_each_line_table_case (test_fixit_replace_containing_newline); } } // namespace selftest diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 47b4c79ebcc..585028ec211 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -31,6 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "backtrace.h" #include "diagnostic.h" #include "diagnostic-color.h" +#include "edit-context.h" #include "selftest.h" #ifdef HAVE_TERMIOS_H @@ -174,6 +175,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts) context->colorize_source_p = false; context->show_ruler_p = false; context->parseable_fixits_p = false; + context->edit_context_ptr = NULL; } /* Maybe initialize the color support. We require clients to do this @@ -235,6 +237,12 @@ diagnostic_finish (diagnostic_context *context) context->printer->~pretty_printer (); XDELETE (context->printer); context->printer = NULL; + + if (context->edit_context_ptr) + { + delete context->edit_context_ptr; + context->edit_context_ptr = NULL; + } } /* Initialize DIAGNOSTIC, where the message MSG has already been @@ -943,6 +951,9 @@ diagnostic_report_diagnostic (diagnostic_context *context, diagnostic->message.format_spec = saved_format_spec; diagnostic->x_data = NULL; + if (context->edit_context_ptr) + context->edit_context_ptr->add_fixits (diagnostic->richloc); + context->lock--; return true; @@ -1493,7 +1504,7 @@ test_print_parseable_fixits_insert () linemap_line_start (line_table, 5, 100); linemap_add (line_table, LC_LEAVE, false, NULL, 0); location_t where = linemap_position_for_column (line_table, 10); - richloc.add_fixit_insert (where, "added content"); + richloc.add_fixit_insert_before (where, "added content"); print_parseable_fixits (&pp, &richloc); ASSERT_STREQ ("fix-it:\"test.c\":{5:10-5:10}:\"added content\"\n", diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 0727644d96b..ead4d2a9544 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -62,6 +62,8 @@ typedef void (*diagnostic_start_span_fn) (diagnostic_context *, typedef diagnostic_starter_fn diagnostic_finalizer_fn; +class edit_context; + /* This data structure bundles altogether any information relevant to the context of a diagnostic message. */ struct diagnostic_context @@ -209,6 +211,10 @@ struct diagnostic_context /* If true, print fixits in machine-parseable form after the rest of the diagnostic. */ bool parseable_fixits_p; + + /* If non-NULL, an edit_context to which fix-it hints should be + applied, for generating patches. */ + edit_context *edit_context_ptr; }; static inline void diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 44f59bdfb47..ed91767bc96 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2247,6 +2247,33 @@ these macros directly; instead, include the appropriate headers. Some of these macros may not be defined on particular systems if GCC does not provide a @file{stdint.h} header on those systems. +@item __SCHAR_WIDTH__ +@itemx __SHRT_WIDTH__ +@itemx __INT_WIDTH__ +@itemx __LONG_WIDTH__ +@itemx __LONG_LONG_WIDTH__ +@itemx __PTRDIFF_WIDTH__ +@itemx __SIG_ATOMIC_WIDTH__ +@itemx __SIZE_WIDTH__ +@itemx __WCHAR_WIDTH__ +@itemx __WINT_WIDTH__ +@itemx __INT_LEAST8_WIDTH__ +@itemx __INT_LEAST16_WIDTH__ +@itemx __INT_LEAST32_WIDTH__ +@itemx __INT_LEAST64_WIDTH__ +@itemx __INT_FAST8_WIDTH__ +@itemx __INT_FAST16_WIDTH__ +@itemx __INT_FAST32_WIDTH__ +@itemx __INT_FAST64_WIDTH__ +@itemx __INTPTR_WIDTH__ +@itemx __INTMAX_WIDTH__ +Defined to the bit widths of the corresponding types. They exist to +make the implementations of @file{limits.h} and @file{stdint.h} behave +correctly. You should not use these macros directly; instead, include +the appropriate headers. Some of these macros may not be defined on +particular systems if GCC does not provide a @file{stdint.h} header on +those systems. + @item __SIZEOF_INT__ @itemx __SIZEOF_LONG__ @itemx __SIZEOF_LONG_LONG__ diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 8cb93abfa09..299986d86e8 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -9486,7 +9486,7 @@ the pointer points. @end smallexample The object pointed to by the first argument must be of integer or pointer -type. It must not be a Boolean type. +type. It must not be a boolean type. @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand} as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}. @@ -9772,7 +9772,7 @@ they are not scaled by the size of the type to which the pointer points. @end smallexample The object pointed to by the first argument must be of integer or pointer -type. It must not be a Boolean type. All memory orders are valid. +type. It must not be a boolean type. All memory orders are valid. @end deftypefn @@ -9881,10 +9881,10 @@ together with checking whether the operations overflowed. @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res) @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res) -@deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long int *res) +@deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res) @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res) @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) -@deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res) +@deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) These built-in functions promote the first two operands into infinite precision signed type and perform addition on those promoted operands. The result is then @@ -9896,7 +9896,7 @@ behavior for all argument values. The first built-in function allows arbitrary integral types for operands and the result type must be pointer to some integral type other than enumerated or -Boolean type, the rest of the built-in functions have explicit integer types. +boolean type, the rest of the built-in functions have explicit integer types. The compiler will attempt to use hardware instructions to implement these built-in functions where possible, like conditional jump on overflow @@ -9907,10 +9907,10 @@ after addition, conditional jump on carry etc. @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res) @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res) -@deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long int *res) +@deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res) @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res) @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) -@deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res) +@deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) These built-in functions are similar to the add overflow checking built-in functions above, except they perform subtraction, subtract the second argument @@ -9921,10 +9921,10 @@ from the first one, instead of addition. @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res) @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res) @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res) -@deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long int *res) +@deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res) @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res) @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res) -@deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long int *res) +@deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res) These built-in functions are similar to the add overflow checking built-in functions above, except they perform multiplication, instead of addition. @@ -9942,7 +9942,7 @@ These built-in functions are similar to @code{__builtin_add_overflow}, @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that they don't store the result of the arithmetic operation anywhere and the last argument is not a pointer, but some expression with integral type other -than enumerated or Boolean type. +than enumerated or boolean type. The built-in functions promote the first two operands into infinite precision signed type and perform addition on those promoted operands. The result is then @@ -10030,8 +10030,15 @@ __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE); @findex __builtin___fprintf_chk @findex __builtin___vfprintf_chk -GCC implements a limited buffer overflow protection mechanism -that can prevent some buffer overflow attacks. +GCC implements a limited buffer overflow protection mechanism that can +prevent some buffer overflow attacks by determining the sizes of objects +into which data is about to be written and preventing the writes when +the size isn't sufficient. The built-in functions described below yield +the best results when used together and when optimization is enabled. +For example, to detect object sizes across function boundaries or to +follow pointer assignments through non-trivial control flow they rely +on various optimization passes enabled with @option{-O2}. However, to +a limited extent, they can be used without optimization as well. @deftypefn {Built-in Function} {size_t} __builtin_object_size (void * @var{ptr}, int @var{type}) is a built-in construct that returns a constant number of bytes from diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 87da1f1c12b..8eb5eff098e 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -190,7 +190,7 @@ in the following sections. @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @gccoptlist{-fabi-version=@var{n} -fno-access-control @gol --fargs-in-order=@var{n} -fcheck-new @gol +-faligned-new=@var{n} -fargs-in-order=@var{n} -fcheck-new @gol -fconstexpr-depth=@var{n} -fconstexpr-loop-limit=@var{n} @gol -ffriend-injection @gol -fno-elide-constructors @gol @@ -248,7 +248,7 @@ Objective-C and Objective-C++ Dialects}. -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} @gol -fno-diagnostics-show-option -fno-diagnostics-show-caret @gol --fdiagnostics-parseable-fixits} +-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch} @item Warning Options @xref{Warning Options,,Options to Request or Suppress Warnings}. @@ -2237,6 +2237,15 @@ option is used for the warning. Turn off all access checking. This switch is mainly useful for working around bugs in the access control code. +@item -faligned-new +@opindex faligned-new +Enable support for C++17 @code{new} of types that require more +alignment than @code{void* ::operator new(std::size_t)} provides. A +numeric argument such as @code{-faligned-new=32} can be used to +specify how much alignment (in bytes) is provided by that function, +but few users will need to override the default of +@code{alignof(std::max_align_t)}. + @item -fcheck-new @opindex fcheck-new Check that the pointer returned by @code{operator new} is non-null @@ -3343,7 +3352,9 @@ for 88-color and 256-color modes background colors. The default @env{GCC_COLORS} is @smallexample -error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:quote=01:fixit-insert=32:fixit-delete=31 +error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:quote=01:\ +fixit-insert=32:fixit-delete=31:\ +diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32 @end smallexample @noindent where @samp{01;31} is bold red, @samp{01;35} is bold magenta, @@ -3391,6 +3402,22 @@ be inserted or replaced. @vindex fixit-delete GCC_COLORS @r{capability} SGR substring for fix-it hints suggesting text to be deleted. + +@item diff-filename= +@vindex diff-filename GCC_COLORS @r{capability} +SGR substring for filename headers within generated patches. + +@item diff-hunk= +@vindex diff-hunk GCC_COLORS @r{capability} +SGR substring for the starts of hunks within generated patches. + +@item diff-delete= +@vindex diff-delete GCC_COLORS @r{capability} +SGR substring for deleted lines within generated patches. + +@item diff-insert= +@vindex diff-insert GCC_COLORS @r{capability} +SGR substring for inserted lines within generated patches. @end table @item -fno-diagnostics-show-option @@ -3442,6 +3469,27 @@ An empty replacement string indicates that the given range is to be removed. An empty range (e.g. ``45:3-45:3'') indicates that the string is to be inserted at the given position. +@item -fdiagnostics-generate-patch +@opindex fdiagnostics-generate-patch +Print fix-it hints to stderr in unified diff format, after any diagnostics +are printed. For example: + +@smallexample +--- test.c ++++ test.c +@@ -42,5 +42,5 @@ + + void show_cb(GtkDialog *dlg) + @{ +- gtk_widget_showall(dlg); ++ gtk_widget_show_all(dlg); + @} + +@end smallexample + +The diff may or may not be colorized, following the same rules +as for diagnostics (see @option{-fdiagnostics-color}). + @end table @node Warning Options @@ -5023,6 +5071,18 @@ disables the warnings about non-ISO @code{printf} / @code{scanf} format width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, which depend on the MS runtime. +@item -Waligned-new +@opindex Waligned-new +@opindex Wno-aligned-new +Warn about a new-expression of a type that requires greater alignment +than the @code{alignof(std::max_align_t)} but uses an allocation +function without an explicit alignment parameter. This option is +enabled by @option{-Wall}. + +Normally this only warns about global allocation functions, but +@option{-Waligned-new=all} also warns about class member allocation +functions. + @item -Wplacement-new @itemx -Wplacement-new=@var{n} @opindex Wplacement-new @@ -5437,8 +5497,8 @@ if (a < 0 && a < 0) @{ @dots{} @} @opindex Wlogical-not-parentheses @opindex Wno-logical-not-parentheses Warn about logical not used on the left hand side operand of a comparison. -This option does not warn if the RHS operand is of a boolean type. Its -purpose is to detect suspicious code like the following: +This option does not warn if the right operand is considered to be a boolean +expression. Its purpose is to detect suspicious code like the following: @smallexample int a; @dots{} @@ -22807,16 +22867,16 @@ more efficient. The default behavior is to use atomic updates. @item -mdual-nops @itemx -mdual-nops=@var{n} @opindex mdual-nops -By default, GCC inserts nops to increase dual issue when it expects +By default, GCC inserts NOPs to increase dual issue when it expects it to increase performance. @var{n} can be a value from 0 to 10. A -smaller @var{n} inserts fewer nops. 10 is the default, 0 is the +smaller @var{n} inserts fewer NOPs. 10 is the default, 0 is the same as @option{-mno-dual-nops}. Disabled with @option{-Os}. @item -mhint-max-nops=@var{n} @opindex mhint-max-nops -Maximum number of nops to insert for a branch hint. A branch hint must +Maximum number of NOPs to insert for a branch hint. A branch hint must be at least 8 instructions away from the branch it is affecting. GCC -inserts up to @var{n} nops to enforce this, otherwise it does not +inserts up to @var{n} NOPs to enforce this, otherwise it does not generate the branch hint. @item -mhint-max-distance=@var{n} @@ -24601,7 +24661,7 @@ automatically patching and out calls. @itemx -mno-nop-mcount @opindex mnop-mcount If profiling is active (@option{-pg}), generate the calls to -the profiling functions as nops. This is useful when they +the profiling functions as NOPs. This is useful when they should be patched in later dynamically. This is likely only useful together with @option{-mrecord-mcount}. diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 996b1649251..c1015f09a82 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -700,7 +700,7 @@ predicates used with @code{match_operand} have names that end in @samp{_operand}, and those used with @code{match_operator} have names that end in @samp{_operator}. -All predicates are Boolean functions (in the mathematical sense) of +All predicates are boolean functions (in the mathematical sense) of two arguments: the RTL expression that is being considered at that position in the instruction pattern, and the machine mode that the @code{match_operand} or @code{match_operator} specifies. In this @@ -4274,7 +4274,7 @@ constraint. Docstrings are explained further below. @end deffn Non-register constraints are more like predicates: the constraint -definition gives a Boolean expression which indicates whether the +definition gives a boolean expression which indicates whether the constraint matches. @deffn {MD Expression} define_constraint name docstring exp diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 58662606243..8d533d53083 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -1891,7 +1891,7 @@ This hook may conditionally modify five variables @code{fixed_regs}, @code{call_used_regs}, @code{global_regs}, @code{reg_names}, and @code{reg_class_contents}, to take into account any dependence of these register sets on target flags. The first three -of these are of type @code{char []} (interpreted as Boolean vectors). +of these are of type @code{char []} (interpreted as boolean vectors). @code{global_regs} is a @code{const char *[]}, and @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is called, @code{fixed_regs}, @code{call_used_regs}, @@ -2861,7 +2861,7 @@ A target hook which can change allocno class for given pseudo from @end deftypefn @deftypefn {Target Hook} bool TARGET_LRA_P (void) -A target hook which returns true if we use LRA instead of reload pass. The default version of this target hook returns always false, but new ports should use LRA. +A target hook which returns true if we use LRA instead of reload pass. The default version of this target hook returns always true. New ports should use LRA, and existing ports are encouraged to convert. @end deftypefn @deftypefn {Target Hook} int TARGET_REGISTER_PRIORITY (int) @@ -3624,7 +3624,7 @@ pointer. In certain cases, the compiler does not know how to produce valid code without a frame pointer. The compiler recognizes those cases and automatically gives the function a frame pointer regardless of what -@code{TARGET_FRAME_POINTER_REQUIRED} returns. You don't need to worry about +@code{targetm.frame_pointer_required} returns. You don't need to worry about them. In a function that does not require a frame pointer, the frame pointer @@ -3634,25 +3634,9 @@ fixed register. See @code{FIXED_REGISTERS} for more information. Default return value is @code{false}. @end deftypefn -@findex get_frame_size -@defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var}) -A C statement to store in the variable @var{depth-var} the difference -between the frame pointer and the stack pointer values immediately after -the function prologue. The value would be computed from information -such as the result of @code{get_frame_size ()} and the tables of -registers @code{regs_ever_live} and @code{call_used_regs}. - -If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and -need not be defined. Otherwise, it must be defined even if -@code{TARGET_FRAME_POINTER_REQUIRED} always returns true; in that -case, you may set @var{depth-var} to anything. -@end defmac - @defmac ELIMINABLE_REGS -If defined, this macro specifies a table of register pairs used to -eliminate unneeded registers that point into the stack frame. If it is not -defined, the only elimination attempted by the compiler is to replace -references to the frame pointer with references to the stack pointer. +This macro specifies a table of register pairs used to eliminate +unneeded registers that point into the stack frame. The definition of this macro is a list of structure initializations, each of which specifies an original and replacement register. @@ -3676,21 +3660,20 @@ specified first since that is the preferred elimination. @end defmac @deftypefn {Target Hook} bool TARGET_CAN_ELIMINATE (const int @var{from_reg}, const int @var{to_reg}) -This target hook should returns @code{true} if the compiler is allowed to +This target hook should return @code{true} if the compiler is allowed to try to replace register number @var{from_reg} with register number -@var{to_reg}. This target hook need only be defined if @code{ELIMINABLE_REGS} -is defined, and will usually be @code{true}, since most of the cases -preventing register elimination are things that the compiler already +@var{to_reg}. This target hook will usually be @code{true}, since most of the +cases preventing register elimination are things that the compiler already knows about. Default return value is @code{true}. @end deftypefn @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var}) -This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It -specifies the initial difference between the specified pair of -registers. This macro must be defined if @code{ELIMINABLE_REGS} is -defined. +This macro returns the initial difference between the specified pair +of registers. The value would be computed from information +such as the result of @code{get_frame_size ()} and the tables of +registers @code{df_regs_ever_live_p} and @code{call_used_regs}. @end defmac @node Stack Arguments @@ -9735,10 +9718,11 @@ between the two given labels in system defined units, e.g. instruction slots on IA64 VMS, using an integer of the given size. @end defmac -@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{section}) +@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{offset}, @var{section}) A C statement to issue assembly directives that create a -section-relative reference to the given @var{label}, using an integer of the -given @var{size}. The label is known to be defined in the given @var{section}. +section-relative reference to the given @var{label} plus @var{offset}, using +an integer of the given @var{size}. The label is known to be defined in the +given @var{section}. @end defmac @defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label}) diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index da133a4b701..b1482381c9a 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -3177,25 +3177,9 @@ This is about eliminating the frame pointer and arg pointer. @hook TARGET_FRAME_POINTER_REQUIRED -@findex get_frame_size -@defmac INITIAL_FRAME_POINTER_OFFSET (@var{depth-var}) -A C statement to store in the variable @var{depth-var} the difference -between the frame pointer and the stack pointer values immediately after -the function prologue. The value would be computed from information -such as the result of @code{get_frame_size ()} and the tables of -registers @code{regs_ever_live} and @code{call_used_regs}. - -If @code{ELIMINABLE_REGS} is defined, this macro will be not be used and -need not be defined. Otherwise, it must be defined even if -@code{TARGET_FRAME_POINTER_REQUIRED} always returns true; in that -case, you may set @var{depth-var} to anything. -@end defmac - @defmac ELIMINABLE_REGS -If defined, this macro specifies a table of register pairs used to -eliminate unneeded registers that point into the stack frame. If it is not -defined, the only elimination attempted by the compiler is to replace -references to the frame pointer with references to the stack pointer. +This macro specifies a table of register pairs used to eliminate +unneeded registers that point into the stack frame. The definition of this macro is a list of structure initializations, each of which specifies an original and replacement register. @@ -3221,10 +3205,10 @@ specified first since that is the preferred elimination. @hook TARGET_CAN_ELIMINATE @defmac INITIAL_ELIMINATION_OFFSET (@var{from-reg}, @var{to-reg}, @var{offset-var}) -This macro is similar to @code{INITIAL_FRAME_POINTER_OFFSET}. It -specifies the initial difference between the specified pair of -registers. This macro must be defined if @code{ELIMINABLE_REGS} is -defined. +This macro returns the initial difference between the specified pair +of registers. The value would be computed from information +such as the result of @code{get_frame_size ()} and the tables of +registers @code{df_regs_ever_live_p} and @code{call_used_regs}. @end defmac @node Stack Arguments @@ -7075,10 +7059,11 @@ between the two given labels in system defined units, e.g. instruction slots on IA64 VMS, using an integer of the given size. @end defmac -@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{section}) +@defmac ASM_OUTPUT_DWARF_OFFSET (@var{stream}, @var{size}, @var{label}, @var{offset}, @var{section}) A C statement to issue assembly directives that create a -section-relative reference to the given @var{label}, using an integer of the -given @var{size}. The label is known to be defined in the given @var{section}. +section-relative reference to the given @var{label} plus @var{offset}, using +an integer of the given @var{size}. The label is known to be defined in the +given @var{section}. @end defmac @defmac ASM_OUTPUT_DWARF_PCREL (@var{stream}, @var{size}, @var{label}) diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c index ae81445dc84..cad550916d4 100644 --- a/gcc/dwarf2asm.c +++ b/gcc/dwarf2asm.c @@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see #include "output.h" #include "dwarf2asm.h" #include "dwarf2.h" +#include "function.h" +#include "emit-rtl.h" #ifndef XCOFF_DEBUGGING_INFO #define XCOFF_DEBUGGING_INFO 0 @@ -191,7 +193,7 @@ dw2_asm_output_offset (int size, const char *label, va_start (ap, comment); #ifdef ASM_OUTPUT_DWARF_OFFSET - ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, base); + ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, 0, base); #else dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label)); #endif @@ -206,6 +208,33 @@ dw2_asm_output_offset (int size, const char *label, va_end (ap); } +void +dw2_asm_output_offset (int size, const char *label, HOST_WIDE_INT offset, + section *base ATTRIBUTE_UNUSED, + const char *comment, ...) +{ + va_list ap; + + va_start (ap, comment); + +#ifdef ASM_OUTPUT_DWARF_OFFSET + ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label, offset, base); +#else + dw2_assemble_integer (size, gen_rtx_PLUS (Pmode, + gen_rtx_SYMBOL_REF (Pmode, label), + gen_int_mode (offset, Pmode))); +#endif + + if (flag_debug_asm && comment) + { + fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); + vfprintf (asm_out_file, comment, ap); + } + fputc ('\n', asm_out_file); + + va_end (ap); +} + #if 0 /* Output a self-relative reference to a label, possibly in a diff --git a/gcc/dwarf2asm.h b/gcc/dwarf2asm.h index d468fc8f346..42064d34d22 100644 --- a/gcc/dwarf2asm.h +++ b/gcc/dwarf2asm.h @@ -40,6 +40,10 @@ extern void dw2_asm_output_offset (int, const char *, section *, const char *, ...) ATTRIBUTE_NULL_PRINTF_4; +extern void dw2_asm_output_offset (int, const char *, HOST_WIDE_INT, + section *, const char *, ...) + ATTRIBUTE_NULL_PRINTF_5; + extern void dw2_asm_output_addr (int, const char *, const char *, ...) ATTRIBUTE_NULL_PRINTF_3; diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 11e011399af..434a2fc8b5a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -2711,9 +2711,14 @@ die_node; /* Set to TRUE while dwarf2out_early_global_decl is running. */ static bool early_dwarf; +static bool early_dwarf_finished; struct set_early_dwarf { bool saved; - set_early_dwarf () : saved(early_dwarf) { early_dwarf = true; } + set_early_dwarf () : saved(early_dwarf) + { + gcc_assert (! early_dwarf_finished); + early_dwarf = true; + } ~set_early_dwarf () { early_dwarf = saved; } }; @@ -23878,18 +23883,31 @@ dwarf2out_early_global_decl (tree decl) static void dwarf2out_late_global_decl (tree decl) { - /* We have to generate early debug late for LTO. */ - if (in_lto_p) - dwarf2out_early_global_decl (decl); - - /* Fill-in any location information we were unable to determine - on the first pass. */ + /* Fill-in any location information we were unable to determine + on the first pass. */ if (TREE_CODE (decl) == VAR_DECL && !POINTER_BOUNDS_P (decl)) { dw_die_ref die = lookup_decl_die (decl); + + /* We have to generate early debug late for LTO. */ + if (! die && in_lto_p) + { + dwarf2out_decl (decl); + die = lookup_decl_die (decl); + } + if (die) - add_location_or_const_value_attribute (die, decl, false); + { + /* We get called during the early debug phase via the symtab + code invoking late_global_decl for symbols that are optimized + out. When the early phase is not finished, do not add + locations. */ + if (! early_dwarf_finished) + tree_add_const_value_attribute_for_decl (die, decl); + else + add_location_or_const_value_attribute (die, decl, false); + } } } @@ -28137,6 +28155,14 @@ dwarf2out_early_finish (void) { set_early_dwarf s; + /* With LTO early dwarf was really finished at compile-time, so make + sure to adjust the phase after annotating the LTRANS CU DIE. */ + if (in_lto_p) + { + early_dwarf_finished = true; + return; + } + /* Walk through the list of incomplete types again, trying once more to emit full debugging info for them. */ retry_incomplete_types (); @@ -28163,6 +28189,9 @@ dwarf2out_early_finish (void) } } deferred_asm_name = NULL; + + /* The early debug phase is now finished. */ + early_dwarf_finished = true; } /* Reset all state within dwarf2out.c so that we can rerun the compiler diff --git a/gcc/edit-context.c b/gcc/edit-context.c new file mode 100644 index 00000000000..5945f423d29 --- /dev/null +++ b/gcc/edit-context.c @@ -0,0 +1,1666 @@ +/* Determining the results of applying fix-it hints. + Copyright (C) 2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "line-map.h" +#include "edit-context.h" +#include "pretty-print.h" +#include "diagnostic-color.h" +#include "selftest.h" + +/* This file implements a way to track the effect of fix-its, + via a class edit_context; the other classes are support classes for + edit_context. + + A complication here is that fix-its are expressed relative to coordinates + in the file when it was parsed, before any changes have been made, and + so if there's more that one fix-it to be applied, we have to adjust + later fix-its to allow for the changes made by earlier ones. This + is done by the various "get_effective_column" methods. + + The "filename" params are required to outlive the edit_context (no + copy of the underlying str is taken, just the ptr). */ + +/* Forward decls. class edit_context is declared within edit-context.h. + The other types are declared here. */ +class edit_context; +class edited_file; +class edited_line; +class line_event; + class insert_event; + class replace_event; + +/* A struct to hold the params of a print_diff call. */ + +struct diff +{ + diff (pretty_printer *pp, bool show_filenames) + : m_pp (pp), m_show_filenames (show_filenames) {} + + pretty_printer *m_pp; + bool m_show_filenames; +}; + +/* The state of one named file within an edit_context: the filename, + and the lines that have been edited so far. */ + +class edited_file +{ + public: + edited_file (const char *filename); + static void delete_cb (edited_file *file); + + const char *get_filename () const { return m_filename; } + char *get_content (); + + bool apply_insert (int line, int column, const char *str, int len); + bool apply_replace (int line, int start_column, + int finish_column, + const char *replacement_str, + int replacement_len); + int get_effective_column (int line, int column); + + static int call_print_diff (const char *, edited_file *file, + void *user_data) + { + diff *d = (diff *)user_data; + file->print_diff (d->m_pp, d->m_show_filenames); + return 0; + } + + private: + bool print_content (pretty_printer *pp); + void print_diff (pretty_printer *pp, bool show_filenames); + void print_diff_hunk (pretty_printer *pp, int start_of_hunk, + int end_of_hunk); + void print_diff_line (pretty_printer *pp, char prefix_char, + const char *line, int line_size); + edited_line *get_line (int line); + edited_line *get_or_insert_line (int line); + int get_num_lines (bool *missing_trailing_newline); + + const char *m_filename; + typed_splay_tree<int, edited_line *> m_edited_lines; + int m_num_lines; +}; + +/* The state of one edited line within an edited_file. + As well as the current content of the line, it contains a record of + the changes, so that further changes can be applied in the correct + place. */ + +class edited_line +{ + public: + edited_line (const char *filename, int line_num); + ~edited_line (); + static void delete_cb (edited_line *el); + + int get_line_num () const { return m_line_num; } + const char *get_content () const { return m_content; } + int get_len () const { return m_len; } + + int get_effective_column (int orig_column) const; + bool apply_insert (int column, const char *str, int len); + bool apply_replace (int start_column, + int finish_column, + const char *replacement_str, + int replacement_len); + + private: + void ensure_capacity (int len); + void ensure_terminated (); + void print_content (pretty_printer *pp) const; + + int m_line_num; + char *m_content; + int m_len; + int m_alloc_sz; + auto_vec <line_event *> m_line_events; +}; + +/* Abstract base class for representing events that have occurred + on one line of one file. */ + +class line_event +{ + public: + virtual ~line_event () {} + virtual int get_effective_column (int orig_column) const = 0; +}; + +/* Concrete subclass of line_event: an insertion of some text + at some column on the line. + + Subsequent events will need their columns adjusting if they're + are on this line and their column is >= the insertion point. */ + +class insert_event : public line_event +{ + public: + insert_event (int column, int len) : m_column (column), m_len (len) {} + int get_effective_column (int orig_column) const FINAL OVERRIDE + { + if (orig_column >= m_column) + return orig_column + m_len; + else + return orig_column; + } + + private: + int m_column; + int m_len; +}; + +/* Concrete subclass of line_event: the replacement of some text + betweeen some columns on the line. + + Subsequent events will need their columns adjusting if they're + are on this line and their column is >= the finish point. */ + +class replace_event : public line_event +{ + public: + replace_event (int start, int finish, int len) : m_start (start), + m_finish (finish), m_delta (len - (finish + 1 - start)) {} + + int get_effective_column (int orig_column) const FINAL OVERRIDE + { + if (orig_column >= m_start) + return orig_column += m_delta; + else + return orig_column; + } + + private: + int m_start; + int m_finish; + int m_delta; +}; + +/* Implementation of class edit_context. */ + +/* edit_context's ctor. */ + +edit_context::edit_context () +: m_valid (true), + m_files (strcmp, NULL, edited_file::delete_cb) +{} + +/* Add any fixits within RICHLOC to this context, recording the + changes that they make. */ + +void +edit_context::add_fixits (rich_location *richloc) +{ + if (!m_valid) + return; + if (richloc->seen_impossible_fixit_p ()) + { + m_valid = false; + return; + } + for (unsigned i = 0; i < richloc->get_num_fixit_hints (); i++) + { + const fixit_hint *hint = richloc->get_fixit_hint (i); + switch (hint->get_kind ()) + { + case fixit_hint::INSERT: + if (!apply_insert ((const fixit_insert *)hint)) + { + /* Failure. */ + m_valid = false; + return; + } + break; + case fixit_hint::REPLACE: + if (!apply_replace ((const fixit_replace *)hint)) + { + /* Failure. */ + m_valid = false; + return; + } + break; + default: + gcc_unreachable (); + } + } +} + +/* Get the content of the given file, with fix-its applied. + If any errors occurred in this edit_context, return NULL. + The ptr should be freed by the caller. */ + +char * +edit_context::get_content (const char *filename) +{ + if (!m_valid) + return NULL; + edited_file &file = get_or_insert_file (filename); + return file.get_content (); +} + +/* Map a location before the edits to a column number after the edits. + This method is for the selftests. */ + +int +edit_context::get_effective_column (const char *filename, int line, + int column) +{ + edited_file *file = get_file (filename); + if (!file) + return column; + return file->get_effective_column (line, column); +} + +/* Generate a unified diff. The resulting string should be freed by the + caller. Primarily for selftests. + If any errors occurred in this edit_context, return NULL. */ + +char * +edit_context::generate_diff (bool show_filenames) +{ + if (!m_valid) + return NULL; + + pretty_printer pp; + print_diff (&pp, show_filenames); + return xstrdup (pp_formatted_text (&pp)); +} + +/* Print a unified diff to PP, showing the changes made within the + context. */ + +void +edit_context::print_diff (pretty_printer *pp, bool show_filenames) +{ + if (!m_valid) + return; + diff d (pp, show_filenames); + m_files.foreach (edited_file::call_print_diff, &d); +} + +/* Attempt to apply the given fixit. Return true if it can be + applied, or false otherwise. */ + +bool +edit_context::apply_insert (const fixit_insert *insert) +{ + expanded_location exploc = expand_location (insert->get_location ()); + + if (exploc.column == 0) + return false; + + edited_file &file = get_or_insert_file (exploc.file); + if (!m_valid) + return false; + return file.apply_insert (exploc.line, exploc.column, insert->get_string (), + insert->get_length ()); +} + +/* Attempt to apply the given fixit. Return true if it can be + applied, or false otherwise. */ + +bool +edit_context::apply_replace (const fixit_replace *replace) +{ + source_range range = replace->get_range (); + + expanded_location start = expand_location (range.m_start); + expanded_location finish = expand_location (range.m_finish); + if (start.file != finish.file) + return false; + if (start.line != finish.line) + return false; + if (start.column == 0) + return false; + if (finish.column == 0) + return false; + + edited_file &file = get_or_insert_file (start.file); + if (!m_valid) + return false; + return file.apply_replace (start.line, start.column, finish.column, + replace->get_string (), + replace->get_length ()); +} + +/* Locate the edited_file * for FILENAME, if any + Return NULL if there isn't one. */ + +edited_file * +edit_context::get_file (const char *filename) +{ + gcc_assert (filename); + return m_files.lookup (filename); +} + +/* Locate the edited_file for FILENAME, adding one if there isn't one. */ + +edited_file & +edit_context::get_or_insert_file (const char *filename) +{ + gcc_assert (filename); + + edited_file *file = get_file (filename); + if (file) + return *file; + + /* Not found. */ + file = new edited_file (filename); + m_files.insert (filename, file); + return *file; +} + +/* Implementation of class edited_file. */ + +/* Callback for m_edited_lines, for comparing line numbers. */ + +static int line_comparator (int a, int b) +{ + return a - b; +} + +/* edited_file's constructor. */ + +edited_file::edited_file (const char *filename) +: m_filename (filename), + m_edited_lines (line_comparator, NULL, edited_line::delete_cb), + m_num_lines (-1) +{ +} + +/* A callback for deleting edited_file *, for use as a + delete_value_fn for edit_context::m_files. */ + +void +edited_file::delete_cb (edited_file *file) +{ + delete file; +} + +/* Get the content of the file, with fix-its applied. + The ptr should be freed by the caller. */ + +char * +edited_file::get_content () +{ + pretty_printer pp; + if (!print_content (&pp)) + return NULL; + return xstrdup (pp_formatted_text (&pp)); +} + +/* Attempt to insert the string INSERT_STR with length INSERT_LEN + at LINE and COLUMN, updating the in-memory copy of the line, and + the record of edits to the line. */ + +bool +edited_file::apply_insert (int line, int column, + const char *insert_str, + int insert_len) +{ + edited_line *el = get_or_insert_line (line); + if (!el) + return false; + return el->apply_insert (column, insert_str, insert_len); +} + +/* Attempt to replace columns START_COLUMN through FINISH_COLUMN of LINE + with the string REPLACEMENT_STR of length REPLACEMENT_LEN, + updating the in-memory copy of the line, and the record of edits to + the line. */ + +bool +edited_file::apply_replace (int line, int start_column, + int finish_column, + const char *replacement_str, + int replacement_len) +{ + edited_line *el = get_or_insert_line (line); + if (!el) + return false; + return el->apply_replace (start_column, finish_column, replacement_str, + replacement_len); +} + +/* Given line LINE, map from COLUMN in the input file to its current + column after edits have been applied. */ + +int +edited_file::get_effective_column (int line, int column) +{ + const edited_line *el = get_line (line); + if (!el) + return column; + return el->get_effective_column (column); +} + +/* Attempt to print the content of the file to PP, with edits applied. + Return true if successful, false otherwise. */ + +bool +edited_file::print_content (pretty_printer *pp) +{ + bool missing_trailing_newline; + int line_count = get_num_lines (&missing_trailing_newline); + for (int line_num = 1; line_num <= line_count; line_num++) + { + edited_line *el = get_line (line_num); + if (el) + pp_string (pp, el->get_content ()); + else + { + int len; + const char *line + = location_get_source_line (m_filename, line_num, &len); + if (!line) + return false; + for (int i = 0; i < len; i++) + pp_character (pp, line[i]); + } + if (line_num < line_count) + pp_character (pp, '\n'); + } + + if (!missing_trailing_newline) + pp_character (pp, '\n'); + + return true; +} + +/* Print a unified diff to PP, showing any changes that have occurred + to this file. */ + +void +edited_file::print_diff (pretty_printer *pp, bool show_filenames) +{ + if (show_filenames) + { + pp_string (pp, colorize_start (pp_show_color (pp), "diff-filename")); + pp_printf (pp, "--- %s\n", m_filename); + pp_printf (pp, "+++ %s\n", m_filename); + pp_string (pp, colorize_stop (pp_show_color (pp))); + } + + edited_line *el = m_edited_lines.min (); + + bool missing_trailing_newline; + int line_count = get_num_lines (&missing_trailing_newline); + + const int context_lines = 3; + + while (el) + { + int start_of_hunk = el->get_line_num (); + start_of_hunk -= context_lines; + if (start_of_hunk < 1) + start_of_hunk = 1; + + /* Locate end of hunk, merging in changed lines + that are sufficiently close. */ + while (true) + { + edited_line *next_el + = m_edited_lines.successor (el->get_line_num ()); + if (!next_el) + break; + if (el->get_line_num () + context_lines + >= next_el->get_line_num () - context_lines) + el = next_el; + else + break; + } + int end_of_hunk = el->get_line_num (); + end_of_hunk += context_lines; + if (end_of_hunk > line_count) + end_of_hunk = line_count; + + print_diff_hunk (pp, start_of_hunk, end_of_hunk); + + el = m_edited_lines.successor (el->get_line_num ()); + } +} + +/* Print one hunk within a unified diff to PP, covering the + given range of lines. */ + +void +edited_file::print_diff_hunk (pretty_printer *pp, int start_of_hunk, + int end_of_hunk) +{ + int num_lines = end_of_hunk - start_of_hunk + 1; + + pp_string (pp, colorize_start (pp_show_color (pp), "diff-hunk")); + pp_printf (pp, "@@ -%i,%i +%i,%i @@\n", start_of_hunk, num_lines, + start_of_hunk, num_lines); + pp_string (pp, colorize_stop (pp_show_color (pp))); + + int line_num = start_of_hunk; + while (line_num <= end_of_hunk) + { + edited_line *el = get_line (line_num); + if (el) + { + /* We have an edited line. + Consolidate into runs of changed lines. */ + const int first_changed_line_in_run = line_num; + while (get_line (line_num)) + line_num++; + const int last_changed_line_in_run = line_num - 1; + + /* Show old version of lines. */ + pp_string (pp, colorize_start (pp_show_color (pp), + "diff-delete")); + for (line_num = first_changed_line_in_run; + line_num <= last_changed_line_in_run; + line_num++) + { + int line_len; + const char *old_line + = location_get_source_line (m_filename, line_num, &line_len); + print_diff_line (pp, '-', old_line, line_len); + } + pp_string (pp, colorize_stop (pp_show_color (pp))); + + /* Show new version of lines. */ + pp_string (pp, colorize_start (pp_show_color (pp), + "diff-insert")); + for (line_num = first_changed_line_in_run; + line_num <= last_changed_line_in_run; + line_num++) + { + edited_line *el_in_run = get_line (line_num); + gcc_assert (el_in_run); + print_diff_line (pp, '+', el_in_run->get_content (), + el_in_run->get_len ()); + } + pp_string (pp, colorize_stop (pp_show_color (pp))); + } + else + { + /* Unchanged line. */ + int line_len; + const char *old_line + = location_get_source_line (m_filename, line_num, &line_len); + print_diff_line (pp, ' ', old_line, line_len); + line_num++; + } + } +} + +/* Print one line within a diff, starting with PREFIX_CHAR, + followed by the LINE of content, of length LEN. LINE is + not necessarily 0-terminated. Print a trailing newline. */ + +void +edited_file::print_diff_line (pretty_printer *pp, char prefix_char, + const char *line, int len) +{ + pp_character (pp, prefix_char); + for (int i = 0; i < len; i++) + pp_character (pp, line[i]); + pp_character (pp, '\n'); +} + +/* Get the state of LINE within the file, or NULL if it is untouched. */ + +edited_line * +edited_file::get_line (int line) +{ + return m_edited_lines.lookup (line); +} + +/* Get the state of LINE within the file, creating a state for it + if necessary. Return NULL if an error occurs. */ + +edited_line * +edited_file::get_or_insert_line (int line) +{ + edited_line *el = get_line (line); + if (el) + return el; + el = new edited_line (m_filename, line); + if (el->get_content () == NULL) + { + delete el; + return NULL; + } + m_edited_lines.insert (line, el); + return el; +} + +/* Get the total number of lines in m_content, writing + true to *MISSING_TRAILING_NEWLINE if the final line + if missing a newline, false otherwise. */ + +int +edited_file::get_num_lines (bool *missing_trailing_newline) +{ + gcc_assert (missing_trailing_newline); + if (m_num_lines == -1) + { + m_num_lines = 0; + while (true) + { + int line_size; + const char *line + = location_get_source_line (m_filename, m_num_lines + 1, + &line_size); + if (line) + m_num_lines++; + else + break; + } + } + *missing_trailing_newline = location_missing_trailing_newline (m_filename); + return m_num_lines; +} + +/* Implementation of class edited_line. */ + +/* edited_line's ctor. */ + +edited_line::edited_line (const char *filename, int line_num) +: m_line_num (line_num), + m_content (NULL), m_len (0), m_alloc_sz (0), + m_line_events () +{ + const char *line = location_get_source_line (filename, line_num, + &m_len); + if (!line) + return; + ensure_capacity (m_len); + memcpy (m_content, line, m_len); + ensure_terminated (); +} + +/* edited_line's dtor. */ + +edited_line::~edited_line () +{ + free (m_content); + + int i; + line_event *event; + FOR_EACH_VEC_ELT (m_line_events, i, event) + delete event; +} + +/* A callback for deleting edited_line *, for use as a + delete_value_fn for edited_file::m_edited_lines. */ + +void +edited_line::delete_cb (edited_line *el) +{ + delete el; +} + +/* Map a location before the edits to a column number after the edits, + within a specific line. */ + +int +edited_line::get_effective_column (int orig_column) const +{ + int i; + line_event *event; + FOR_EACH_VEC_ELT (m_line_events, i, event) + orig_column = event->get_effective_column (orig_column); + return orig_column; +} + +/* Attempt to insert the string INSERT_STR with length INSERT_LEN at COLUMN + of this line, updating the in-memory copy of the line, and the record + of edits to it. + Return true if successful; false if an error occurred. */ + +bool +edited_line::apply_insert (int column, const char *insert_str, + int insert_len) +{ + column = get_effective_column (column); + + int start_offset = column - 1; + gcc_assert (start_offset >= 0); + if (start_offset > m_len) + return false; + + /* Ensure buffer is big enough. */ + size_t new_len = m_len + insert_len; + ensure_capacity (new_len); + + char *suffix = m_content + start_offset; + gcc_assert (suffix <= m_content + m_len); + size_t len_suffix = (m_content + m_len) - suffix; + + /* Move successor content into position. They overlap, so use memmove. */ + memmove (m_content + start_offset + insert_len, + suffix, len_suffix); + + /* Replace target content. They don't overlap, so use memcpy. */ + memcpy (m_content + start_offset, + insert_str, + insert_len); + + m_len = new_len; + + ensure_terminated (); + + /* Record the insertion, so that future changes to the line can have + their column information adjusted accordingly. */ + m_line_events.safe_push (new insert_event (column, insert_len)); + + return true; +} + +/* Attempt to replace columns START_COLUMN through FINISH_COLUMN of the line + with the string REPLACEMENT_STR of length REPLACEMENT_LEN, + updating the in-memory copy of the line, and the record of edits to + the line. + Return true if successful; false if an error occurred. */ + +bool +edited_line::apply_replace (int start_column, + int finish_column, + const char *replacement_str, + int replacement_len) +{ + start_column = get_effective_column (start_column); + finish_column = get_effective_column (finish_column); + + int start_offset = start_column - 1; + int end_offset = finish_column - 1; + + gcc_assert (start_offset >= 0); + gcc_assert (end_offset >= 0); + + if (start_column > finish_column) + return false; + if (start_offset >= m_len) + return false; + if (end_offset >= m_len) + return false; + + size_t victim_len = end_offset - start_offset + 1; + + /* Ensure buffer is big enough. */ + size_t new_len = m_len + replacement_len - victim_len; + ensure_capacity (new_len); + + char *suffix = m_content + end_offset + 1; + gcc_assert (suffix <= m_content + m_len); + size_t len_suffix = (m_content + m_len) - suffix; + + /* Move successor content into position. They overlap, so use memmove. */ + memmove (m_content + start_offset + replacement_len, + suffix, len_suffix); + + /* Replace target content. They don't overlap, so use memcpy. */ + memcpy (m_content + start_offset, + replacement_str, + replacement_len); + + m_len = new_len; + + ensure_terminated (); + + /* Record the replacement, so that future changes to the line can have + their column information adjusted accordingly. */ + m_line_events.safe_push (new replace_event (start_column, finish_column, + replacement_len)); + return true; +} + +/* Ensure that the buffer for m_content is at least large enough to hold + a string of length LEN and its 0-terminator, doubling on repeated + allocations. */ + +void +edited_line::ensure_capacity (int len) +{ + /* Allow 1 extra byte for 0-termination. */ + if (m_alloc_sz < (len + 1)) + { + size_t new_alloc_sz = (len + 1) * 2; + m_content = (char *)xrealloc (m_content, new_alloc_sz); + m_alloc_sz = new_alloc_sz; + } +} + +/* Ensure that m_content is 0-terminated. */ + +void +edited_line::ensure_terminated () +{ + /* 0-terminate the buffer. */ + gcc_assert (m_len < m_alloc_sz); + m_content[m_len] = '\0'; +} + +#if CHECKING_P + +/* Selftests of code-editing. */ + +namespace selftest { + +/* A wrapper class for ensuring that the underlying pointer is freed. */ + +template <typename POINTER_T> +class auto_free +{ + public: + auto_free (POINTER_T p) : m_ptr (p) {} + ~auto_free () { free (m_ptr); } + + operator POINTER_T () { return m_ptr; } + + private: + POINTER_T m_ptr; +}; + +/* Verify that edit_context::get_content works for unedited files. */ + +static void +test_get_content () +{ + /* Test of empty file. */ + { + const char *content = (""); + temp_source_file tmp (SELFTEST_LOCATION, ".c", content); + edit_context edit; + auto_free <char *> result = edit.get_content (tmp.get_filename ()); + ASSERT_STREQ ("", result); + } + + /* Test of simple content. */ + { + const char *content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", content); + edit_context edit; + auto_free <char *> result = edit.get_content (tmp.get_filename ()); + ASSERT_STREQ ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n", result); + } + + /* Test of omitting the trailing newline on the final line. */ + { + const char *content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", content); + edit_context edit; + auto_free <char *> result = edit.get_content (tmp.get_filename ()); + /* We should respect the omitted trailing newline. */ + ASSERT_STREQ ("/* before */\n" + "foo = bar.field;\n" + "/* after */", result); + } +} + +/* Test applying an "insert" fixit, using insert_before. */ + +static void +test_applying_fixits_insert_before (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 2); + + /* Add a comment in front of "bar.field". */ + location_t start = linemap_position_for_column (line_table, 7); + rich_location richloc (line_table, start); + richloc.add_fixit_insert_before ("/* inserted */"); + + if (start > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + if (start <= LINE_MAP_MAX_LOCATION_WITH_COLS) + ASSERT_STREQ ("/* before */\n" + "foo = /* inserted */bar.field;\n" + "/* after */\n", new_content); + + /* Verify that locations on other lines aren't affected by the change. */ + ASSERT_EQ (100, edit.get_effective_column (filename, 1, 100)); + ASSERT_EQ (100, edit.get_effective_column (filename, 3, 100)); + + /* Verify locations on the line before the change. */ + ASSERT_EQ (1, edit.get_effective_column (filename, 2, 1)); + ASSERT_EQ (6, edit.get_effective_column (filename, 2, 6)); + + /* Verify locations on the line at and after the change. */ + ASSERT_EQ (21, edit.get_effective_column (filename, 2, 7)); + ASSERT_EQ (22, edit.get_effective_column (filename, 2, 8)); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.field;\n" + "+foo = /* inserted */bar.field;\n" + " /* after */\n", diff); +} + +/* Test applying an "insert" fixit, using insert_after, with + a range of length > 1 (to ensure that the end-point of + the input range is used). */ + +static void +test_applying_fixits_insert_after (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 2); + + /* Add a comment after "field". */ + location_t start = linemap_position_for_column (line_table, 11); + location_t finish = linemap_position_for_column (line_table, 15); + location_t field = make_location (start, start, finish); + rich_location richloc (line_table, field); + richloc.add_fixit_insert_after ("/* inserted */"); + + if (finish > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + /* Verify that the text was inserted after the end of "field". */ + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + ASSERT_STREQ ("/* before */\n" + "foo = bar.field/* inserted */;\n" + "/* after */\n", new_content); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.field;\n" + "+foo = bar.field/* inserted */;\n" + " /* after */\n", diff); +} + +/* Test applying an "insert" fixit, using insert_after at the end of + a line (contrast with test_applying_fixits_insert_after_failure + below). */ + +static void +test_applying_fixits_insert_after_at_line_end (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 2); + + /* Add a comment after the semicolon. */ + location_t loc = linemap_position_for_column (line_table, 16); + rich_location richloc (line_table, loc); + richloc.add_fixit_insert_after ("/* inserted */"); + + if (loc > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + ASSERT_STREQ ("/* before */\n" + "foo = bar.field;/* inserted */\n" + "/* after */\n", new_content); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.field;\n" + "+foo = bar.field;/* inserted */\n" + " /* after */\n", diff); +} + +/* Test of a failed attempt to apply an "insert" fixit, using insert_after, + due to the relevant linemap ending. Contrast with + test_applying_fixits_insert_after_at_line_end above. */ + +static void +test_applying_fixits_insert_after_failure (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 2); + + /* Add a comment after the semicolon. */ + location_t loc = linemap_position_for_column (line_table, 16); + rich_location richloc (line_table, loc); + + /* We want a failure of linemap_position_for_loc_and_offset. + We can do this by starting a new linemap at line 3, so that + there is no appropriate location value for the insertion point + within the linemap for line 2. */ + linemap_add (line_table, LC_ENTER, false, tmp.get_filename (), 3); + + /* The failure fails to happen at the transition point from + packed ranges to unpacked ranges (where there are some "spare" + location_t values). Skip the test there. */ + if (loc >= LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES) + return; + + /* Offsetting "loc" should now fail (by returning the input loc. */ + ASSERT_EQ (loc, linemap_position_for_loc_and_offset (line_table, loc, 1)); + + /* Hence attempting to use add_fixit_insert_after at the end of the line + should now fail. */ + richloc.add_fixit_insert_after ("/* inserted */"); + ASSERT_TRUE (richloc.seen_impossible_fixit_p ()); + + edit_context edit; + edit.add_fixits (&richloc); + ASSERT_FALSE (edit.valid_p ()); + ASSERT_EQ (NULL, edit.get_content (filename)); + ASSERT_EQ (NULL, edit.generate_diff (false)); +} + +/* Test applying a "replace" fixit that grows the affected line. */ + +static void +test_applying_fixits_growing_replace (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................0000000001111111. + .........................1234567890123456. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + /* Replace "field" with "m_field". */ + location_t start = linemap_position_for_column (line_table, 11); + location_t finish = linemap_position_for_column (line_table, 15); + location_t field = make_location (start, start, finish); + rich_location richloc (line_table, field); + richloc.add_fixit_replace ("m_field"); + + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + if (finish <= LINE_MAP_MAX_LOCATION_WITH_COLS) + { + ASSERT_STREQ ("/* before */\n" + "foo = bar.m_field;\n" + "/* after */\n", new_content); + + /* Verify location of ";" after the change. */ + ASSERT_EQ (18, edit.get_effective_column (filename, 2, 16)); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.field;\n" + "+foo = bar.m_field;\n" + " /* after */\n", diff); + } +} + +/* Test applying a "replace" fixit that shrinks the affected line. */ + +static void +test_applying_fixits_shrinking_replace (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................000000000111111111. + .........................123456789012345678. */ + const char *old_content = ("/* before */\n" + "foo = bar.m_field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + /* Replace "field" with "m_field". */ + location_t start = linemap_position_for_column (line_table, 11); + location_t finish = linemap_position_for_column (line_table, 17); + location_t m_field = make_location (start, start, finish); + rich_location richloc (line_table, m_field); + richloc.add_fixit_replace ("field"); + + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + if (finish <= LINE_MAP_MAX_LOCATION_WITH_COLS) + { + ASSERT_STREQ ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n", new_content); + + /* Verify location of ";" after the change. */ + ASSERT_EQ (16, edit.get_effective_column (filename, 2, 18)); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.m_field;\n" + "+foo = bar.field;\n" + " /* after */\n", diff); + } +} + +/* Test applying a "remove" fixit. */ + +static void +test_applying_fixits_remove (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................000000000111111111. + .........................123456789012345678. */ + const char *old_content = ("/* before */\n" + "foo = bar.m_field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + /* Remove ".m_field". */ + location_t start = linemap_position_for_column (line_table, 10); + location_t finish = linemap_position_for_column (line_table, 17); + rich_location richloc (line_table, start); + source_range range; + range.m_start = start; + range.m_finish = finish; + richloc.add_fixit_remove (range); + + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (filename); + if (finish <= LINE_MAP_MAX_LOCATION_WITH_COLS) + { + ASSERT_STREQ ("/* before */\n" + "foo = bar;\n" + "/* after */\n", new_content); + + /* Verify location of ";" after the change. */ + ASSERT_EQ (10, edit.get_effective_column (filename, 2, 18)); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.m_field;\n" + "+foo = bar;\n" + " /* after */\n", diff); + } +} + +/* Test applying multiple fixits to one line. */ + +static void +test_applying_fixits_multiple (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................00000000011111111. + .........................12345678901234567. */ + const char *old_content = ("/* before */\n" + "foo = bar.field;\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + location_t c7 = linemap_position_for_column (line_table, 7); + location_t c9 = linemap_position_for_column (line_table, 9); + location_t c11 = linemap_position_for_column (line_table, 11); + location_t c15 = linemap_position_for_column (line_table, 15); + location_t c17 = linemap_position_for_column (line_table, 17); + + if (c17 > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + /* Add a comment in front of "bar.field". */ + rich_location insert_a (line_table, c7); + insert_a.add_fixit_insert_before (c7, "/* alpha */"); + + /* Add a comment after "bar.field;". */ + rich_location insert_b (line_table, c17); + insert_b.add_fixit_insert_before (c17, "/* beta */"); + + /* Replace "bar" with "pub". */ + rich_location replace_a (line_table, c7); + replace_a.add_fixit_replace (source_range::from_locations (c7, c9), + "pub"); + + /* Replace "field" with "meadow". */ + rich_location replace_b (line_table, c7); + replace_b.add_fixit_replace (source_range::from_locations (c11, c15), + "meadow"); + + edit_context edit; + edit.add_fixits (&insert_a); + ASSERT_EQ (100, edit.get_effective_column (filename, 1, 100)); + ASSERT_EQ (1, edit.get_effective_column (filename, 2, 1)); + ASSERT_EQ (6, edit.get_effective_column (filename, 2, 6)); + ASSERT_EQ (18, edit.get_effective_column (filename, 2, 7)); + ASSERT_EQ (27, edit.get_effective_column (filename, 2, 16)); + ASSERT_EQ (100, edit.get_effective_column (filename, 3, 100)); + + edit.add_fixits (&insert_b); + edit.add_fixits (&replace_a); + edit.add_fixits (&replace_b); + + if (c17 <= LINE_MAP_MAX_LOCATION_WITH_COLS) + { + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + ASSERT_STREQ ("/* before */\n" + "foo = /* alpha */pub.meadow;/* beta */\n" + "/* after */\n", + new_content); + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,3 +1,3 @@\n" + " /* before */\n" + "-foo = bar.field;\n" + "+foo = /* alpha */pub.meadow;/* beta */\n" + " /* after */\n", diff); + } +} + +/* Subroutine of test_applying_fixits_multiple_lines. + Add the text "CHANGED: " to the front of the given line. */ + +static location_t +change_line (edit_context &edit, int line_num) +{ + const line_map_ordinary *ord_map + = LINEMAPS_LAST_ORDINARY_MAP (line_table); + const int column = 1; + location_t loc = + linemap_position_for_line_and_column (line_table, ord_map, + line_num, column); + + expanded_location exploc = expand_location (loc); + if (loc <= LINE_MAP_MAX_LOCATION_WITH_COLS) + { + ASSERT_EQ (line_num, exploc.line); + ASSERT_EQ (column, exploc.column); + } + + rich_location insert (line_table, loc); + insert.add_fixit_insert_before ("CHANGED: "); + edit.add_fixits (&insert); + return loc; +} + +/* Test of editing multiple lines within a long file, + to ensure that diffs are generated as expected. */ + +static void +test_applying_fixits_multiple_lines (const line_table_case &case_) +{ + /* Create a tempfile and write many lines of text to it. */ + named_temp_file tmp (".txt"); + const char *filename = tmp.get_filename (); + FILE *f = fopen (filename, "w"); + ASSERT_NE (f, NULL); + for (int i = 1; i <= 1000; i++) + fprintf (f, "line %i\n", i); + fclose (f); + + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 1); + linemap_position_for_column (line_table, 127); + + edit_context edit; + + /* A run of consecutive lines. */ + change_line (edit, 2); + change_line (edit, 3); + change_line (edit, 4); + + /* A run of nearby lines, within the contextual limit. */ + change_line (edit, 150); + change_line (edit, 151); + location_t last_loc = change_line (edit, 153); + + if (last_loc > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + /* Verify diff. */ + auto_free <char *> diff = edit.generate_diff (false); + ASSERT_STREQ ("@@ -1,7 +1,7 @@\n" + " line 1\n" + "-line 2\n" + "-line 3\n" + "-line 4\n" + "+CHANGED: line 2\n" + "+CHANGED: line 3\n" + "+CHANGED: line 4\n" + " line 5\n" + " line 6\n" + " line 7\n" + "@@ -147,10 +147,10 @@\n" + " line 147\n" + " line 148\n" + " line 149\n" + "-line 150\n" + "-line 151\n" + "+CHANGED: line 150\n" + "+CHANGED: line 151\n" + " line 152\n" + "-line 153\n" + "+CHANGED: line 153\n" + " line 154\n" + " line 155\n" + " line 156\n", diff); + + /* Ensure tmp stays alive until this point, so that the tempfile + persists until after the generate_diff call. */ + tmp.get_filename (); +} + +/* Test of converting an initializer for a named field from + the old GCC extension to C99 syntax. + Exercises a shrinking replacement followed by a growing + replacement on the same line. */ + +static void +test_applying_fixits_modernize_named_init (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + .........................00000000011111111. + .........................12345678901234567. */ + const char *old_content = ("/* before */\n" + "bar : 1,\n" + "/* after */\n"); + temp_source_file tmp (SELFTEST_LOCATION, ".c", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + location_t c1 = linemap_position_for_column (line_table, 1); + location_t c3 = linemap_position_for_column (line_table, 3); + location_t c8 = linemap_position_for_column (line_table, 8); + + if (c8 > LINE_MAP_MAX_LOCATION_WITH_COLS) + return; + + /* Replace "bar" with ".". */ + rich_location r1 (line_table, c8); + r1.add_fixit_replace (source_range::from_locations (c1, c3), + "."); + + /* Replace ":" with "bar =". */ + rich_location r2 (line_table, c8); + r2.add_fixit_replace (source_range::from_locations (c8, c8), + "bar ="); + + /* The order should not matter. Do r1 then r2. */ + { + edit_context edit; + edit.add_fixits (&r1); + + /* Verify state after first replacement. */ + { + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + /* We should now have: + ............00000000011. + ............12345678901. */ + ASSERT_STREQ ("/* before */\n" + ". : 1,\n" + "/* after */\n", + new_content); + /* Location of the "1". */ + ASSERT_EQ (6, edit.get_effective_column (filename, 2, 8)); + /* Location of the ",". */ + ASSERT_EQ (9, edit.get_effective_column (filename, 2, 11)); + } + + edit.add_fixits (&r2); + + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + /* Verify state after second replacement. + ............00000000011111111. + ............12345678901234567. */ + ASSERT_STREQ ("/* before */\n" + ". bar = 1,\n" + "/* after */\n", + new_content); + } + + /* Try again, doing r2 then r1; the new_content should be the same. */ + { + edit_context edit; + edit.add_fixits (&r2); + edit.add_fixits (&r1); + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + /*.............00000000011111111. + .............12345678901234567. */ + ASSERT_STREQ ("/* before */\n" + ". bar = 1,\n" + "/* after */\n", + new_content); + } +} + +/* Test of a fixit affecting a file that can't be read. */ + +static void +test_applying_fixits_unreadable_file () +{ + const char *filename = "this-does-not-exist.txt"; + line_table_test ltt (); + linemap_add (line_table, LC_ENTER, false, filename, 1); + + location_t loc = linemap_position_for_column (line_table, 1); + + rich_location insert (line_table, loc); + insert.add_fixit_insert_before ("change 1"); + insert.add_fixit_insert_before ("change 2"); + + edit_context edit; + /* Attempting to add the fixits affecting the unreadable file + should transition the edit from valid to invalid. */ + ASSERT_TRUE (edit.valid_p ()); + edit.add_fixits (&insert); + ASSERT_FALSE (edit.valid_p ()); + ASSERT_EQ (NULL, edit.get_content (filename)); + ASSERT_EQ (NULL, edit.generate_diff (false)); +} + +/* Verify that we gracefully handle an attempt to edit a line + that's beyond the end of the file. */ + +static void +test_applying_fixits_line_out_of_range () +{ + /* Create a tempfile and write some text to it. + ........................00000000011111111. + ........................12345678901234567. */ + const char *old_content = "One-liner file\n"; + temp_source_file tmp (SELFTEST_LOCATION, ".txt", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (); + linemap_add (line_table, LC_ENTER, false, filename, 2); + + /* Try to insert a string in line 2. */ + location_t loc = linemap_position_for_column (line_table, 1); + + rich_location insert (line_table, loc); + insert.add_fixit_insert_before ("change"); + + /* Verify that attempting the insertion puts an edit_context + into an invalid state. */ + edit_context edit; + ASSERT_TRUE (edit.valid_p ()); + edit.add_fixits (&insert); + ASSERT_FALSE (edit.valid_p ()); + ASSERT_EQ (NULL, edit.get_content (filename)); + ASSERT_EQ (NULL, edit.generate_diff (false)); +} + +/* Verify the boundary conditions of column values in fix-it + hints applied to edit_context instances. */ + +static void +test_applying_fixits_column_validation (const line_table_case &case_) +{ + /* Create a tempfile and write some text to it. + ........................00000000011111111. + ........................12345678901234567. */ + const char *old_content = "One-liner file\n"; + temp_source_file tmp (SELFTEST_LOCATION, ".txt", old_content); + const char *filename = tmp.get_filename (); + line_table_test ltt (case_); + linemap_add (line_table, LC_ENTER, false, filename, 1); + + location_t c11 = linemap_position_for_column (line_table, 11); + location_t c14 = linemap_position_for_column (line_table, 14); + location_t c15 = linemap_position_for_column (line_table, 15); + location_t c16 = linemap_position_for_column (line_table, 16); + + /* Verify limits of valid columns in insertion fixits. */ + + /* Verify inserting at the end of the line. */ + { + rich_location richloc (line_table, c11); + richloc.add_fixit_insert_before (c15, " change"); + + /* Col 15 is at the end of the line, so the insertion + should succeed. */ + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + if (c15 <= LINE_MAP_MAX_LOCATION_WITH_COLS) + ASSERT_STREQ ("One-liner file change\n", new_content); + else + ASSERT_EQ (NULL, new_content); + } + + /* Verify inserting beyond the end of the line. */ + { + rich_location richloc (line_table, c11); + richloc.add_fixit_insert_before (c16, " change"); + + /* Col 16 is beyond the end of the line, so the insertion + should fail gracefully. */ + edit_context edit; + ASSERT_TRUE (edit.valid_p ()); + edit.add_fixits (&richloc); + ASSERT_FALSE (edit.valid_p ()); + ASSERT_EQ (NULL, edit.get_content (filename)); + ASSERT_EQ (NULL, edit.generate_diff (false)); + } + + /* Verify limits of valid columns in replacement fixits. */ + + /* Verify replacing the end of the line. */ + { + rich_location richloc (line_table, c11); + source_range range = source_range::from_locations (c11, c14); + richloc.add_fixit_replace (range, "change"); + + /* Col 14 is at the end of the line, so the replacement + should succeed. */ + edit_context edit; + edit.add_fixits (&richloc); + auto_free <char *> new_content = edit.get_content (tmp.get_filename ()); + if (c14 <= LINE_MAP_MAX_LOCATION_WITH_COLS) + ASSERT_STREQ ("One-liner change\n", new_content); + else + ASSERT_EQ (NULL, new_content); + } + + /* Verify going beyond the end of the line. */ + { + rich_location richloc (line_table, c11); + source_range range = source_range::from_locations (c11, c15); + richloc.add_fixit_replace (range, "change"); + + /* Col 15 is after the end of the line, so the replacement + should fail; verify that the attempt fails gracefully. */ + edit_context edit; + ASSERT_TRUE (edit.valid_p ()); + edit.add_fixits (&richloc); + ASSERT_FALSE (edit.valid_p ()); + ASSERT_EQ (NULL, edit.get_content (filename)); + ASSERT_EQ (NULL, edit.generate_diff (false)); + } +} + +/* Run all of the selftests within this file. */ + +void +edit_context_c_tests () +{ + test_get_content (); + for_each_line_table_case (test_applying_fixits_insert_before); + for_each_line_table_case (test_applying_fixits_insert_after); + for_each_line_table_case (test_applying_fixits_insert_after_at_line_end); + for_each_line_table_case (test_applying_fixits_insert_after_failure); + for_each_line_table_case (test_applying_fixits_growing_replace); + for_each_line_table_case (test_applying_fixits_shrinking_replace); + for_each_line_table_case (test_applying_fixits_remove); + for_each_line_table_case (test_applying_fixits_multiple); + for_each_line_table_case (test_applying_fixits_multiple_lines); + for_each_line_table_case (test_applying_fixits_modernize_named_init); + test_applying_fixits_unreadable_file (); + test_applying_fixits_line_out_of_range (); + for_each_line_table_case (test_applying_fixits_column_validation); +} + +} // namespace selftest + +#endif /* CHECKING_P */ diff --git a/gcc/edit-context.h b/gcc/edit-context.h new file mode 100644 index 00000000000..842da561991 --- /dev/null +++ b/gcc/edit-context.h @@ -0,0 +1,68 @@ +/* Determining the results of applying fix-it hints. + Copyright (C) 2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#ifndef GCC_EDIT_CONTEXT_H +#define GCC_EDIT_CONTEXT_H + +#include "typed-splay-tree.h" + +class edit_context; +class edited_file; + +/* A set of changes to the source code. + + The changes are "atomic" - if any changes can't be applied, + none of them can be (tracked by the m_valid flag). + Similarly, attempts to add the changes from a rich_location flagged + as containing invalid changes mean that the whole of the edit_context + is flagged as invalid. + + A complication here is that fix-its are expressed relative to coordinates + in the files when they were parsed, before any changes have been made, and + so if there's more that one fix-it to be applied, we have to adjust + later fix-its to allow for the changes made by earlier ones. This + is done by the various "get_effective_column" methods. */ + +class edit_context +{ + public: + edit_context (); + + bool valid_p () const { return m_valid; } + + void add_fixits (rich_location *richloc); + + char *get_content (const char *filename); + + int get_effective_column (const char *filename, int line, int column); + + char *generate_diff (bool show_filenames); + void print_diff (pretty_printer *pp, bool show_filenames); + + private: + bool apply_insert (const fixit_insert *insert); + bool apply_replace (const fixit_replace *replace); + edited_file *get_file (const char *filename); + edited_file &get_or_insert_file (const char *filename); + + bool m_valid; + typed_splay_tree<const char *, edited_file *> m_files; +}; + +#endif /* GCC_EDIT_CONTEXT_H. */ diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index a7246089222..9e0bda2cc41 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1964,7 +1964,7 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp, get_object_alignment_1 (t, &obj_align, &obj_bitpos); obj_bitpos = (obj_bitpos - bitpos) & (obj_align - 1); if (obj_bitpos != 0) - obj_align = (obj_bitpos & -obj_bitpos); + obj_align = least_bit_hwi (obj_bitpos); attrs.align = MAX (attrs.align, obj_align); } @@ -2298,7 +2298,7 @@ adjust_address_1 (rtx memref, machine_mode mode, HOST_WIDE_INT offset, if zero. */ if (offset != 0) { - max_align = (offset & -offset) * BITS_PER_UNIT; + max_align = least_bit_hwi (offset) * BITS_PER_UNIT; attrs.align = MIN (attrs.align, max_align); } diff --git a/gcc/explow.c b/gcc/explow.c index b14291d8653..e935c307bcb 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -106,7 +106,15 @@ plus_constant (machine_mode mode, rtx x, HOST_WIDE_INT c, if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0))) { - tem = plus_constant (mode, get_pool_constant (XEXP (x, 0)), c); + rtx cst = get_pool_constant (XEXP (x, 0)); + + if (GET_CODE (cst) == CONST_VECTOR + && GET_MODE_INNER (GET_MODE (cst)) == mode) + { + cst = gen_lowpart (mode, cst); + gcc_assert (cst); + } + tem = plus_constant (mode, cst, c); tem = force_const_mem (GET_MODE (x), tem); /* Targets may disallow some constants in the constant pool, thus force_const_mem may return NULL_RTX. */ diff --git a/gcc/expmed.c b/gcc/expmed.c index 1cedf023c8e..2f789a2f075 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -127,10 +127,10 @@ init_expmed_one_conv (struct init_expmed_rtl *all, machine_mode to_mode, comparison purposes here, reduce the bit size by one in that case. */ if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT - && exact_log2 (to_size) != -1) + && pow2p_hwi (to_size)) to_size --; if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT - && exact_log2 (from_size) != -1) + && pow2p_hwi (from_size)) from_size --; /* Assume cost of zero-extend and sign-extend is the same. */ @@ -2572,7 +2572,6 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, entry_ptr = alg_hash_entry_ptr (hash_index); if (entry_ptr->t == t && entry_ptr->mode == mode - && entry_ptr->mode == mode && entry_ptr->speed == speed && entry_ptr->alg != alg_unknown) { @@ -2636,7 +2635,7 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, if ((t & 1) == 0) { do_alg_shift: - m = floor_log2 (t & -t); /* m = number of low zero bits */ + m = ctz_or_zero (t); /* m = number of low zero bits */ if (m < maxm) { q = t >> m; @@ -2873,9 +2872,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, { do_alg_add_t2_m: q = t - 1; - q = q & -q; - m = exact_log2 (q); - if (m >= 0 && m < maxm) + m = ctz_hwi (q); + if (q && m < maxm) { op_cost = shiftadd_cost (speed, mode, m); new_limit.cost = best_cost.cost - op_cost; @@ -2897,9 +2895,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, do_alg_sub_t2_m: q = t + 1; - q = q & -q; - m = exact_log2 (q); - if (m >= 0 && m < maxm) + m = ctz_hwi (q); + if (q && m < maxm) { op_cost = shiftsub0_cost (speed, mode, m); new_limit.cost = best_cost.cost - op_cost; @@ -4215,7 +4212,7 @@ expand_divmod (int rem_flag, enum tree_code code, machine_mode mode, initial right shift. */ if (mh != 0 && (d & 1) == 0) { - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); mh = choose_multiplier (d >> pre_shift, size, size - pre_shift, &ml, &post_shift, &dummy); @@ -4873,7 +4870,7 @@ expand_divmod (int rem_flag, enum tree_code code, machine_mode mode, int pre_shift; rtx t1; - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); ml = invert_mod2n (d >> pre_shift, size); t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0, pre_shift, NULL_RTX, unsignedp); diff --git a/gcc/expr.c b/gcc/expr.c index 391a8058654..73e000efca6 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -11065,7 +11065,7 @@ is_aligning_offset (const_tree offset, const_tree exp) || !tree_fits_uhwi_p (TREE_OPERAND (offset, 1)) || compare_tree_int (TREE_OPERAND (offset, 1), BIGGEST_ALIGNMENT / BITS_PER_UNIT) <= 0 - || exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0) + || !pow2p_hwi (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1)) return 0; /* Look at the first operand of BIT_AND_EXPR and strip any conversion. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index bf177b609e5..e040b2a279b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -837,15 +837,16 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code, var = negate_expr (var); } } + else if (TREE_CONSTANT (in)) + *conp = in; else if (TREE_CODE (in) == BIT_NOT_EXPR && code == PLUS_EXPR) { - /* -X - 1 is folded to ~X, undo that here. */ + /* -X - 1 is folded to ~X, undo that here. Do _not_ do this + when IN is constant. */ *minus_litp = build_one_cst (TREE_TYPE (in)); var = negate_expr (TREE_OPERAND (in, 0)); } - else if (TREE_CONSTANT (in)) - *conp = in; else var = in; @@ -10005,7 +10006,7 @@ fold_binary_loc (location_t loc, mode which allows further optimizations. */ int pop = wi::popcount (warg1); if (!(pop >= BITS_PER_UNIT - && exact_log2 (pop) != -1 + && pow2p_hwi (pop) && wi::mask (pop, false, warg1.get_precision ()) == warg1)) return fold_build2_loc (loc, code, type, op0, wide_int_to_tree (type, masked)); @@ -14251,7 +14252,7 @@ round_up_loc (location_t loc, tree value, unsigned int divisor) } /* If divisor is a power of two, simplify this to bit manipulation. */ - if (divisor == (divisor & -divisor)) + if (pow2_or_zerop (divisor)) { if (TREE_CODE (value) == INTEGER_CST) { @@ -14314,7 +14315,7 @@ round_down_loc (location_t loc, tree value, int divisor) } /* If divisor is a power of two, simplify this to bit manipulation. */ - if (divisor == (divisor & -divisor)) + if (pow2_or_zerop (divisor)) { tree t; diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9913c97de04..973f615b6b4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,89 @@ +2016-09-19 Fritz Reese <fritzoreese@gmail.com> + + PR fortran/77584 + * decl.c (match_record_decl, gfc_match_decl_type_spec): Fixes to + handling of structure/record from declaration-type-spec. + +2016_09_17 Louis Krupp <louis.krupp@zoho.com> + + PR fortran/68078 + * resolve.c (resolve_allocate_expr): Check that derived type + pointer, object or array has been successfully allocated before + initializing. + +2016-09-16 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77612 + * decl.c (char_len_param_value): Check parent namespace for + seen_implicit_none. + +2016-09-15 Louis Krupp <louis.krupp@zoho.com> + + PR fortran/69963 + * parse.c (reject_statement): Clear charlen pointers in implicit + character typespecs before those charlen structures are freed. + +2016-09-14 Bernd Edlinger <bernd.edlinger@hotmail.de> + + * simplify.c (gfc_simplify_repeat): Fix a misplaced closing ')'. + +2016-09-13 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77420 + * module.c (load_equiv): Revert revision 240063. + +2016-09-10 Paul Thomas <pault@gcc.gnu.org> + Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77532 + * interface.c (check_dtio_arg_TKR_intent): Return after error. + (check_dtio_interface1): Remove asserts, test for NULL and return + if found. + +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77420 + * module.c (load_equiv): If the current namespace has a list of + equivalence statements, initialize duplicate to false and then + look for duplicates; otherwise, initialize it to true. + +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77506 + * array.c (gfc_match_array_constructor): CHARACTER(len=*) cannot + appear in an array constructor. + +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77507 + * intrinsic.c (add_functions): Use correct keyword. + +2016-09-08 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/69514 + * array.c (gfc_match_array_constructor): If type-spec is present, + walk the array constructor performing possible conversions for + numeric types. + +2016-09-08 Jakub Jelinek <jakub@redhat.com> + + PR fortran/77500 + * trans-openmp.c (gfc_trans_omp_atomic): For atomic write or + swap, don't try to look through GFC_ISYM_CONVERSION. In other cases, + check that value.function.isym is non-NULL before dereferencing it. + +2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77391 + * resolve.c (deferred_requirements): New function to check F2008:C402. + (resolve_fl_variable,resolve_fl_parameter): Use it. + +2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77460 + * simplify.c (simplify_transformation_to_scalar): On error, result + may be NULL, simply return. + 2016-08-31 Jakub Jelinek <jakub@redhat.com> PR fortran/77352 @@ -83,13 +169,13 @@ * interface.c (compare_components, gfc_compare_derived_types): Use new functions. -2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> +2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77380 * dependency.c (gfc_check_dependency): Do not assert with -fcoarray=lib. -2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> +2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77372 simplify.c (simplify_ieee_selected_real_kind): Check for NULL pointers. @@ -259,7 +345,7 @@ * intrinsic.c (add_function, add_subroutine): New B/I/J/K intrinsic variants. -2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org> +2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/41922 * target-memory.c (expr_to_char): Pass in locus and use it in error @@ -383,7 +469,7 @@ a static one. 2016-07-15 Jerry DeLisle <jvdelisle@gcc.gnu.org> - Marco Restelli <mrestelli@gmail.com> + Marco Restelli <mrestelli@gmail.com> PR fortran/62125 * symbol.c (select_type_insert_tmp): Recursively call self to take care @@ -938,7 +1024,7 @@ * dump-parse-tree.c (show_code_node): Print association list of a block if present. Handle EXEC_END_BLOCK. -2016-02-28 Harald Anlauf <anlauf@gmx.de> +2016-02-28 Harald Anlauf <anlauf@gmx.de> Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/56007 @@ -1124,7 +1210,7 @@ * frontend-passes.c (matmul_lhs_realloc): Add forgotten break statement. -2016-01-24 Dominique d'Humieres <dominiq@lps.ens.fr> +2016-01-24 Dominique d'Humieres <dominiq@lps.ens.fr> PR fortran/68283 * primary.c (gfc_variable_attr): revert revision r221955, diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 03c8b17178c..14e20a36de5 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -1089,6 +1089,7 @@ match_array_cons_element (gfc_constructor_base *result) match gfc_match_array_constructor (gfc_expr **result) { + gfc_constructor *c; gfc_constructor_base head, new_cons; gfc_undo_change_set changed_syms; gfc_expr *expr; @@ -1141,6 +1142,15 @@ gfc_match_array_constructor (gfc_expr **result) gfc_restore_last_undo_checkpoint (); goto cleanup; } + + if (ts.type == BT_CHARACTER + && ts.u.cl && !ts.u.cl->length && !ts.u.cl->length_from_typespec) + { + gfc_error ("Type-spec at %L cannot contain an asterisk for a " + "type parameter", &where); + gfc_restore_last_undo_checkpoint (); + goto cleanup; + } } } else if (m == MATCH_ERROR) @@ -1194,8 +1204,6 @@ done: be converted. See PR fortran/67803. */ if (ts.type == BT_CHARACTER) { - gfc_constructor *c; - c = gfc_constructor_first (head); for (; c; c = gfc_constructor_next (c)) { @@ -1218,6 +1226,14 @@ done: } } } + + /* Walk the constructor and ensure type conversion for numeric types. */ + if (gfc_numeric_ts (&ts)) + { + c = gfc_constructor_first (head); + for (; c; c = gfc_constructor_next (c)) + gfc_convert_type (c->expr, &ts, 1); + } } else expr = gfc_get_array_expr (BT_UNKNOWN, 0, &where); diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index b5242394cef..d9fae5753d0 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -920,9 +920,10 @@ char_len_param_value (gfc_expr **expr, bool *deferred) t = gfc_reduce_init_expr (e); - if (!t && (e->ts.type == BT_UNKNOWN - && e->symtree->n.sym->attr.untyped == 1 - && e->symtree->n.sym->ns->seen_implicit_none == 1)) + if (!t && e->ts.type == BT_UNKNOWN + && e->symtree->n.sym->attr.untyped == 1 + && (e->symtree->n.sym->ns->seen_implicit_none == 1 + || e->symtree->n.sym->ns->parent->seen_implicit_none == 1)) { gfc_free_expr (e); goto syntax; @@ -2908,12 +2909,14 @@ done: /* Matches a RECORD declaration. */ static match -match_record_decl (const char *name) +match_record_decl (char *name) { locus old_loc; old_loc = gfc_current_locus; + match m; - if (gfc_match (" record") == MATCH_YES) + m = gfc_match (" record /"); + if (m == MATCH_YES) { if (!gfc_option.flag_dec_structure) { @@ -2922,17 +2925,20 @@ match_record_decl (const char *name) "-fdec-structure"); return MATCH_ERROR; } - if (gfc_match (" /%n/", name) != MATCH_YES) - { - gfc_error ("Structure name expected after RECORD at %C"); - gfc_current_locus = old_loc; - return MATCH_ERROR; - } - return MATCH_YES; + m = gfc_match (" %n/", name); + if (m == MATCH_YES) + return MATCH_YES; } - gfc_current_locus = old_loc; + gfc_current_locus = old_loc; + if (gfc_option.flag_dec_structure + && (gfc_match (" record% ") == MATCH_YES + || gfc_match (" record%t") == MATCH_YES)) + gfc_error ("Structure name expected after RECORD at %C"); + if (m == MATCH_NO) return MATCH_NO; + + return MATCH_ERROR; } /* Matches a declaration-type-spec (F03:R502). If successful, sets the ts @@ -3127,26 +3133,26 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag) else { /* Match nested STRUCTURE declarations; only valid within another - structure declaration. */ - m = gfc_match (" structure"); - if (m == MATCH_ERROR) - return MATCH_ERROR; - else if (m == MATCH_YES) - { - if ( gfc_current_state () != COMP_STRUCTURE - && gfc_current_state () != COMP_MAP) - return MATCH_ERROR; - - m = gfc_match_structure_decl (); - if (m == MATCH_YES) - { - /* gfc_new_block is updated by match_structure_decl. */ - ts->type = BT_DERIVED; - ts->u.derived = gfc_new_block; - return MATCH_YES; - } - return MATCH_ERROR; - } + structure declaration. */ + if (gfc_option.flag_dec_structure + && (gfc_current_state () == COMP_STRUCTURE + || gfc_current_state () == COMP_MAP)) + { + m = gfc_match (" structure"); + if (m == MATCH_YES) + { + m = gfc_match_structure_decl (); + if (m == MATCH_YES) + { + /* gfc_new_block is updated by match_structure_decl. */ + ts->type = BT_DERIVED; + ts->u.derived = gfc_new_block; + return MATCH_YES; + } + } + if (m == MATCH_ERROR) + return MATCH_ERROR; + } /* Match CLASS declarations. */ m = gfc_match (" class ( * )"); diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index c138f4d7c77..cd109791075 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -164,19 +164,34 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, gfc_expr *expr1, *expr2; gfc_code *co = *c; gfc_expr *n; + gfc_ref *ref; + bool found_substr; if (co->op != EXEC_ASSIGN) return 0; expr1 = co->expr1; if (expr1->ts.type != BT_CHARACTER || expr1->rank != 0 - || !expr1->symtree->n.sym->attr.allocatable) + || !gfc_expr_attr(expr1).allocatable + || !expr1->ts.deferred) return 0; expr2 = gfc_discard_nops (co->expr2); if (expr2->expr_type != EXPR_VARIABLE) return 0; + found_substr = false; + for (ref = expr2->ref; ref; ref = ref->next) + { + if (ref->type == REF_SUBSTRING) + { + found_substr = true; + break; + } + } + if (!found_substr) + return 0; + if (!gfc_check_dependency (expr1, expr2, true)) return 0; @@ -190,7 +205,7 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, current_code = c; inserted_block = NULL; changed_statement = NULL; - n = create_var (expr2, "trim"); + n = create_var (expr2, "realloc_string"); co->expr2 = n; return 0; } diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index fece3168dc7..45a9afe5685 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -4559,8 +4559,11 @@ check_dtio_arg_TKR_intent (gfc_symbol *fsym, bool typebound, bt type, int kind, int rank, sym_intent intent) { if (fsym->ts.type != type) - gfc_error ("DTIO dummy argument at %L must be of type %s", - &fsym->declared_at, gfc_basic_typename (type)); + { + gfc_error ("DTIO dummy argument at %L must be of type %s", + &fsym->declared_at, gfc_basic_typename (type)); + return; + } if (fsym->ts.type != BT_CLASS && fsym->ts.type != BT_DERIVED && fsym->ts.kind != kind) @@ -4606,20 +4609,23 @@ check_dtio_interface1 (gfc_symbol *derived, gfc_symtree *tb_io_st, { /* Typebound DTIO binding. */ tb_io_proc = tb_io_st->n.tb; - gcc_assert (tb_io_proc != NULL); + if (tb_io_proc == NULL) + return; + gcc_assert (tb_io_proc->is_generic); gcc_assert (tb_io_proc->u.generic->next == NULL); specific_proc = tb_io_proc->u.generic->specific; - gcc_assert (!specific_proc->is_generic); + if (specific_proc == NULL || specific_proc->is_generic) + return; dtio_sub = specific_proc->u.specific->n.sym; } else { generic_proc = tb_io_st->n.sym; - gcc_assert (generic_proc); - gcc_assert (generic_proc->generic); + if (generic_proc == NULL || generic_proc->generic == NULL) + return; for (intr = tb_io_st->n.sym->generic; intr; intr = intr->next) { diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index ca28eac8cf7..cad54b8100b 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -1239,7 +1239,8 @@ add_functions (void) *z = "z", *ln = "len", *ut = "unit", *han = "handler", *num = "number", *tm = "time", *nm = "name", *md = "mode", *vl = "values", *p1 = "path1", *p2 = "path2", *com = "command", - *ca = "coarray", *sub = "sub", *dist = "distance", *failed="failed"; + *ca = "coarray", *sub = "sub", *dist = "distance", *failed="failed", + *c_ptr_1 = "c_ptr_1", *c_ptr_2 = "c_ptr_2"; int di, dr, dd, dl, dc, dz, ii; @@ -2914,8 +2915,8 @@ add_functions (void) /* The following functions are part of ISO_C_BINDING. */ add_sym_2 ("c_associated", GFC_ISYM_C_ASSOCIATED, CLASS_INQUIRY, ACTUAL_NO, BT_LOGICAL, dl, GFC_STD_F2003, gfc_check_c_associated, NULL, NULL, - "C_PTR_1", BT_VOID, 0, REQUIRED, - "C_PTR_2", BT_VOID, 0, OPTIONAL); + c_ptr_1, BT_VOID, 0, REQUIRED, + c_ptr_2, BT_VOID, 0, OPTIONAL); make_from_module(); add_sym_1 ("c_loc", GFC_ISYM_C_LOC, CLASS_INQUIRY, ACTUAL_NO, diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 86f2c427368..d78a2c07eec 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -2399,6 +2399,29 @@ accept_statement (gfc_statement st) } +/* Clear default character types with charlen pointers that are about + to become invalid. */ + +static void +clear_default_charlen (gfc_namespace *ns, const gfc_charlen *cl, + const gfc_charlen *end) +{ + gfc_typespec *ts; + + for (ts = &ns->default_type[0]; ts < &ns->default_type[GFC_LETTERS]; ts++) + if (ts->type == BT_CHARACTER) + { + const gfc_charlen *cl2; + for (cl2 = cl; cl2 != end; cl2 = cl2->next) + if (ts->u.cl == cl2) + { + ts->u.cl = NULL; + ts->type = BT_UNKNOWN; + break; + } + } +} + /* Undo anything tentative that has been built for the current statement. */ @@ -2406,6 +2429,8 @@ static void reject_statement (void) { /* Revert to the previous charlen chain. */ + clear_default_charlen (gfc_current_ns, + gfc_current_ns->cl_list, gfc_current_ns->old_cl_list); gfc_free_charlen (gfc_current_ns->cl_list, gfc_current_ns->old_cl_list); gfc_current_ns->cl_list = gfc_current_ns->old_cl_list; diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 39c1330c455..037c2fe74e0 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -6928,6 +6928,35 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2) return true; } +static void +cond_init (gfc_code *code, gfc_expr *e, int pointer, gfc_expr *init_e) +{ + gfc_code *block; + gfc_expr *cond; + gfc_code *init_st; + gfc_expr *e_to_init = gfc_expr_to_initialize (e); + + cond = pointer + ? gfc_build_intrinsic_call (gfc_current_ns, GFC_ISYM_ASSOCIATED, + "associated", code->loc, 2, gfc_copy_expr (e_to_init), NULL) + : gfc_build_intrinsic_call (gfc_current_ns, GFC_ISYM_ALLOCATED, + "allocated", code->loc, 1, gfc_copy_expr (e_to_init)); + + init_st = gfc_get_code (EXEC_INIT_ASSIGN); + init_st->loc = code->loc; + init_st->expr1 = e_to_init; + init_st->expr2 = init_e; + + block = gfc_get_code (EXEC_IF); + block->loc = code->loc; + block->block = gfc_get_code (EXEC_IF); + block->block->loc = code->loc; + block->block->expr1 = cond; + block->block->next = init_st; + block->next = code->next; + + code->next = block; +} /* Resolve the expression in an ALLOCATE statement, doing the additional checks to see whether the expression is OK or not. The expression must @@ -7193,14 +7222,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec) ts = ts.u.derived->components->ts; if (gfc_bt_struct (ts.type) && (init_e = gfc_default_initializer (&ts))) - { - gfc_code *init_st = gfc_get_code (EXEC_INIT_ASSIGN); - init_st->loc = code->loc; - init_st->expr1 = gfc_expr_to_initialize (e); - init_st->expr2 = init_e; - init_st->next = code->next; - code->next = init_st; - } + cond_init (code, e, pointer, init_e); } else if (code->expr3->mold && code->expr3->ts.type == BT_DERIVED) { @@ -11488,6 +11510,27 @@ resolve_fl_variable_derived (gfc_symbol *sym, int no_init_flag) } +/* F2008, C402 (R401): A colon shall not be used as a type-param-value + except in the declaration of an entity or component that has the POINTER + or ALLOCATABLE attribute. */ + +static bool +deferred_requirements (gfc_symbol *sym) +{ + if (sym->ts.deferred + && !(sym->attr.pointer + || sym->attr.allocatable + || sym->attr.omp_udr_artificial_var)) + { + gfc_error ("Entity %qs at %L has a deferred type parameter and " + "requires either the POINTER or ALLOCATABLE attribute", + sym->name, &sym->declared_at); + return false; + } + return true; +} + + /* Resolve symbols with flavor variable. */ static bool @@ -11527,17 +11570,8 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) } /* Constraints on deferred type parameter. */ - if (sym->ts.deferred - && !(sym->attr.pointer - || sym->attr.allocatable - || sym->attr.omp_udr_artificial_var)) - { - gfc_error ("Entity %qs at %L has a deferred type parameter and " - "requires either the pointer or allocatable attribute", - sym->name, &sym->declared_at); - specification_expr = saved_specification_expr; - return false; - } + if (!deferred_requirements (sym)) + return false; if (sym->ts.type == BT_CHARACTER) { @@ -13682,6 +13716,10 @@ resolve_fl_parameter (gfc_symbol *sym) return false; } + /* Constraints on deferred type parameter. */ + if (!deferred_requirements (sym)) + return false; + /* Make sure a parameter that has been implicitly typed still matches the implicit type, since PARAMETER statements can precede IMPLICIT statements. */ diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 6e6566d9245..ad547a15e47 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -489,6 +489,8 @@ simplify_transformation_to_scalar (gfc_expr *result, gfc_expr *array, gfc_expr * } result = op (result, gfc_copy_expr (a)); + if (!result) + return result; } return result; @@ -5125,7 +5127,7 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n) if (len || (e->ts.u.cl->length && - mpz_sgn (e->ts.u.cl->length->value.integer)) != 0) + mpz_sgn (e->ts.u.cl->length->value.integer) != 0)) { const char *res = gfc_extract_int (n, &ncop); gcc_assert (res == NULL); diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 2d720c80a2a..4f1a1beb8cc 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -2803,7 +2803,11 @@ gfc_trans_omp_atomic (gfc_code *code) gfc_start_block (&block); expr2 = code->expr2; - if (expr2->expr_type == EXPR_FUNCTION + if (((atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_MASK) + != GFC_OMP_ATOMIC_WRITE) + && (atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_SWAP) == 0 + && expr2->expr_type == EXPR_FUNCTION + && expr2->value.function.isym && expr2->value.function.isym->id == GFC_ISYM_CONVERSION) expr2 = expr2->value.function.actual->expr; @@ -2842,6 +2846,7 @@ gfc_trans_omp_atomic (gfc_code *code) var = code->expr1->symtree->n.sym; expr2 = code->expr2; if (expr2->expr_type == EXPR_FUNCTION + && expr2->value.function.isym && expr2->value.function.isym->id == GFC_ISYM_CONVERSION) expr2 = expr2->value.function.actual->expr; } @@ -2899,6 +2904,7 @@ gfc_trans_omp_atomic (gfc_code *code) } e = expr2->value.op.op1; if (e->expr_type == EXPR_FUNCTION + && e->value.function.isym && e->value.function.isym->id == GFC_ISYM_CONVERSION) e = e->value.function.actual->expr; if (e->expr_type == EXPR_VARIABLE @@ -2912,6 +2918,7 @@ gfc_trans_omp_atomic (gfc_code *code) { e = expr2->value.op.op2; if (e->expr_type == EXPR_FUNCTION + && e->value.function.isym && e->value.function.isym->id == GFC_ISYM_CONVERSION) e = e->value.function.actual->expr; gcc_assert (e->expr_type == EXPR_VARIABLE @@ -3026,6 +3033,7 @@ gfc_trans_omp_atomic (gfc_code *code) code = code->next; expr2 = code->expr2; if (expr2->expr_type == EXPR_FUNCTION + && expr2->value.function.isym && expr2->value.function.isym->id == GFC_ISYM_CONVERSION) expr2 = expr2->value.function.actual->expr; diff --git a/gcc/function.c b/gcc/function.c index 53bad8736e9..94ed786dbc7 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -2716,7 +2716,7 @@ assign_parm_find_stack_rtl (tree parm, struct assign_parm_data_one *data) else if (CONST_INT_P (offset_rtx)) { align = INTVAL (offset_rtx) * BITS_PER_UNIT | boundary; - align = align & -align; + align = least_bit_hwi (align); } set_mem_align (stack_parm, align); diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 02e945af71d..6195a3b7ed0 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -4051,7 +4051,8 @@ parser::parse_expr () else if (force_capture) { unsigned num = capture_ids->elements (); - char id[8]; + /* Big enough for a 32-bit UINT_MAX plus prefix. */ + char id[13]; bool existed; sprintf (id, "__%u", num); capture_ids->get_or_insert (xstrdup (id), &existed); diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 1170d4f5b0c..92ca055f4eb 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -486,7 +486,8 @@ make_vector_modes (enum mode_class cl, unsigned int width, { struct mode_data *m; struct mode_data *v; - char buf[8]; + /* Big enough for a 32-bit UINT_MAX plus the text. */ + char buf[12]; unsigned int ncomponents; enum mode_class vclass = vector_class (cl); diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 7e3aad33000..4645eadfff4 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -1632,33 +1632,30 @@ duplicate_each_alternative (const char * str, int n_dup) static const char * alter_output_for_subst_insn (rtx insn, int alt) { - const char *insn_out, *sp ; - char *old_out, *new_out, *cp; - int i, j, new_len; + const char *insn_out, *old_out; + char *new_out, *cp; + size_t old_len, new_len; + int j; insn_out = XTMPL (insn, 3); - if (alt < 2 || *insn_out == '*' || *insn_out != '@') + if (alt < 2 || *insn_out != '@') return insn_out; - old_out = XNEWVEC (char, strlen (insn_out)), - sp = insn_out; + old_out = insn_out + 1; + while (ISSPACE (*old_out)) + old_out++; + old_len = strlen (old_out); - while (ISSPACE (*sp) || *sp == '@') - sp++; - - for (i = 0; *sp;) - old_out[i++] = *sp++; - - new_len = alt * (i + 1) + 1; + new_len = alt * (old_len + 1) + 1; new_out = XNEWVEC (char, new_len); new_out[0] = '@'; - for (j = 0, cp = new_out + 1; j < alt; j++, cp += i + 1) + for (j = 0, cp = new_out + 1; j < alt; j++, cp += old_len + 1) { - memcpy (cp, old_out, i); - *(cp+i) = (j == alt - 1) ? '\0' : '\n'; + memcpy (cp, old_out, old_len); + cp[old_len] = (j == alt - 1) ? '\0' : '\n'; } return new_out; diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index fbbe52004aa..2e0bd806987 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -699,7 +699,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, && !c_strlen (src, 2)) { unsigned ilen = tree_to_uhwi (len); - if (exact_log2 (ilen) != -1) + if (pow2p_hwi (ilen)) { tree type = lang_hooks.types.type_for_size (ilen * 8, 1); if (type diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 9e0b3d1d162..68115ee7896 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -1874,7 +1874,7 @@ replace_ref (tree *expr, slsr_cand_t c) requirement for the data type. See PR58041. */ get_object_alignment_1 (*expr, &align, &misalign); if (misalign != 0) - align = (misalign & -misalign); + align = least_bit_hwi (misalign); if (align < TYPE_ALIGN (acc_type)) acc_type = build_aligned_type (acc_type, align); diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 288b4727dd8..e378ed0d1cb 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -5346,7 +5346,8 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) flexibility, split it into separate input and output operands. */ tree input; - char buf[10]; + /* Buffer big enough to format a 32-bit UINT_MAX into. */ + char buf[11]; /* Turn the in/out constraint into an output constraint. */ char *p = xstrdup (constraint); @@ -5356,7 +5357,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) /* And add a matching input constraint. */ if (allows_reg) { - sprintf (buf, "%d", i); + sprintf (buf, "%u", i); /* If there are multiple alternatives in the constraint, handle each of them individually. Those that allow register @@ -7910,7 +7911,15 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) if (private_debug) code = OMP_CLAUSE_PRIVATE; else if (flags & GOVD_MAP) - code = OMP_CLAUSE_MAP; + { + code = OMP_CLAUSE_MAP; + if ((gimplify_omp_ctxp->region_type & ORT_ACC) == 0 + && TYPE_ATOMIC (strip_array_types (TREE_TYPE (decl)))) + { + error ("%<_Atomic%> %qD in implicit %<map%> clause", decl); + return 0; + } + } else if (flags & GOVD_SHARED) { if (is_global_var (decl)) @@ -7934,7 +7943,17 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) else if (flags & GOVD_PRIVATE) code = OMP_CLAUSE_PRIVATE; else if (flags & GOVD_FIRSTPRIVATE) - code = OMP_CLAUSE_FIRSTPRIVATE; + { + code = OMP_CLAUSE_FIRSTPRIVATE; + if ((gimplify_omp_ctxp->region_type & ORT_TARGET) + && (gimplify_omp_ctxp->region_type & ORT_ACC) == 0 + && TYPE_ATOMIC (strip_array_types (TREE_TYPE (decl)))) + { + error ("%<_Atomic%> %qD in implicit %<firstprivate%> clause on " + "%<target%> construct", decl); + return 0; + } + } else if (flags & GOVD_LASTPRIVATE) code = OMP_CLAUSE_LASTPRIVATE; else if (flags & GOVD_ALIGNED) @@ -8089,9 +8108,21 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p, switch (OMP_CLAUSE_CODE (c)) { + case OMP_CLAUSE_FIRSTPRIVATE: + if ((ctx->region_type & ORT_TARGET) + && (ctx->region_type & ORT_ACC) == 0 + && TYPE_ATOMIC (strip_array_types + (TREE_TYPE (OMP_CLAUSE_DECL (c))))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qD in %<firstprivate%> clause on " + "%<target%> construct", OMP_CLAUSE_DECL (c)); + remove = true; + break; + } + /* FALLTHRU */ case OMP_CLAUSE_PRIVATE: case OMP_CLAUSE_SHARED: - case OMP_CLAUSE_FIRSTPRIVATE: case OMP_CLAUSE_LINEAR: decl = OMP_CLAUSE_DECL (c); n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl); @@ -11959,6 +11990,11 @@ gimplify_va_arg_expr (tree *expr_p, gimple_seq *pre_p, if (have_va_type == error_mark_node) return GS_ERROR; have_va_type = targetm.canonical_va_list_type (have_va_type); + if (have_va_type == NULL_TREE + && TREE_CODE (valist) == ADDR_EXPR) + /* Handle 'Case 1: Not an array type' from c-common.c/build_va_arg. */ + have_va_type + = targetm.canonical_va_list_type (TREE_TYPE (TREE_TYPE (valist))); gcc_assert (have_va_type != NULL_TREE); /* Generate a diagnostic for requesting data of a type that cannot diff --git a/gcc/ginclude/stdint-gcc.h b/gcc/ginclude/stdint-gcc.h index 6d208afd0e7..610e118a97c 100644 --- a/gcc/ginclude/stdint-gcc.h +++ b/gcc/ginclude/stdint-gcc.h @@ -260,4 +260,105 @@ typedef __UINTMAX_TYPE__ uintmax_t; #endif /* (!defined __cplusplus || __cplusplus >= 201103L || defined __STDC_CONSTANT_MACROS) */ +#ifdef __STDC_WANT_IEC_60559_BFP_EXT__ +/* TS 18661-1 widths of integer types. */ + +#ifdef __INT8_TYPE__ +# undef INT8_WIDTH +# define INT8_WIDTH 8 +#endif +#ifdef __UINT8_TYPE__ +# undef UINT8_WIDTH +# define UINT8_WIDTH 8 +#endif +#ifdef __INT16_TYPE__ +# undef INT16_WIDTH +# define INT16_WIDTH 16 +#endif +#ifdef __UINT16_TYPE__ +# undef UINT16_WIDTH +# define UINT16_WIDTH 16 +#endif +#ifdef __INT32_TYPE__ +# undef INT32_WIDTH +# define INT32_WIDTH 32 +#endif +#ifdef __UINT32_TYPE__ +# undef UINT32_WIDTH +# define UINT32_WIDTH 32 +#endif +#ifdef __INT64_TYPE__ +# undef INT64_WIDTH +# define INT64_WIDTH 64 +#endif +#ifdef __UINT64_TYPE__ +# undef UINT64_WIDTH +# define UINT64_WIDTH 64 +#endif + +#undef INT_LEAST8_WIDTH +#define INT_LEAST8_WIDTH __INT_LEAST8_WIDTH__ +#undef UINT_LEAST8_WIDTH +#define UINT_LEAST8_WIDTH __INT_LEAST8_WIDTH__ +#undef INT_LEAST16_WIDTH +#define INT_LEAST16_WIDTH __INT_LEAST16_WIDTH__ +#undef UINT_LEAST16_WIDTH +#define UINT_LEAST16_WIDTH __INT_LEAST16_WIDTH__ +#undef INT_LEAST32_WIDTH +#define INT_LEAST32_WIDTH __INT_LEAST32_WIDTH__ +#undef UINT_LEAST32_WIDTH +#define UINT_LEAST32_WIDTH __INT_LEAST32_WIDTH__ +#undef INT_LEAST64_WIDTH +#define INT_LEAST64_WIDTH __INT_LEAST64_WIDTH__ +#undef UINT_LEAST64_WIDTH +#define UINT_LEAST64_WIDTH __INT_LEAST64_WIDTH__ + +#undef INT_FAST8_WIDTH +#define INT_FAST8_WIDTH __INT_FAST8_WIDTH__ +#undef UINT_FAST8_WIDTH +#define UINT_FAST8_WIDTH __INT_FAST8_WIDTH__ +#undef INT_FAST16_WIDTH +#define INT_FAST16_WIDTH __INT_FAST16_WIDTH__ +#undef UINT_FAST16_WIDTH +#define UINT_FAST16_WIDTH __INT_FAST16_WIDTH__ +#undef INT_FAST32_WIDTH +#define INT_FAST32_WIDTH __INT_FAST32_WIDTH__ +#undef UINT_FAST32_WIDTH +#define UINT_FAST32_WIDTH __INT_FAST32_WIDTH__ +#undef INT_FAST64_WIDTH +#define INT_FAST64_WIDTH __INT_FAST64_WIDTH__ +#undef UINT_FAST64_WIDTH +#define UINT_FAST64_WIDTH __INT_FAST64_WIDTH__ + +#ifdef __INTPTR_TYPE__ +# undef INTPTR_WIDTH +# define INTPTR_WIDTH __INTPTR_WIDTH__ +#endif +#ifdef __UINTPTR_TYPE__ +# undef UINTPTR_WIDTH +# define UINTPTR_WIDTH __INTPTR_WIDTH__ +#endif + +#undef INTMAX_WIDTH +#define INTMAX_WIDTH __INTMAX_WIDTH__ +#undef UINTMAX_WIDTH +#define UINTMAX_WIDTH __INTMAX_WIDTH__ + +#undef PTRDIFF_WIDTH +#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__ + +#undef SIG_ATOMIC_WIDTH +#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__ + +#undef SIZE_WIDTH +#define SIZE_WIDTH __SIZE_WIDTH__ + +#undef WCHAR_WIDTH +#define WCHAR_WIDTH __WCHAR_WIDTH__ + +#undef WINT_WIDTH +#define WINT_WIDTH __WINT_WIDTH__ + +#endif + #endif /* _GCC_STDINT_H */ diff --git a/gcc/glimits.h b/gcc/glimits.h index 9acd467017d..3967bfe5a0e 100644 --- a/gcc/glimits.h +++ b/gcc/glimits.h @@ -123,4 +123,30 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL) #endif +#ifdef __STDC_WANT_IEC_60559_BFP_EXT__ +/* TS 18661-1 widths of integer types. */ +# undef CHAR_WIDTH +# define CHAR_WIDTH __SCHAR_WIDTH__ +# undef SCHAR_WIDTH +# define SCHAR_WIDTH __SCHAR_WIDTH__ +# undef UCHAR_WIDTH +# define UCHAR_WIDTH __SCHAR_WIDTH__ +# undef SHRT_WIDTH +# define SHRT_WIDTH __SHRT_WIDTH__ +# undef USHRT_WIDTH +# define USHRT_WIDTH __SHRT_WIDTH__ +# undef INT_WIDTH +# define INT_WIDTH __INT_WIDTH__ +# undef UINT_WIDTH +# define UINT_WIDTH __INT_WIDTH__ +# undef LONG_WIDTH +# define LONG_WIDTH __LONG_WIDTH__ +# undef ULONG_WIDTH +# define ULONG_WIDTH __LONG_WIDTH__ +# undef LLONG_WIDTH +# define LLONG_WIDTH __LONG_LONG_WIDTH__ +# undef ULLONG_WIDTH +# define ULLONG_WIDTH __LONG_LONG_WIDTH__ +#endif + #endif /* _LIMITS_H___ */ diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 2052a977029..9351ddafe16 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,19 @@ +2016-09-11 Ian Lance Taylor <iant@golang.org> + + * go-gcc.cc (Gcc_backend::Gcc_backend): Add builtin versions of + ctz, ctzll, bswap32, bswap64. + +2016-09-10 Ian Lance Taylor <iant@golang.org> + + * go-backend.c (go_trampoline_info): Remove. + * go-c.h (go_trampoline_info): Don't declare. + +2016-09-09 Than McIntosh <thanm@google.com> + + * go-sha1.cc: New file. + * Make-lang.in (GO_OBJS): Add go/go-sha1.o. + (CFLAGS-go/go-sha1.o): New variable. + 2016-08-29 Ian Lance Taylor <iant@google.com> * lang.opt (fgo-c-header, fgo-compiling-runtime): New options. diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in index d5b2a776776..e7011f9d242 100644 --- a/gcc/go/Make-lang.in +++ b/gcc/go/Make-lang.in @@ -59,6 +59,7 @@ GO_OBJS = \ go/go-lang.o \ go/go-linemap.o \ go/go-optimize.o \ + go/go-sha1.o \ go/go.o \ go/gogo.o \ go/import.o \ @@ -225,6 +226,7 @@ GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend CFLAGS-go/go-gcc.o += $(GOINCLUDES) CFLAGS-go/go-linemap.o += $(GOINCLUDES) +CFLAGS-go/go-sha1.o += $(GOINCLUDES) go/%.o: go/gofrontend/%.cc $(COMPILE) $(GOINCLUDES) $< diff --git a/gcc/go/go-backend.c b/gcc/go/go-backend.c index 1c62495c38d..99609f0fc16 100644 --- a/gcc/go/go-backend.c +++ b/gcc/go/go-backend.c @@ -80,15 +80,6 @@ go_field_alignment (tree t) return v / BITS_PER_UNIT; } -/* Return the size and alignment of a trampoline. */ - -void -go_trampoline_info (unsigned int *size, unsigned int *alignment) -{ - *size = TRAMPOLINE_SIZE; - *alignment = TRAMPOLINE_ALIGNMENT; -} - /* This is called by the Go frontend proper if the unsafe package was imported. When that happens we can not do type-based alias analysis. */ diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h index a96812d3cb5..194c1a9ca64 100644 --- a/gcc/go/go-c.h +++ b/gcc/go/go-c.h @@ -63,8 +63,6 @@ extern const char *go_localize_identifier (const char*); extern unsigned int go_field_alignment (tree); -extern void go_trampoline_info (unsigned int *size, unsigned int *alignment); - extern void go_imported_unsafe (void); extern void go_write_export_data (const char *, unsigned int); diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index 13407ea5d37..a332831b310 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -692,6 +692,28 @@ Gcc_backend::Gcc_backend() NULL_TREE), false, false); + // Used by runtime/internal/sys. + this->define_builtin(BUILT_IN_CTZ, "__builtin_ctz", "ctz", + build_function_type_list(integer_type_node, + unsigned_type_node, + NULL_TREE), + true, false); + this->define_builtin(BUILT_IN_CTZLL, "__builtin_ctzll", "ctzll", + build_function_type_list(integer_type_node, + long_long_unsigned_type_node, + NULL_TREE), + true, false); + this->define_builtin(BUILT_IN_BSWAP32, "__builtin_bswap32", "bswap32", + build_function_type_list(uint32_type_node, + uint32_type_node, + NULL_TREE), + true, false); + this->define_builtin(BUILT_IN_BSWAP64, "__builtin_bswap64", "bswap64", + build_function_type_list(uint64_type_node, + uint64_type_node, + NULL_TREE), + true, false); + // We provide some functions for the math library. tree math_function_type = build_function_type_list(double_type_node, double_type_node, diff --git a/gcc/go/go-sha1.cc b/gcc/go/go-sha1.cc new file mode 100644 index 00000000000..874b9635a76 --- /dev/null +++ b/gcc/go/go-sha1.cc @@ -0,0 +1,71 @@ +/* go-sha1.cc -- Go frontend interface to gcc backend. + Copyright (C) 2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "go-sha1.h" +#include "sha1.h" + +class Gcc_sha1_helper : public Go_sha1_helper +{ + public: + + Gcc_sha1_helper() : ctx_(new sha1_ctx) { sha1_init_ctx(this->ctx_); } + + ~Gcc_sha1_helper(); + + // Incorporate 'len' bytes from 'buffer' into checksum. + void + process_bytes(const void* buffer, size_t len); + + // Finalize checksum and return in the form of a string. + std::string + finish(); + + private: + sha1_ctx *ctx_; +}; + +Gcc_sha1_helper::~Gcc_sha1_helper() +{ + delete ctx_; +} + +void +Gcc_sha1_helper::process_bytes(const void* buffer, size_t len) +{ + sha1_process_bytes(buffer, len, this->ctx_); +} + +std::string +Gcc_sha1_helper::finish() +{ + // Use a union to provide the required alignment. + union + { + char checksum[checksum_len]; + long align; + } u; + sha1_finish_ctx(this->ctx_, u.checksum); + return std::string(u.checksum, checksum_len); +} + +Go_sha1_helper* +go_create_sha1_helper() +{ + return new Gcc_sha1_helper(); +} diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 71a9f5bcd5e..987aef7a6ef 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -c8cf90f2daf62428ca6aa0b5674572cd99f25fe3 +b34c93bf00ec4f2ad043ec89ff96989e0d1b26aa The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc index e9040efeda9..bec4c7ff978 100644 --- a/gcc/go/gofrontend/export.cc +++ b/gcc/go/gofrontend/export.cc @@ -6,8 +6,7 @@ #include "go-system.h" -#include "sha1.h" - +#include "go-sha1.h" #include "go-c.h" #include "gogo.h" @@ -40,6 +39,7 @@ const int Export::checksum_len; Export::Export(Stream* stream) : stream_(stream), type_refs_(), type_index_(1), packages_() { + go_assert(Export::checksum_len == Go_sha1_helper::checksum_len); } // A functor to sort Named_object pointers by name. @@ -686,9 +686,8 @@ Export::register_builtin_type(Gogo* gogo, const char* name, Builtin_code code) Export::Stream::Stream() { - this->checksum_ = new sha1_ctx; - memset(this->checksum_, 0, sizeof(sha1_ctx)); - sha1_init_ctx(this->checksum_); + this->sha1_helper_ = go_create_sha1_helper(); + go_assert(this->sha1_helper_ != NULL); } Export::Stream::~Stream() @@ -701,7 +700,7 @@ Export::Stream::~Stream() void Export::Stream::write_and_sum_bytes(const char* bytes, size_t length) { - sha1_process_bytes(bytes, length, this->checksum_); + this->sha1_helper_->process_bytes(bytes, length); this->do_write(bytes, length); } @@ -710,14 +709,9 @@ Export::Stream::write_and_sum_bytes(const char* bytes, size_t length) std::string Export::Stream::checksum() { - // Use a union to provide the required alignment. - union - { - char checksum[Export::checksum_len]; - long align; - } u; - sha1_finish_ctx(this->checksum_, u.checksum); - return std::string(u.checksum, Export::checksum_len); + std::string rval = this->sha1_helper_->finish(); + delete this->sha1_helper_; + return rval; } // Write the checksum string to the export data. diff --git a/gcc/go/gofrontend/export.h b/gcc/go/gofrontend/export.h index ee61d2752de..fec73fbd75e 100644 --- a/gcc/go/gofrontend/export.h +++ b/gcc/go/gofrontend/export.h @@ -9,7 +9,7 @@ #include "string-dump.h" -struct sha1_ctx; +class Go_sha1_helper; class Gogo; class Import_init; class Bindings; @@ -109,8 +109,8 @@ class Export : public String_dump void write_and_sum_bytes(const char*, size_t); - // The checksum. - sha1_ctx* checksum_; + // The checksum helper. + Go_sha1_helper* sha1_helper_; }; Export(Stream*); diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 803611d5442..aabb35391ac 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -9050,7 +9050,7 @@ Call_expression::do_flatten(Gogo* gogo, Named_object*, Location loc = this->location(); int i = 0; - char buf[10]; + char buf[20]; for (Typed_identifier_list::const_iterator p = results->begin(); p != results->end(); ++p, ++i) diff --git a/gcc/go/gofrontend/go-sha1.h b/gcc/go/gofrontend/go-sha1.h new file mode 100644 index 00000000000..22db5a2b4b9 --- /dev/null +++ b/gcc/go/gofrontend/go-sha1.h @@ -0,0 +1,33 @@ +// go-sha1.h -- GCC specific sha1 checksum utilities. -*- C++ -*- + +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#ifndef GO_SHA1_H +#define GO_SHA1_H + +#include "go-system.h" + +// +// Interface class for computation of SHA1 checksums. Front end requests +// one of these objects from the back end to use for computing +// checksums (each back end tends to have a different SHA1 implementation). +// Back ends are expected to create a new class that derives from this +// one containing an implementation. +// + +class Go_sha1_helper +{ + public: + virtual ~Go_sha1_helper() { } + virtual void process_bytes(const void* buffer, size_t len) = 0; + virtual std::string finish() = 0; + static const int checksum_len = 20; +}; + +// Call to create and return a new sha1 helper (this routine defined +// by the backend). Caller is responsible for deletion. +extern Go_sha1_helper* go_create_sha1_helper(); + +#endif // !defined(GO_SHA1_H) diff --git a/gcc/go/gofrontend/import.cc b/gcc/go/gofrontend/import.cc index 54fd4c95719..d150020a4a3 100644 --- a/gcc/go/gofrontend/import.cc +++ b/gcc/go/gofrontend/import.cc @@ -7,7 +7,6 @@ #include "go-system.h" #include "filenames.h" -#include "simple-object.h" #include "go-c.h" #include "gogo.h" @@ -233,7 +232,7 @@ Import::find_export_data(const std::string& filename, int fd, Location location) return NULL; } -// Look for export data in a simple_object. +// Look for export data in an object file. Import::Stream* Import::find_object_export_data(const std::string& filename, diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc index 692aa502fec..05705f581c9 100644 --- a/gcc/go/gofrontend/lex.cc +++ b/gcc/go/gofrontend/lex.cc @@ -985,6 +985,52 @@ Lex::is_hex_digit(char c) || (c >= 'a' && c <= 'f')); } +// not a hex value +#define NHV 100 + +// for use by Lex::hex_val +static const unsigned char hex_value_lookup_table[256] = +{ + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // NUL SOH STX ETX EOT ENQ ACK BEL + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // BS HT LF VT FF CR SO SI + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // DLE DC1 DC2 DC3 DC4 NAK SYN ETB + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // CAN EM SUB ESC FS GS RS US + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // SP ! " # $ % & ' + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // ( ) * + , - . / + 0, 1, 2, 3, 4, 5, 6, 7, // 0 1 2 3 4 5 6 7 + 8, 9, NHV, NHV, NHV, NHV, NHV, NHV, // 8 9 : ; < = > ? + NHV, 10, 11, 12, 13, 14, 15, NHV, // @ A B C D E F G + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // H I J K L M N O + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // P Q R S T U V W + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // X Y Z [ \ ] ^ _ + NHV, 10, 11, 12, 13, 14, 15, NHV, // ` a b c d e f g + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // h i j k l m n o + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // p q r s t u v w + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // x y z { | } ~ + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV, // + NHV, NHV, NHV, NHV, NHV, NHV, NHV, NHV // +}; + +unsigned +Lex::hex_val(char c) +{ + return hex_value_lookup_table[static_cast<unsigned char>(c)]; +} + // Return whether an exponent could start at P. bool @@ -1212,7 +1258,7 @@ Lex::advance_one_char(const char* p, bool is_single_quote, unsigned int* value, *is_character = false; if (Lex::is_hex_digit(p[1]) && Lex::is_hex_digit(p[2])) { - *value = (hex_value(p[1]) << 4) + hex_value(p[2]); + *value = (Lex::hex_val(p[1]) << 4) + Lex::hex_val(p[2]); return p + 3; } error_at(this->location(), "invalid hex character"); @@ -1259,10 +1305,10 @@ Lex::advance_one_char(const char* p, bool is_single_quote, unsigned int* value, if (Lex::is_hex_digit(p[1]) && Lex::is_hex_digit(p[2]) && Lex::is_hex_digit(p[3]) && Lex::is_hex_digit(p[4])) { - *value = ((hex_value(p[1]) << 12) - + (hex_value(p[2]) << 8) - + (hex_value(p[3]) << 4) - + hex_value(p[4])); + *value = ((Lex::hex_val(p[1]) << 12) + + (Lex::hex_val(p[2]) << 8) + + (Lex::hex_val(p[3]) << 4) + + Lex::hex_val(p[4])); if (*value >= 0xd800 && *value < 0xe000) { error_at(this->location(), @@ -1282,14 +1328,14 @@ Lex::advance_one_char(const char* p, bool is_single_quote, unsigned int* value, && Lex::is_hex_digit(p[5]) && Lex::is_hex_digit(p[6]) && Lex::is_hex_digit(p[7]) && Lex::is_hex_digit(p[8])) { - *value = ((hex_value(p[1]) << 28) - + (hex_value(p[2]) << 24) - + (hex_value(p[3]) << 20) - + (hex_value(p[4]) << 16) - + (hex_value(p[5]) << 12) - + (hex_value(p[6]) << 8) - + (hex_value(p[7]) << 4) - + hex_value(p[8])); + *value = ((Lex::hex_val(p[1]) << 28) + + (Lex::hex_val(p[2]) << 24) + + (Lex::hex_val(p[3]) << 20) + + (Lex::hex_val(p[4]) << 16) + + (Lex::hex_val(p[5]) << 12) + + (Lex::hex_val(p[6]) << 8) + + (Lex::hex_val(p[7]) << 4) + + Lex::hex_val(p[8])); if (*value > 0x10ffff || (*value >= 0xd800 && *value < 0xe000)) { @@ -2721,10 +2767,10 @@ Lex::is_exported_name(const std::string& name) for (size_t i = 2; i < len && p[i] != '$'; ++i) { c = p[i]; - if (!hex_p(c)) + if (!Lex::is_hex_digit(c)) return false; ci <<= 4; - ci |= hex_value(c); + ci |= Lex::hex_val(c); } return Lex::is_unicode_uppercase(ci); } diff --git a/gcc/go/gofrontend/lex.h b/gcc/go/gofrontend/lex.h index 5c4afb611b0..0a7a842ba88 100644 --- a/gcc/go/gofrontend/lex.h +++ b/gcc/go/gofrontend/lex.h @@ -454,6 +454,9 @@ class Lex octal_value(char c) { return c - '0'; } + static unsigned + hex_val(char c); + Token make_invalid_token() { return Token::make_invalid_token(this->location()); } diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index 314bb5b231c..4d1b2767441 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -2207,7 +2207,7 @@ gen_hsa_addr_with_align (tree ref, hsa_bb *hbb, BrigAlignment8_t *output_align) unsigned align = hsa_byte_alignment (addr->m_symbol->m_align); unsigned misalign = addr->m_imm_offset & (align - 1); if (misalign) - align = (misalign & -misalign); + align = least_bit_hwi (misalign); *output_align = hsa_alignment_encoding (BITS_PER_UNIT * align); } return addr; @@ -2434,7 +2434,7 @@ hsa_bitmemref_alignment (tree ref) BrigAlignment8_t base = hsa_object_alignment (ref); if (byte_bits == 0) return base; - return MIN (base, hsa_alignment_encoding (byte_bits & -byte_bits)); + return MIN (base, hsa_alignment_encoding (least_bit_hwi (byte_bits))); } /* Generate HSAIL instructions loading something into register DEST. RHS is diff --git a/gcc/hwint.c b/gcc/hwint.c index b936c52e5c1..53730285dd7 100644 --- a/gcc/hwint.c +++ b/gcc/hwint.c @@ -74,7 +74,7 @@ ceil_log2 (unsigned HOST_WIDE_INT x) int exact_log2 (unsigned HOST_WIDE_INT x) { - if (x != (x & -x)) + if (!pow2p_hwi (x)) return -1; return floor_log2 (x); } @@ -85,7 +85,7 @@ exact_log2 (unsigned HOST_WIDE_INT x) int ctz_hwi (unsigned HOST_WIDE_INT x) { - return x ? floor_log2 (x & -x) : HOST_BITS_PER_WIDE_INT; + return x ? floor_log2 (least_bit_hwi (x)) : HOST_BITS_PER_WIDE_INT; } /* Similarly for most significant bits. */ @@ -102,7 +102,7 @@ clz_hwi (unsigned HOST_WIDE_INT x) int ffs_hwi (unsigned HOST_WIDE_INT x) { - return 1 + floor_log2 (x & -x); + return 1 + floor_log2 (least_bit_hwi (x)); } /* Return the number of set bits in X. */ diff --git a/gcc/hwint.h b/gcc/hwint.h index 6b4d53737a2..ea87b2158b1 100644 --- a/gcc/hwint.h +++ b/gcc/hwint.h @@ -134,6 +134,31 @@ typedef HOST_WIDE_INT __gcc_host_wide_int__; #endif /* Inline functions operating on HOST_WIDE_INT. */ + +/* Return X with all but the lowest bit masked off. */ + +static inline unsigned HOST_WIDE_INT +least_bit_hwi (unsigned HOST_WIDE_INT x) +{ + return (x & -x); +} + +/* True if X is zero or a power of two. */ + +static inline bool +pow2_or_zerop (unsigned HOST_WIDE_INT x) +{ + return least_bit_hwi (x) == x; +} + +/* True if X is a power of two. */ + +static inline bool +pow2p_hwi (unsigned HOST_WIDE_INT x) +{ + return x && pow2_or_zerop (x); +} + #if GCC_VERSION < 3004 extern int clz_hwi (unsigned HOST_WIDE_INT x); @@ -222,7 +247,7 @@ ceil_log2 (unsigned HOST_WIDE_INT x) static inline int exact_log2 (unsigned HOST_WIDE_INT x) { - return x == (x & -x) && x ? ctz_hwi (x) : -1; + return pow2p_hwi (x) ? ctz_hwi (x) : -1; } #endif /* GCC_VERSION >= 3004 */ @@ -238,6 +263,14 @@ extern HOST_WIDE_INT pos_mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT); extern HOST_WIDE_INT mul_hwi (HOST_WIDE_INT, HOST_WIDE_INT); extern HOST_WIDE_INT least_common_multiple (HOST_WIDE_INT, HOST_WIDE_INT); +/* Like ctz_hwi, except 0 when x == 0. */ + +static inline int +ctz_or_zero (unsigned HOST_WIDE_INT x) +{ + return ffs_hwi (x) - 1; +} + /* Sign extend SRC starting from PREC. */ static inline HOST_WIDE_INT diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index ecdfc2e2bf3..24542f00848 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -1417,11 +1417,11 @@ noce_try_store_flag_constants (struct noce_if_info *if_info) gcc_unreachable (); } /* Is this (cond) ? 2^n : 0? */ - else if (ifalse == 0 && exact_log2 (itrue) >= 0 + else if (ifalse == 0 && pow2p_hwi (itrue) && STORE_FLAG_VALUE == 1) normalize = 1; /* Is this (cond) ? 0 : 2^n? */ - else if (itrue == 0 && exact_log2 (ifalse) >= 0 && can_reverse + else if (itrue == 0 && pow2p_hwi (ifalse) && can_reverse && STORE_FLAG_VALUE == 1) { normalize = 1; diff --git a/gcc/input.c b/gcc/input.c index 2ff7cb8e943..55bff4891ef 100644 --- a/gcc/input.c +++ b/gcc/input.c @@ -95,6 +95,11 @@ struct fcache before the line map has seen the end of the file. */ size_t total_lines; + /* Could this file be missing a trailing newline on its final line? + Initially true (to cope with empty files), set to true/false + as each line is read. */ + bool missing_trailing_newline; + /* This is a record of the beginning and end of the lines we've seen while reading the file. This is useful to avoid walking the data from the beginning when we are asked to read a line that is @@ -280,6 +285,7 @@ diagnostics_file_cache_forcibly_evict_file (const char *file_path) r->line_record.truncate (0); r->use_count = 0; r->total_lines = 0; + r->missing_trailing_newline = true; } /* Return the file cache that has been less used, recently, or the @@ -348,6 +354,7 @@ add_file_to_cache_tab (const char *file_path) add_file_to_cache_tab is called. */ r->use_count = ++highest_use_count; r->total_lines = total_lines_num (file_path); + r->missing_trailing_newline = true; return r; } @@ -372,7 +379,7 @@ lookup_or_add_file_to_cache_tab (const char *file_path) fcache::fcache () : use_count (0), file_path (NULL), fp (NULL), data (0), size (0), nb_read (0), line_start_idx (0), line_num (0), - total_lines (0) + total_lines (0), missing_trailing_newline (true) { line_record.create (0); } @@ -507,16 +514,24 @@ get_next_line (fcache *c, char **line, ssize_t *line_len) } } if (line_end == NULL) - /* We've loadded all the file into the cache and still no - '\n'. Let's say the line ends up at one byte passed the - end of the file. This is to stay consistent with the case - of when the line ends up with a '\n' and line_end points to - that terminal '\n'. That consistency is useful below in - the len calculation. */ - line_end = c->data + c->nb_read ; + { + /* We've loadded all the file into the cache and still no + '\n'. Let's say the line ends up at one byte passed the + end of the file. This is to stay consistent with the case + of when the line ends up with a '\n' and line_end points to + that terminal '\n'. That consistency is useful below in + the len calculation. */ + line_end = c->data + c->nb_read ; + c->missing_trailing_newline = true; + } + else + c->missing_trailing_newline = false; } else - next_line_start = line_end + 1; + { + next_line_start = line_end + 1; + c->missing_trailing_newline = false; + } if (ferror (c->fp)) return -1; @@ -751,6 +766,20 @@ location_get_source_line (const char *file_path, int line, return read ? buffer : NULL; } +/* Determine if FILE_PATH missing a trailing newline on its final line. + Only valid to call once all of the file has been loaded, by + requesting a line number beyond the end of the file. */ + +bool +location_missing_trailing_newline (const char *file_path) +{ + fcache *c = lookup_or_add_file_to_cache_tab (file_path); + if (c == NULL) + return false; + + return c->missing_trailing_newline; +} + /* Test if the location originates from the spelling location of a builtin-tokens. That is, return TRUE if LOC is a (possibly virtual) location of a built-in token that appears in the expansion diff --git a/gcc/input.h b/gcc/input.h index fd21f34abf1..e95bd3cb1a9 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -41,6 +41,7 @@ extern bool is_location_from_builtin_token (source_location); extern expanded_location expand_location (source_location); extern const char *location_get_source_line (const char *file_path, int line, int *line_size); +extern bool location_missing_trailing_newline (const char *file_path); extern expanded_location expand_location_to_spelling_point (source_location); extern source_location expansion_point_location_if_in_system_header (source_location); extern source_location expansion_point_location (source_location); diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index cd4b6254c81..c269ca6b940 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -1833,7 +1833,10 @@ expand_arith_overflow (enum tree_code code, gimple *stmt) { case MINUS_EXPR: if (integer_zerop (arg0) && !unsr_p) - expand_neg_overflow (loc, lhs, arg1, false); + { + expand_neg_overflow (loc, lhs, arg1, false); + return; + } /* FALLTHRU */ case PLUS_EXPR: expand_addsub_overflow (loc, code, lhs, arg0, arg1, diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 9514dd18177..60fcd023bf8 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -929,7 +929,7 @@ ipcp_alignment_lattice::meet_with_1 (unsigned new_align, unsigned new_misalign) if (misalign != (new_misalign % align)) { int diff = abs ((int) misalign - (int) (new_misalign % align)); - align = (unsigned) diff & -diff; + align = least_bit_hwi (diff); if (align) misalign = misalign % align; else @@ -4917,7 +4917,7 @@ ipcp_store_bits_results (void) { if (dump_file) fprintf (dump_file, "Not considering %s for ipa bitwise propagation " - "; -fipa-cp-bit: disabled.\n", + "; -fipa-bit-cp: disabled.\n", node->name ()); continue; } diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 2cf018bdf39..98d35006f2b 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -2136,8 +2136,7 @@ get_odr_type (tree type, bool insert) /* Be sure we did not recorded any derived types; these may need renumbering too. */ gcc_assert (val->derived_types.length() == 0); - if (odr_types_ptr) - val->id = odr_types.length (); + val->id = odr_types.length (); vec_safe_push (odr_types_ptr, val); } return val; diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index f29d929cf67..798d833971e 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -2133,6 +2133,23 @@ sem_variable::get_hash (void) return m_hash; } +/* Set all points-to UIDs of aliases pointing to node N as UID. */ + +static void +set_alias_uids (symtab_node *n, int uid) +{ + ipa_ref *ref; + FOR_EACH_ALIAS (n, ref) + { + if (dump_file) + fprintf (dump_file, " Setting points-to UID of [%s] as %d\n", + xstrdup_for_dump (ref->referring->asm_name ()), uid); + + SET_DECL_PT_UID (ref->referring->decl, uid); + set_alias_uids (ref->referring, uid); + } +} + /* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can be applied. */ @@ -2258,12 +2275,11 @@ sem_variable::merge (sem_item *alias_item) varpool_node::create_alias (alias_var->decl, decl); alias->resolve_alias (original); - if (DECL_PT_UID_SET_P (original->decl)) - SET_DECL_PT_UID (alias->decl, DECL_PT_UID (original->decl)); if (dump_file) - fprintf (dump_file, "Unified; Variable alias has been created.\n\n"); + fprintf (dump_file, "Unified; Variable alias has been created.\n"); + set_alias_uids (original, DECL_UID (original->decl)); return true; } } diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index c8b1fefc288..132779d2621 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -2183,28 +2183,33 @@ param_change_prob (gimple *stmt, int i) { tree op = gimple_call_arg (stmt, i); basic_block bb = gimple_bb (stmt); - tree base; - /* Global invariants neve change. */ - if (is_gimple_min_invariant (op)) + if (TREE_CODE (op) == WITH_SIZE_EXPR) + op = TREE_OPERAND (op, 0); + + tree base = get_base_address (op); + + /* Global invariants never change. */ + if (is_gimple_min_invariant (base)) return 0; + /* We would have to do non-trivial analysis to really work out what is the probability of value to change (i.e. when init statement is in a sibling loop of the call). We do an conservative estimate: when call is executed N times more often than the statement defining value, we take the frequency 1/N. */ - if (TREE_CODE (op) == SSA_NAME) + if (TREE_CODE (base) == SSA_NAME) { int init_freq; if (!bb->frequency) return REG_BR_PROB_BASE; - if (SSA_NAME_IS_DEFAULT_DEF (op)) + if (SSA_NAME_IS_DEFAULT_DEF (base)) init_freq = ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency; else - init_freq = gimple_bb (SSA_NAME_DEF_STMT (op))->frequency; + init_freq = gimple_bb (SSA_NAME_DEF_STMT (base))->frequency; if (!init_freq) init_freq = 1; @@ -2213,9 +2218,7 @@ param_change_prob (gimple *stmt, int i) else return REG_BR_PROB_BASE; } - - base = get_base_address (op); - if (base) + else { ao_ref refd; int max; @@ -2256,7 +2259,6 @@ param_change_prob (gimple *stmt, int i) else return REG_BR_PROB_BASE; } - return REG_BR_PROB_BASE; } /* Find whether a basic block BB is the final block of a (half) diamond CFG diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 16297817f95..b86a4a06218 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -4170,7 +4170,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt, * BITS_PER_UNIT); misalign = misalign & (align - 1); if (misalign != 0) - align = (misalign & -misalign); + align = least_bit_hwi (misalign); if (align < TYPE_ALIGN (type)) type = build_aligned_type (type, align); base = force_gimple_operand_gsi (&gsi, base, diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index a9570e4aa6c..9732cbff12e 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -508,6 +508,8 @@ special_builtin_state (enum pure_const_state_e *state, bool *looping, case BUILT_IN_FRAME_ADDRESS: case BUILT_IN_APPLY: case BUILT_IN_APPLY_ARGS: + case BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT: + case BUILT_IN_ASAN_AFTER_DYNAMIC_INIT: *looping = false; *state = IPA_CONST; return true; diff --git a/gcc/ira.c b/gcc/ira.c index f8a59e3cd64..62612521edb 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -2253,10 +2253,9 @@ compute_regs_asm_clobbered (void) void ira_setup_eliminable_regset (void) { -#ifdef ELIMINABLE_REGS int i; static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS; -#endif + /* FIXME: If EXIT_IGNORE_STACK is set, we will not save and restore sp for alloca. So we can't eliminate the frame pointer in that case. At some point, we should improve this by emitting the @@ -2292,7 +2291,6 @@ ira_setup_eliminable_regset (void) /* Build the regset of all eliminable registers and show we can't use those that we already know won't be eliminated. */ -#ifdef ELIMINABLE_REGS for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++) { bool cannot_elim @@ -2326,19 +2324,6 @@ ira_setup_eliminable_regset (void) else df_set_regs_ever_live (HARD_FRAME_POINTER_REGNUM, true); } - -#else - if (!TEST_HARD_REG_BIT (crtl->asm_clobbers, HARD_FRAME_POINTER_REGNUM)) - { - SET_HARD_REG_BIT (eliminable_regset, FRAME_POINTER_REGNUM); - if (frame_pointer_needed) - SET_HARD_REG_BIT (ira_no_alloc_regs, FRAME_POINTER_REGNUM); - } - else if (frame_pointer_needed) - error ("%s cannot be used in asm here", reg_names[FRAME_POINTER_REGNUM]); - else - df_set_regs_ever_live (FRAME_POINTER_REGNUM, true); -#endif } diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 74c5be8cc5d..acca8406a6c 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,10 @@ +2016-09-01 Martin Sebor <msebor@redhat.com> + + * decl.c (give_name_to_locals): Increase buffer size to guarantee + it fits the output of the formatted function regardless of its + arguments. + * mangle_name.c (append_unicode_mangled_name): Same. + 2016-08-26 Richard Biener <rguenther@suse.de> java/ @@ -1053,7 +1060,7 @@ java_init_options. (LANG_HOOKS_INIT_OPTIONS_STRUCT): Define. -2010-10-04 Andi Kleen <ak@linux.intel.com> +2010-10-04 Andi Kleen <ak@linux.intel.com> * Make-lang.in (xgcj, jc1, jcf-dump, jvgenmain): Add + to build rule. @@ -1488,7 +1495,7 @@ (build_jni_stub): Remove unused res_type variable. * verify-impl.c (check_field_constant): Remove unused len variable. -2009-10-20 Joel Dice <dicej@mailsnare.net> +2009-10-20 Joel Dice <dicej@mailsnare.net> PR java/28474 * mangle_name.c (append_unicode_mangled_name): Fix mangling @@ -1683,7 +1690,7 @@ * jcf-parse.c (handle_constant): Add cast to enum type. -2009-04-21 Taras Glek <tglek@mozilla.com> +2009-04-21 Taras Glek <tglek@mozilla.com> * builtins.c: Update GTY annotations to new syntax * decl.c: Likewise @@ -1987,7 +1994,7 @@ * jcf-dump.c (print_constant): Use HOST_LONG_LONG_FORMAT. -2008-05-07 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-05-07 Kenneth Zadeck <zadeck@naturalbridge.com> * decl.c (java_init_decl_processing): Change DECL_IS_PURE to DECL_PURE_P. @@ -2189,7 +2196,7 @@ * lang.c (java_dump_tree): Update. * java-tree.h (DECL_FUNCTION_BODY): Remove. -2007-09-11 Jan Hubicka <jh@suse.cz> +2007-09-11 Jan Hubicka <jh@suse.cz> * decl.c (java_expand_body): Kill. (LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION): Kill. @@ -3931,7 +3938,7 @@ * gjavah.c (decompile_method): Add ATTRIBUTE_UNUSED 2005-10-12 Nathan Sidwell <nathan@codesourcery.com> - Wil Mahan <wmahan@gmail.com> + Wil Mahan <wmahan@gmail.com> PR java/23620 * class.c (make_class): Create empty binfo here. @@ -4082,7 +4089,7 @@ * java-gimplify.c (java_gimplify_modify_expr): Fix any pointer type mismatches to make legal GIMPLE. -2005-08-10 Robin Green <greenrd@greenrd.org> +2005-08-10 Robin Green <greenrd@greenrd.org> PR java/23230: * parse.y (maybe_use_access_method): Generalize check from @@ -4440,7 +4447,7 @@ * jcf-write.c (generate_bytecode_insns) <SAVE_EXPR>: Don't call NOTE_PUSH. -2005-05-12 Aaron Luchko <aluchko@redhat.com> +2005-05-12 Aaron Luchko <aluchko@redhat.com> * gcj.texi: Add '-verify', '-noverify', and '-verifyremote'. @@ -6281,7 +6288,7 @@ * jcf-write.c (find_constant_index): Canonicalize NaNs when generating bytecode. -2004-08-16 Elliot Lee <sopwith@redhat.com> +2004-08-16 Elliot Lee <sopwith@redhat.com> PR java/9677 * jcf-parse.c (java_parse_file): Handle filenames with embedded @@ -7091,7 +7098,7 @@ class in an interface - create helper class nested in outer interface. (build_assertion): Short-circuit if enable_assertions is false. -2004-03-18 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> +2004-03-18 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> * java-tree.h: Changes throughout to add checking to macros and numerous whitespace changes. @@ -8511,7 +8518,7 @@ * parse.y (java_expand_classes): Scan the whole class list looking for access methods that haven't yet been expanded. -2003-01-31 Adrian Bunk <bunk@fs.tum.de> +2003-01-31 Adrian Bunk <bunk@fs.tum.de> Fix for java/4269: @@ -8831,7 +8838,7 @@ * gcj.texi (GNU Classpath Properties): Document new properties. -2003-01-02 Steven Bosscher <s.bosscher@student.tudelft.nl> +2003-01-02 Steven Bosscher <s.bosscher@student.tudelft.nl> * java/jcf-reader.c, java/jvgenmain.c, java/keyword.gperf, java/lang-options.h, java/mangle.c, java/mangle_name.c, @@ -8926,8 +8933,8 @@ * gcj.texi: Change version number to 3.4. -2002-12-05 Ranjit Mathew <rmathew@hotmail.com> - Andrew Haley <aph@redhat.com> +2002-12-05 Ranjit Mathew <rmathew@hotmail.com> + Andrew Haley <aph@redhat.com> * parse.y (source_end_java_method): Remove custom encoding of line numbers for a function decl before passing it to the back end. @@ -8972,8 +8979,8 @@ * parse.y (patch_binop): Cast right hand side of shift expression to `int'. Fixes PR java/8676. -2002-11-22 Ranjit Mathew <rmathew@hotmail.com> - Andrew Haley <aph@redhat.com> +2002-11-22 Ranjit Mathew <rmathew@hotmail.com> + Andrew Haley <aph@redhat.com> * gcc/java/jcf-write.c (write_classfile): Remove target class file, if it exists, before renaming the temporary @@ -9062,7 +9069,7 @@ * lang.c (dump_compound_expr): New. (java_dump_tree): New. -2002-10-20 Ranjit Mathew <rmathew@hotmail.com> +2002-10-20 Ranjit Mathew <rmathew@hotmail.com> * gcj.texi: Added item describing the GCJ runtime property "gnu.gcj.progname". @@ -9229,7 +9236,7 @@ * except.c (link_handler): Initialize `expanded' in new eh_range. (binding_depth, is_class_level, current_pc): Declare extern. -2002-09-01 Mark Wielaard <mark@klomp.org> +2002-09-01 Mark Wielaard <mark@klomp.org> * gcj.texi: Add chapter about system properties. Fixed some typos. @@ -9330,7 +9337,7 @@ (jcf_path_init): Use GET_ENVIRONMENT. 2002-07-10 Roger Sayle <roger@eyesopen.com> - Zack Weinberg <zack@codesourcery.com> + Zack Weinberg <zack@codesourcery.com> * builtins.c (initialize_builtins): Remove defines that handled C/C++ specific junk hereby removed from builtins.def. @@ -10039,7 +10046,7 @@ (java.install-common): Link native driver to JAVA_TARGET_INSTALL_NAME. -2002-03-05 David Billinghurst <David.Billinghurst@riotinto.com> +2002-03-05 David Billinghurst <David.Billinghurst@riotinto.com> * builtins.c(cos_builtin): method_return_type ATTRIBUTE_UNUSED * builtins.c(sin_builtin): Likewise @@ -10205,7 +10212,7 @@ recognize strictfp flag. * jcf.h (ACC_STRICT): New define. -2002-02-12 David Billinghurst <Davod.Billinghurst@riotinto.com> +2002-02-12 David Billinghurst <Davod.Billinghurst@riotinto.com> * class.c(build_utf8_ref): Move declaration of decl_size @@ -10254,7 +10261,7 @@ * parse.y (java_complete_expand_methods): Set current_function_decl before building JNI stub. -2002-01-26 Andreas Tobler <a.tobler@schweiz.ch> +2002-01-26 Andreas Tobler <a.tobler@schweiz.ch> * gcc/java/builtins.c (sqrt_builtin): Use BUILT_IN_SQRT, not BUILT_IN_SQRTF. @@ -10755,7 +10762,7 @@ Strip `main' from classname. Fixes PR java/227. -2001-11-18 Roger Sayle <roger@eyesopen.com> +2001-11-18 Roger Sayle <roger@eyesopen.com> * parse.h (java_expand_switch): Remove old prototype. @@ -12066,7 +12073,7 @@ too early to lay innerclasses out. 2001-03-20 Tom Tromey <tromey@redhat.com> - Alexandre Petit-Bianco <apbianco@redhat.com> + Alexandre Petit-Bianco <apbianco@redhat.com> * parse.y (patch_assignment): Handle the case of a SAVE_EXPR inside an array reference. Insertion of the array store check @@ -12995,7 +13002,7 @@ necessary. Fixes gcj/367. -2000-11-23 J"orn Rennecke <amylaar@redhat.com> +2000-11-23 J"orn Rennecke <amylaar@redhat.com> * Make-lang.in (jvspec.o): Depend on $(CONFIG_H). @@ -14578,7 +14585,7 @@ * parse.y (source_start_java_method): Deleted unnecessary code. (patch_method_invocation): Fixed comment. -2000-04-24 Robert Lipe <robertlipe@usa.net> +2000-04-24 Robert Lipe <robertlipe@usa.net> * parse.h (_jdep): Member `kind' now ENUM_BITFIELD. @@ -14951,7 +14958,7 @@ (resolve_qualified_expression_name): Handle situation where `this' is implied. -2000-03-13 Hans Boehm <boehm@acm.org> +2000-03-13 Hans Boehm <boehm@acm.org> * typeck.c (build_prim_array_type): Correctly set the high word too. @@ -15004,7 +15011,7 @@ * parse.y (patch_invoke): Call `build_invokeinterface' with new parameters. -2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> +2000-03-06 Bryce McKinlay <bryce@albatross.co.nz> * typeck.c (lookup_do): Search superinterfaces first when looking up an interface method. From Godmar Back @@ -16217,7 +16224,7 @@ check. * expr.c (expand_java_arraystore): Likewise. -1999-11-28 Anthony Green <green@cygnus.com> +1999-11-28 Anthony Green <green@cygnus.com> * decl.c (find_local_variable): Reuse single slot decls when appropriate. @@ -16294,7 +16301,7 @@ * parse.y (resolve_qualified_expression_name): Handle PLUS_EXPR. (qualify_ambiguous_name): Likewise. -1999-11-03 Godmar Back <gback@cs.utah.edu> +1999-11-03 Godmar Back <gback@cs.utah.edu> * typeck.c: (lookup_java_method): search all inherited interfaces when looking up interface method. @@ -16312,7 +16319,7 @@ (complete_function_arguments): Use CALL_EXPLICIT_CONSTRUCTOR_P instead of `CALL_THIS_CONSTRUCTOR_P'. -1999-10-30 Todd T. Fries <todd@lighthouse.fries.net> +1999-10-30 Todd T. Fries <todd@lighthouse.fries.net> * check-init.c: Fix typo in comment. @@ -16887,7 +16894,7 @@ (java_complete_expand_methods, java_expand_finals): Make static. (convert_narrow): Remove static prototype. -1999-08-03 J"orn Rennecke <amylaar@cygnus.co.uk> +1999-08-03 J"orn Rennecke <amylaar@cygnus.co.uk> * Makefile.in (decl.o): Depends on $(srcdir)/../defaults.h. @@ -18250,7 +18257,7 @@ Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> separator, rather than '/'. (make_class_data): Likewise. -1999-02-03 Marc Espie <Marc.Espie@liafa.jussieu.fr> +1999-02-03 Marc Espie <Marc.Espie@liafa.jussieu.fr> * Make-lang.in ($(GCJ)(exeext)): Remove choose-temp.o, pexecute.o and mkstemp.o. Get them from libiberty now. @@ -18615,7 +18622,7 @@ Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * parse.y (java_complete_expand_method): Call check_for_initialization. * parse.h (BLOCK_EXPR_DECLS, BLOCK_EXPR_BODY): Moved to java-tree.h. -1999-01-06 Graham <grahams@rcp.co.uk> +1999-01-06 Graham <grahams@rcp.co.uk> * parse.y : include system.h instead of including standard headers directly with the exception of <dirent.h>. @@ -19065,7 +19072,7 @@ Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> * expr.c (CHECK_PC_IN_RANGE): Add void cast to kill warnings. -1998-11-25 Marc Espie <espie@quatramaran.ens.fr> +1998-11-25 Marc Espie <espie@quatramaran.ens.fr> * jcf-write.c (generate_bytecode_conditional): Fix typo. @@ -21851,7 +21858,7 @@ Tue Mar 9 11:52:08 1999 Alexandre Petit-Bianco <apbianco@cygnus.com> mangle_class_field. (push_class_static_dummy_field): Likewise. -1998-05-17 Michael Tiemann <tiemann@cygnus.com> +1998-05-17 Michael Tiemann <tiemann@cygnus.com> * parse.y (source_start_java_method): Use TREE_SET_CODE instead of assigning to TREE_CODE. The latter method exploits a feature diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 36989d380ab..70eac315113 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1721,7 +1721,8 @@ give_name_to_locals (JCF *jcf) DECL_NAME (parm) = get_identifier ("this"); else { - char buffer[12]; + /* Buffer large enough for INT_MAX plus prefix. */ + char buffer[15]; sprintf (buffer, "ARG_%d", arg_i); DECL_NAME (parm) = get_identifier (buffer); } diff --git a/gcc/java/mangle_name.c b/gcc/java/mangle_name.c index 00374dbd298..7627c5d5df3 100644 --- a/gcc/java/mangle_name.c +++ b/gcc/java/mangle_name.c @@ -231,7 +231,8 @@ void append_gpp_mangled_name (const char *name, int len) { int encoded_len, needs_escapes; - char buf[6]; + /* Buffer large enough for INT_MIN. */ + char buf[9]; MANGLE_CXX_KEYWORDS (name, len); @@ -270,7 +271,8 @@ append_unicode_mangled_name (const char *name, int len) /* Everything else needs encoding */ else { - char buf [9]; + /* Buffer large enough for UINT_MAX plus the prefix. */ + char buf [13]; if (ch == '_' || ch == 'U') { /* Prepare to recognize __U */ diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 10d910c960d..cf5f91da125 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see #include "hooks.h" struct diagnostic_info; +class substring_loc; /* Note to creators of new hooks: @@ -81,6 +82,9 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *, tree); extern bool lhd_omp_mappable_type (tree); +extern const char *lhd_get_substring_location (const substring_loc &, + location_t *out_loc); + #define LANG_HOOKS_NAME "GNU unknown" #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier) #define LANG_HOOKS_INIT hook_bool_void_false @@ -121,6 +125,7 @@ extern bool lhd_omp_mappable_type (tree); #define LANG_HOOKS_EH_USE_CXA_END_CLEANUP false #define LANG_HOOKS_DEEP_UNSHARING false #define LANG_HOOKS_RUN_LANG_SELFTESTS lhd_do_nothing +#define LANG_HOOKS_GET_SUBSTRING_LOCATION lhd_get_substring_location /* Attribute hooks. */ #define LANG_HOOKS_ATTRIBUTE_TABLE NULL @@ -323,7 +328,8 @@ extern void lhd_end_section (void); LANG_HOOKS_BLOCK_MAY_FALLTHRU, \ LANG_HOOKS_EH_USE_CXA_END_CLEANUP, \ LANG_HOOKS_DEEP_UNSHARING, \ - LANG_HOOKS_RUN_LANG_SELFTESTS \ + LANG_HOOKS_RUN_LANG_SELFTESTS, \ + LANG_HOOKS_GET_SUBSTRING_LOCATION \ } #endif /* GCC_LANG_HOOKS_DEF_H */ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 3256a9d10cc..538d9f92710 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -693,6 +693,14 @@ lhd_enum_underlying_base_type (const_tree enum_type) TYPE_UNSIGNED (enum_type)); } +/* Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION. */ + +const char * +lhd_get_substring_location (const substring_loc &, location_t *) +{ + return "unimplemented"; +} + /* Returns true if the current lang_hooks represents the GNU C frontend. */ bool diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 44c258e9638..c109c8c7e15 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -34,6 +34,8 @@ typedef void (*lang_print_tree_hook) (FILE *, tree, int indent); enum classify_record { RECORD_IS_STRUCT, RECORD_IS_CLASS, RECORD_IS_INTERFACE }; +class substring_loc; + /* The following hooks are documented in langhooks.c. Must not be NULL. */ @@ -513,6 +515,13 @@ struct lang_hooks /* Run all lang-specific selftests. */ void (*run_lang_selftests) (void); + /* Attempt to determine the source location of the substring. + If successful, return NULL and write the source location to *OUT_LOC. + Otherwise return an error message. Error messages are intended + for GCC developers (to help debugging) rather than for end-users. */ + const char *(*get_substring_location) (const substring_loc &, + location_t *out_loc); + /* Whenever you add entries here, make sure you adjust langhooks-def.h and langhooks.c accordingly. */ }; diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index b568ea56d84..2d5fe48411b 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -979,7 +979,7 @@ unroll_loop_runtime_iterations (struct loop *loop) swtch = split_edge_and_insert (single_pred_edge (swtch), branch_code); set_immediate_dominator (CDI_DOMINATORS, preheader, swtch); - single_pred_edge (swtch)->probability = REG_BR_PROB_BASE - p; + single_succ_edge (swtch)->probability = REG_BR_PROB_BASE - p; e = make_edge (swtch, preheader, single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP); e->count = RDIV (preheader->count * REG_BR_PROB_BASE, p); diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 053a65aa404..bf5b521f51c 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -182,41 +182,31 @@ get_try_hard_regno (int regno) return ira_class_hard_regs[rclass][0]; } -/* Return final hard regno (plus offset) which will be after - elimination. We do this for matching constraints because the final - hard regno could have a different class. */ +/* Return the hard regno of X after removing its subreg. If X is not + a register or a subreg of a register, return -1. If X is a pseudo, + use its assignment. If FINAL_P return the final hard regno which will + be after elimination. */ static int -get_final_hard_regno (int hard_regno, int offset) -{ - if (hard_regno < 0) - return hard_regno; - hard_regno = lra_get_elimination_hard_regno (hard_regno); - return hard_regno + offset; -} - -/* Return hard regno of X after removing subreg and making - elimination. If X is not a register or subreg of register, return - -1. For pseudo use its assignment. */ -static int -get_hard_regno (rtx x) +get_hard_regno (rtx x, bool final_p) { rtx reg; - int offset, hard_regno; + int hard_regno; reg = x; - if (GET_CODE (x) == SUBREG) + if (SUBREG_P (x)) reg = SUBREG_REG (x); if (! REG_P (reg)) return -1; - if ((hard_regno = REGNO (reg)) >= FIRST_PSEUDO_REGISTER) + if (! HARD_REGISTER_NUM_P (hard_regno = REGNO (reg))) hard_regno = lra_get_regno_hard_regno (hard_regno); if (hard_regno < 0) return -1; - offset = 0; - if (GET_CODE (x) == SUBREG) - offset += subreg_regno_offset (hard_regno, GET_MODE (reg), - SUBREG_BYTE (x), GET_MODE (x)); - return get_final_hard_regno (hard_regno, offset); + if (final_p) + hard_regno = lra_get_elimination_hard_regno (hard_regno); + if (SUBREG_P (x)) + hard_regno += subreg_regno_offset (hard_regno, GET_MODE (reg), + SUBREG_BYTE (x), GET_MODE (x)); + return hard_regno; } /* If REGNO is a hard register or has been allocated a hard register, @@ -228,11 +218,11 @@ get_reg_class (int regno) { int hard_regno; - if ((hard_regno = regno) >= FIRST_PSEUDO_REGISTER) + if (! HARD_REGISTER_NUM_P (hard_regno = regno)) hard_regno = lra_get_regno_hard_regno (regno); if (hard_regno >= 0) { - hard_regno = get_final_hard_regno (hard_regno, 0); + hard_regno = lra_get_elimination_hard_regno (hard_regno); return REGNO_REG_CLASS (hard_regno); } if (regno >= new_regno_start) @@ -693,7 +683,7 @@ operands_match_p (rtx x, rtx y, int y_hard_regno) { int j; - i = get_hard_regno (x); + i = get_hard_regno (x, false); if (i < 0) goto slow; @@ -1712,7 +1702,7 @@ uses_hard_regs_p (rtx x, HARD_REG_SET set) if (REG_P (x)) { - x_hard_regno = get_hard_regno (x); + x_hard_regno = get_hard_regno (x, true); return (x_hard_regno >= 0 && overlaps_hard_reg_set_p (set, mode, x_hard_regno)); } @@ -1839,7 +1829,7 @@ process_alt_operands (int only_alternative) op = no_subreg_reg_operand[nop] = *curr_id->operand_loc[nop]; /* The real hard regno of the operand after the allocation. */ - hard_regno[nop] = get_hard_regno (op); + hard_regno[nop] = get_hard_regno (op, true); operand_reg[nop] = reg = op; biggest_mode[nop] = GET_MODE (op); @@ -2000,7 +1990,7 @@ process_alt_operands (int only_alternative) lra_assert (nop > m); this_alternative_matches = m; - m_hregno = get_hard_regno (*curr_id->operand_loc[m]); + m_hregno = get_hard_regno (*curr_id->operand_loc[m], false); /* We are supposed to match a previous operand. If we do, we win if that one did. If we do not, count both of the operands as losers. diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c index 08cc39011d1..1764bd699ce 100644 --- a/gcc/lra-eliminations.c +++ b/gcc/lra-eliminations.c @@ -108,15 +108,7 @@ static const struct elim_table_1 const int to; } reg_eliminate_1[] = -/* If a set of eliminable hard registers was specified, define the - table from it. Otherwise, default to the normal case of the frame - pointer being replaced by the stack pointer. */ - -#ifdef ELIMINABLE_REGS ELIMINABLE_REGS; -#else - {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}; -#endif #define NUM_ELIMINABLE_REGS ARRAY_SIZE (reg_eliminate_1) @@ -1265,11 +1257,7 @@ update_reg_eliminate (bitmap insns_with_changed_offsets) } } -#ifdef ELIMINABLE_REGS INITIAL_ELIMINATION_OFFSET (ep->from, ep->to, ep->offset); -#else - INITIAL_FRAME_POINTER_OFFSET (ep->offset); -#endif } setup_elimination_map (); result = false; @@ -1308,10 +1296,8 @@ static void init_elim_table (void) { struct lra_elim_table *ep; -#ifdef ELIMINABLE_REGS bool value_p; const struct elim_table_1 *ep1; -#endif if (!reg_eliminate) reg_eliminate = XCNEWVEC (struct lra_elim_table, NUM_ELIMINABLE_REGS); @@ -1320,7 +1306,7 @@ init_elim_table (void) /* Initiate member values which will be never changed. */ self_elim_table.can_eliminate = self_elim_table.prev_can_eliminate = true; self_elim_table.previous_offset = 0; -#ifdef ELIMINABLE_REGS + for (ep = reg_eliminate, ep1 = reg_eliminate_1; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++, ep1++) { @@ -1334,12 +1320,6 @@ init_elim_table (void) || ! stack_realign_fp))); setup_can_eliminate (ep, value_p); } -#else - reg_eliminate[0].offset = reg_eliminate[0].previous_offset = 0; - reg_eliminate[0].from = reg_eliminate_1[0].from; - reg_eliminate[0].to = reg_eliminate_1[0].to; - setup_can_eliminate (®_eliminate[0], ! frame_pointer_needed); -#endif /* Build the FROM and TO REG rtx's. Note that code in gen_rtx_REG will cause, e.g., gen_rtx_REG (Pmode, STACK_POINTER_REGNUM) to diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 86cc8b13459..c5bd7a07a6e 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,7 @@ +2016-09-19 Richard Biener <rguenther@suse.de> + + * lto.c (lto_main): Invoke early_finish debug hook. + 2016-07-25 Richard Biener <rguenther@suse.de> * lto.c (compare_tree_sccs_1): Remove streamer_handle_as_builtin_p uses. @@ -2636,7 +2640,7 @@ * lto-macho.c: New file. * Make-lang.in: Add rule for lto-macho.o. -2010-05-07 Richard Guenther <rguenther@suse.de> +2010-05-07 Richard Guenther <rguenther@suse.de> PR lto/43857 PR lto/43371 @@ -3905,7 +3909,7 @@ (lto_post_options): Suppress debug info generation. * Make-lang.in: Add dependency of lto-lang.o on tree-gimple.h. -2008-08-25 Bill Maddox <maddox@google.com> +2008-08-25 Bill Maddox <maddox@google.com> * lto-symtab.c (lto_symtab_merge_decl): Remove a suspect assertion and leave an explanatory comment in its place. @@ -4170,7 +4174,7 @@ * lto-section-out.h (lto_hash_global_slot_node, lto_eq_global_slot_node): Declare. -2008-06-07 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-06-07 Kenneth Zadeck <zadeck@naturalbridge.com> Jan Hubicka <jh@suse.cz> * lto.c (sys/mman.h, tree-pass.h): New includes. @@ -4186,7 +4190,7 @@ (lto_main): Now calls pass manager, sets the hooks so that the ipa passes can get the section data. -2008-05-27 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-05-27 Kenneth Zadeck <zadeck@naturalbridge.com> * lto.h (lto_read_decls): Made local. (lto_input_function_body, lto_input_constructors_and_inits, @@ -4266,11 +4270,11 @@ * lto.c (lto_read_compile_unit_DIE): Add DW_LANG_C_plus_plus to the list of supported languages. -2008-03-25 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-03-25 Kenneth Zadeck <zadeck@naturalbridge.com> Merge with mainline @133491. -2008-03-05 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-03-05 Kenneth Zadeck <zadeck@naturalbridge.com> Jan Hubicka <jh@suse.cz> * lto.c (lto_info_fd_init, lto_info_fd_close): Get rid of @@ -4307,7 +4311,7 @@ (section_hash_table.lto_file_decl_data): New field. -2008-02-09 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-02-09 Kenneth Zadeck <zadeck@naturalbridge.com> * lto.c (lto_read_variable_formal_parameter_const): Remove code to reconstruct static initializers. @@ -4344,7 +4348,7 @@ Renamed to lto_input_function_body and takes file_data parameter. * lto-section-in.h (lto_file_decl_data): New structure. -2008-01-28 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-01-28 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-function-in.c (input_globals.c): Changed input type to lto_function_header. @@ -4362,7 +4366,7 @@ * lto-elf.c (lto_elf_read_var_init): Remove unused function. (lto_elf_build_init): Likewise. -2008-01-14 Kenneth Zadeck <zadeck@naturalbridge.com> +2008-01-14 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c: Renamed to lto-function-in.c. (input_1_unsigned): Moved to lto-section-in.c and renamed @@ -4421,7 +4425,7 @@ (LANG_HOOKS_TYPES_COMPATIBLE_P): Define. 2007-12-22 Nathan Froyd <froydnj@codesourcery.com> - Kenneth Zadeck <zadeck@naturalbridge.com> + Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Fixed uninitialize var warning. (input_local_vars): Read in DECL_INITIAL and context for local @@ -4449,7 +4453,7 @@ * lto.c (lto_read_subroutine_type_subprogram_DIE): Initialize 'declaration'. Set the assembler name for non-public functions. -2007-12-17 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-12-17 Kenneth Zadeck <zadeck@naturalbridge.com> * lto_read.c (data_in.unexpanded_indexes): New array. (input_local_var): Added code to read in unexpanded_var_list @@ -4622,12 +4626,12 @@ Don't combine TREE_PUBLIC flags. Copy over DECL_SIZE and DECL_SIZE_UNIT if necessary. -2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Get types right for COMPLEX_CST. -2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (make_new_block, input_cfg): Properly set n_basic_blocks. @@ -4642,7 +4646,7 @@ * lto.c (lto_read_base_type_DIE): Use make_bitfield_integer_type to construct the integer type for bitfields. -2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-16 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (data_in.current_node_has_loc): Removed. (input_line_info): Returns true if node needs line set. @@ -4675,7 +4679,7 @@ (lto_builtin_function): Chain the new decl onto registered_builtin_fndecls. -2007-11-15 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-15 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (process_tree_flags, lto_static_init_local): Renamed to ADD_CLASS_EXPR_FLAG. ADD_CLASS_DECL_FLAG New Macro. @@ -4693,7 +4697,7 @@ * lto-read.c (set_line_info): Remove ; from calls to LINEMAP_POSITION_FOR_COLUMN. -2007-11-13 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-13 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_type_ref): Renamed from get_type_ref. (input_expr_operand, input_local_var): Renamed get_type_ref to @@ -4730,12 +4734,12 @@ nodes. (LANG_HOOKS_REGISTER_BUILTIN_TYPE): Define. -2007-11-13 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-13 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Added code to properly handle index filed. Added new RANGE_EXPR case. -2007-11-11 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-11 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (ADD_FUNC_FLAG): Deleted macro. (data_in): Added current_node_has_loc field. @@ -4796,7 +4800,7 @@ (lto_file_vtable): Use it instead of lto_file. 2007-11-06 Alon Dayan <alond@il.ibm.com> - Kenneth Zadeck <zadeck@naturalbridge.com> + Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (process_flags, lto_static_init_local): read flags of VAR_DECL and FUNCTION_DECL of size>1. @@ -4814,7 +4818,7 @@ * lto-read.c (input_expr_operand): Change the LTO_return_expr1 case to use DECL_RESULT if necessary. -2007-11-01 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-11-01 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_tree_list): Removed. (input_tree_flags): Added parameter to force flags no matter what @@ -4844,7 +4848,7 @@ (lto/lto-symtab.o): Depend on LTO_H instead of TREE_H. (lto/lto-read.o): Likewise. -2007-10-29 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-29 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (data_in): Added type_decls and current_col fields. (string_slot): New type to hold canonized file name. @@ -4883,7 +4887,7 @@ RESULT_DECL slightly earlier. Only remember the decl for later if we successfully merge declarations. -2007-10-24 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-24 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Give label_values the proper context and provide switch statements with a default type. @@ -4906,7 +4910,7 @@ * lto-read.c (lto_read_body): Call init_ssa_operands if we are reading a function body. -2007-10-20 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-20 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_tree_flags): Renamed from input_flags to be semetric with output_tree_flags. Added call to log flags. @@ -4959,7 +4963,7 @@ Implement for scalar integer modes. (lto_init): Initialize size_type_node. -2007-10-18 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-18 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Remove ssa name asserts. (input_local_var): Add chaining for params. @@ -4988,7 +4992,7 @@ (input_cfg): Use basic_block_info_for_function instead of basic_block_info. -2007-10-16 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-16 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_sleb128, input_integer): Use proper casts. (input_list): Renamed input_tree_list and modified to follow same @@ -4998,7 +5002,7 @@ (lto_read_body): Change placement for setting context of debug_labels. -2007-10-16 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-10-16 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_real): Output debugging in proper order. (input_integer): Compute bit lengths properly. @@ -5044,7 +5048,7 @@ the DIE. (lto_resolve_fn_ref): Delete trailing whitespace. -2007-09-11 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-09-11 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Added type for STRING_CST. @@ -5077,7 +5081,7 @@ * lto-read.c (lto_read_body): Doc fix. -2007-08-29 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-08-29 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (fun_in): Renamed to data_in. (input_expr_operand, input_local_var, input_string_internal, @@ -5091,13 +5095,13 @@ (lto_read_function_body, lto_read_var_init): New function. -2007-08-28 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-08-28 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Assert that there really is a FUNCTION_DECL. (input_globals): Removed checks on 0 section. -2007-08-28 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-08-28 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (fun_in): Added local_decls_index and local_decls_index_d. @@ -5153,12 +5157,12 @@ * lto.c (lto_read_form): Add entry for DW_AT_inline. -2007-08-02 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-08-02 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (lto_read_function_body): Moved declaration of fn outside of ifdef. -2007-08-01 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-08-01 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_uleb128, input_string_internal, input_real, input_integer, input_record_start, input_list, get_type_ref, @@ -5167,13 +5171,12 @@ input_ssa_names, input_bb, input_function): Added semicolons. -2007-07-31 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-07-31 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_globals): Remove debugging. (input_function): Set DECL_ARGUMENTS. - -2007-07-31 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-07-31 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_expr_operand): Fixed code for COND_EXEC, RETURN_EXPR, MODIFY_EXPR and processing of flags. @@ -5218,7 +5221,7 @@ process local variables. (lto_read_subroutine_type_subprogram_DIE): Read child DIEs. -2007-07-13 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-07-13 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read.c (input_list, input_expr_operand): Added struct function parameter. @@ -5257,7 +5260,7 @@ (lto_elf_read_var_init): Likewise. * Make-lang.in (lto/lto-elf.o): Depend on $(TM_H). -2007-06-26 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-06-26 Kenneth Zadeck <zadeck@naturalbridge.com> * lto-read (make_new_block): Initialize the stmt_list. (lto_static_init_local): Add debugging for missing codes. @@ -5280,7 +5283,7 @@ * Make-lang.in (LTO_OBJS): Depend on attribs.o. -2007-06-21 Kenneth Zadeck <zadeck@naturalbridge.com> +2007-06-21 Kenneth Zadeck <zadeck@naturalbridge.com> * lto/lto-tree.h (lang_decl, lang_type, language_function): Added dummy since ggc does not like empty structs. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 73d1e26be71..c94ed622307 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -3315,6 +3315,9 @@ lto_main (void) if (!flag_ltrans) lto_promote_statics_nonwpa (); + /* Annotate the CU DIE and mark the early debug phase as finished. */ + debug_hooks->early_finish (); + /* Let the middle end know that we have read and merged all of the input files. */ symtab->compile (); diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index cf735d125e1..6badc59df74 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1651,7 +1651,7 @@ to gcc_alloc_xxx calls in hash_init and hash_class_name_enter to get it to compile in the current trunk. - 2006-01-27 Fariborz Jahanian <fjahanian@apple.com> + 2006-01-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4345837 * objc/objc-act.c (hash_class_name_enter): New. @@ -1690,7 +1690,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2006-03-10 Fariborz Jahanian <fjahanian@apple.com> + 2006-03-10 Fariborz Jahanian <fjahanian@apple.com> Radar 4407151 * objc/objc-act.c (objc_is_class_name): template parameter is not @@ -1702,12 +1702,12 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-11-08 Fariborz Jahanian <fjahanian@apple.com> + 2005-11-08 Fariborz Jahanian <fjahanian@apple.com> Radar 4330422 * objc/objc-act.c (objc_non_volatilized_type): New - 2005-10-07 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-07 Fariborz Jahanian <fjahanian@apple.com> Radar 4204796 * objc-act.c (objc_build_volatilized_type): Build 'volatilzed' @@ -1721,7 +1721,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> + 2006-03-27 Fariborz Jahanian <fjahanian@apple.com> Radar 4133425 * objc-act.c (objc_diagnose_private_ivar): New. @@ -1741,7 +1741,7 @@ 2010-10-14 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. - 2006 Fariborz Jahanian <fjahanian@apple.com> + 2006 Fariborz Jahanian <fjahanian@apple.com> Radars 4436866, 4505126, 4506903, 4517826 * objc-act.c (CALL_EXPR_OBJC_PROPERTY_GETTER): New. @@ -1792,7 +1792,7 @@ merge from FSF apple 'trunk' branch. - 2006-04-26 Fariborz Jahanian <fjahanian@apple.com> + 2006-04-26 Fariborz Jahanian <fjahanian@apple.com> Radar 3803157 (method attributes) * objc/objc-act.h (METHOD_TYPE_ATTRIBUTES): New macro. * objc/objc-act.c (objc_decl_method_attributes): New. @@ -1850,7 +1850,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2006-04-12 Fariborz Jahanian <fjahanian@apple.com> + 2006-04-12 Fariborz Jahanian <fjahanian@apple.com> Radar 4507230 * objc-act.c (objc_type_valid_for_messaging): New routine to check @@ -1862,20 +1862,20 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-10-17 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-17 Fariborz Jahanian <fjahanian@apple.com> Radar 4290840 * objc-act.c (objc_start_method_definition): Check for error_mark_node for the selector name and make a quick exit. -2010-10-04 Andi Kleen <ak@linux.intel.com> +2010-10-04 Andi Kleen <ak@linux.intel.com> * Make-lang.in (cc1obj-dummy, cc1obj): Add + to build rule. 2010-09-30 Iain Sandoe <iains@gcc.gnu.org> merge from FSF 'apple/trunk' branch. - 2006-01-30 Fariborz Jahanian <fjahanian@apple.com> + 2006-01-30 Fariborz Jahanian <fjahanian@apple.com> Radar 4386773 * objc/objc-act.c (objc_set_method_opt): New function. @@ -1893,7 +1893,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> Radar 4278236 * objc-act.c (objc_declare_class): Pick the right @@ -1903,7 +1903,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-04 Fariborz Jahanian <fjahanian@apple.com> Radar 4281748 * objc-act.c (objc_check_global_decl): New @@ -1934,7 +1934,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-08-23 Stuart Hastings <stuart@apple.com> + 2005-08-23 Stuart Hastings <stuart@apple.com> Ziemowit Laski <zlaski@apple.com> Radar 4209854 @@ -2001,7 +2001,7 @@ Merge from 'apple/trunk' branch on FSF servers. I modified the changes to be used only when compiling for the NeXT runtime. - 2005-10-10 Fariborz Jahanian <fjahanian@apple.com> + 2005-10-10 Fariborz Jahanian <fjahanian@apple.com> Radar 4301047 @@ -2018,7 +2018,7 @@ Merge from 'apple/trunk' branch on FSF servers. - 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> + 2005-12-15 Fariborz Jahanian <fjahanian@apple.com> Radar 4229905 * objc-act.c (objc_have_common_types): New function. @@ -2056,13 +2056,13 @@ Merge from 'apple/trunk' branch on FSF servers. - 2006-03-09 Fariborz Jahanian <fjahanian@apple.com> + 2006-03-09 Fariborz Jahanian <fjahanian@apple.com> Radar 4457381 * objc/objc-act.c (objc_finish_message_expr): Look for message in @class's protocol list. - 2006-02-07 Fariborz Jahanian <fjahanian@apple.com> + 2006-02-07 Fariborz Jahanian <fjahanian@apple.com> Radar 4219590 * objc/objc-act.c (objc_start_method_definition): Initialize @@ -2251,19 +2251,19 @@ really_start_method, get_super_receiver, handle_class_ref): Set DECL_READ_P in addition to TREE_USED. -2010-04-07 Iain Sandoe <iains@gcc.gnu.org> +2010-04-07 Iain Sandoe <iains@gcc.gnu.org> PR objc/35996 * objc-act.c (objc_init): Warn that -fobjc-gc is ignored for -fgnu-runtime and set flag_objc_gc to zero. -2010-04-07 Iain Sandoe <iains@gcc.gnu.org> +2010-04-07 Iain Sandoe <iains@gcc.gnu.org> PR objc++/23716 * objc-act.c (build_module_initializer_routine): Make the argument to objc_start_function NULL_TREE when compiling ObjC++. -2010-02-18 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk> +2010-02-18 Iain Sandoe <iain.sandoe@sandoe-acoustics.co.uk> Mike Stump <mikestump@comcast.net> PR objc/43061 @@ -2476,7 +2476,7 @@ * objc-act.c (get_super_receiver): Update calls to build_modify_expr to pass new argument. -2009-04-21 Taras Glek <tglek@mozilla.com> +2009-04-21 Taras Glek <tglek@mozilla.com> * objc-act.c: Update GTY annotations to new syntax * objc-act.h: Likewise @@ -2781,13 +2781,14 @@ PR objc/27240 * objc-act.c (objc_is_public): Return early on invalid type. -2006-03-02 Fariborz Jahanian <fjahanian@apple.com> +2006-03-02 Fariborz Jahanian <fjahanian@apple.com> * objc-act.c (init_module_descriptor): Remove file name from module descriptor. (gen_type_name_0): Fix ICE when issuing warning. -2006-02-20 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> +2006-02-20 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> + * Make-lang.in (OBJC): Remove (OBJECTIVE-C): Remove (objective-c): Remove diff --git a/gcc/objcp/ChangeLog b/gcc/objcp/ChangeLog index 1451a1c8513..e51e8f587c7 100644 --- a/gcc/objcp/ChangeLog +++ b/gcc/objcp/ChangeLog @@ -200,7 +200,7 @@ 2010-10-14 Iain Sandoe <iains@gcc.gnu.org> merge from FSF apple 'trunk' branch. - 2006 Fariborz Jahanian <fjahanian@apple.com> + 2006 Fariborz Jahanian <fjahanian@apple.com> Radars 4436866, 4505126, 4506903, 4517826 * objcp-lang.c (objcxx_init_ts): Update for property_decl. @@ -221,7 +221,7 @@ (cc1objplus-checksum): Change to run checksum over object files and options only. -2010-10-04 Andi Kleen <ak@linux.intel.com> +2010-10-04 Andi Kleen <ak@linux.intel.com> * Make-lang.in (cc1objplus-dummy, cc1objplus): Add + to build rule. @@ -426,7 +426,7 @@ * Make-lang.in (objcp/objcp-decl.o): Add dependency on $(TARGET_H). -2006-02-20 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> +2006-02-20 Rafael Ávila de Espíndola <rafael.espindola@gmail.com> * Make-lang.in (OBJ-C++): Remove (.PHONY): Remove Obj-c++ and obj-C++. Add obj-c++ diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 3f7debf1fd1..bf52d849d9e 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1120,7 +1120,8 @@ maybe_lookup_field (tree var, omp_context *ctx) static bool use_pointer_for_field (tree decl, omp_context *shared_ctx) { - if (AGGREGATE_TYPE_P (TREE_TYPE (decl))) + if (AGGREGATE_TYPE_P (TREE_TYPE (decl)) + || TYPE_ATOMIC (TREE_TYPE (decl))) return true; /* We can only use copy-in/copy-out semantics for shared variables @@ -4301,7 +4302,9 @@ lower_rec_simd_input_clauses (tree new_var, omp_context *ctx, int &max_vf, { tree c = find_omp_clause (gimple_omp_for_clauses (ctx->stmt), OMP_CLAUSE_SAFELEN); - if (c && TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) != INTEGER_CST) + if (c + && (TREE_CODE (OMP_CLAUSE_SAFELEN_EXPR (c)) != INTEGER_CST + || tree_int_cst_sgn (OMP_CLAUSE_SAFELEN_EXPR (c)) != 1)) max_vf = 1; else if (c && compare_tree_int (OMP_CLAUSE_SAFELEN_EXPR (c), max_vf) == -1) @@ -19449,7 +19452,7 @@ oacc_loop_fixed_partitions (oacc_loop *loop, unsigned outer_mask) } else { - unsigned outermost = this_mask & -this_mask; + unsigned outermost = least_bit_hwi (this_mask); if (outermost && outermost <= outer_mask) { @@ -19530,7 +19533,7 @@ oacc_loop_auto_partitions (oacc_loop *loop, unsigned outer_mask) /* Determine the outermost partitioning used within this loop. */ this_mask = loop->inner | GOMP_DIM_MASK (GOMP_DIM_MAX); - this_mask = (this_mask & -this_mask); + this_mask = least_bit_hwi (this_mask); /* Pick the partitioning just inside that one. */ this_mask >>= 1; diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c index 467d8725225..df140d40446 100644 --- a/gcc/omp-simd-clone.c +++ b/gcc/omp-simd-clone.c @@ -126,13 +126,11 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, clone_info->cilk_elemental = cilk_clone; if (!clauses) - { - args.release (); - return clone_info; - } + goto out; + clauses = TREE_VALUE (clauses); if (!clauses || TREE_CODE (clauses) != OMP_CLAUSE) - return clone_info; + goto out; for (t = clauses; t; t = OMP_CLAUSE_CHAIN (t)) { @@ -252,6 +250,28 @@ simd_clone_clauses_extract (struct cgraph_node *node, tree clauses, break; } } + + out: + if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (node->decl)))) + { + warning_at (DECL_SOURCE_LOCATION (node->decl), 0, + "ignoring %<#pragma omp declare simd%> on function " + "with %<_Atomic%> qualified return type"); + args.release (); + return NULL; + } + + for (unsigned int argno = 0; argno < clone_info->nargs; argno++) + if (TYPE_ATOMIC (args[argno]) + && clone_info->args[argno].arg_type != SIMD_CLONE_ARG_TYPE_UNIFORM) + { + warning_at (DECL_SOURCE_LOCATION (node->decl), 0, + "ignoring %<#pragma omp declare simd%> on function " + "with %<_Atomic%> qualified non-%<uniform%> argument"); + args.release (); + return NULL; + } + args.release (); return clone_info; } @@ -911,11 +931,11 @@ ipa_simd_modify_function_body (struct cgraph_node *node, } l = adjustments.length (); - for (i = 1; i < num_ssa_names; i++) + tree name; + + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (name - && SSA_NAME_VAR (name) + if (SSA_NAME_VAR (name) && TREE_CODE (SSA_NAME_VAR (name)) == PARM_DECL) { for (j = 0; j < l; j++) diff --git a/gcc/optabs.c b/gcc/optabs.c index 87b4f978420..e41747a630f 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -3716,13 +3716,17 @@ can_compare_p (enum rtx_code code, machine_mode mode, } /* This function is called when we are going to emit a compare instruction that - compares the values found in *PX and *PY, using the rtl operator COMPARISON. + compares the values found in X and Y, using the rtl operator COMPARISON. - *PMODE is the mode of the inputs (in case they are const_int). - *PUNSIGNEDP nonzero says that the operands are unsigned; + If they have mode BLKmode, then SIZE specifies the size of both operands. + + UNSIGNEDP nonzero says that the operands are unsigned; this matters if they need to be widened (as given by METHODS). - If they have mode BLKmode, then SIZE specifies the size of both operands. + *PTEST is where the resulting comparison RTX is returned or NULL_RTX + if we failed to produce one. + + *PMODE is the mode of the inputs (in case they are const_int). This function performs all the setup necessary so that the caller only has to emit a single comparison insn. This setup can involve doing a BLKmode diff --git a/gcc/opts-common.c b/gcc/opts-common.c index 8634b520ecf..e9d1c20a1f3 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -1069,6 +1069,38 @@ generate_option_input_file (const char *file, decoded->errors = 0; } +/* Helper function for listing valid choices and hint for misspelled + value. CANDIDATES is a vector containing all valid strings, + STR is set to a heap allocated string that contains all those + strings concatenated, separated by spaces, and the return value + is the closest string from those to ARG, or NULL if nothing is + close enough. Callers should XDELETEVEC (STR) after using it + to avoid memory leaks. */ + +const char * +candidates_list_and_hint (const char *arg, char *&str, + const auto_vec <const char *> &candidates) +{ + size_t len = 0; + int i; + const char *candidate; + char *p; + + FOR_EACH_VEC_ELT (candidates, i, candidate) + len += strlen (candidate) + 1; + + str = p = XNEWVEC (char, len); + FOR_EACH_VEC_ELT (candidates, i, candidate) + { + len = strlen (candidate); + memcpy (p, candidate, len); + p[len] = ' '; + p += len + 1; + } + p[-1] = '\0'; + return find_closest_string (arg, &candidates); +} + /* Perform diagnostics for read_cmdline_option and control_warning_option functions. Returns true if an error has been diagnosed. LOC and LANG_MASK arguments like in read_cmdline_option. @@ -1108,38 +1140,27 @@ cmdline_handle_error (location_t loc, const struct cl_option *option, { const struct cl_enum *e = &cl_enums[option->var_enum]; unsigned int i; - size_t len; - char *s, *p; + char *s; if (e->unknown_error) error_at (loc, e->unknown_error, arg); else error_at (loc, "unrecognized argument in option %qs", opt); - len = 0; - for (i = 0; e->values[i].arg != NULL; i++) - len += strlen (e->values[i].arg) + 1; - auto_vec <const char *> candidates; - s = XALLOCAVEC (char, len); - p = s; for (i = 0; e->values[i].arg != NULL; i++) { if (!enum_arg_ok_for_language (&e->values[i], lang_mask)) continue; - size_t arglen = strlen (e->values[i].arg); - memcpy (p, e->values[i].arg, arglen); - p[arglen] = ' '; - p += arglen + 1; candidates.safe_push (e->values[i].arg); } - p[-1] = 0; - const char *hint = find_closest_string (arg, &candidates); + const char *hint = candidates_list_and_hint (arg, s, candidates); if (hint) inform (loc, "valid arguments to %qs are: %s; did you mean %qs?", option->opt_text, s, hint); else inform (loc, "valid arguments to %qs are: %s", option->opt_text, s); + XDELETEVEC (s); return true; } diff --git a/gcc/opts.c b/gcc/opts.c index bc0570dbd5e..86b422a706f 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1471,9 +1471,9 @@ const struct sanitizer_opts_s sanitizer_opts[] = SANITIZER_OPT (returns-nonnull-attribute, SANITIZE_RETURNS_NONNULL_ATTRIBUTE), SANITIZER_OPT (object-size, SANITIZE_OBJECT_SIZE), SANITIZER_OPT (vptr, SANITIZE_VPTR), - SANITIZER_OPT (all, ~0), + SANITIZER_OPT (all, ~0U), #undef SANITIZER_OPT - { NULL, 0, 0 } + { NULL, 0U, 0UL } }; /* Parse comma separated sanitizer suboptions from P for option SCODE, diff --git a/gcc/opts.h b/gcc/opts.h index 25d32c1ad49..4132432bd7c 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -419,5 +419,8 @@ extern const struct sanitizer_opts_s extern void add_misspelling_candidates (auto_vec<char *> *candidates, const struct cl_option *option, const char *base_option); +extern const char *candidates_list_and_hint (const char *arg, char *&str, + const auto_vec <const char *> & + candidates); #endif diff --git a/gcc/passes.c b/gcc/passes.c index c7d7dbe7e91..07ebf8b4a2f 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -771,7 +771,9 @@ pass_manager::register_one_dump_file (opt_pass *pass) { char *dot_name, *flag_name, *glob_name; const char *name, *full_name, *prefix; - char num[10]; + + /* Buffer big enough to format a 32-bit UINT_MAX into. */ + char num[11]; int flags, id; int optgroup_flags = OPTGROUP_NONE; gcc::dump_manager *dumps = m_ctxt->get_dumps (); @@ -779,7 +781,7 @@ pass_manager::register_one_dump_file (opt_pass *pass) /* See below in next_pass_1. */ num[0] = '\0'; if (pass->static_pass_number != -1) - sprintf (num, "%d", ((int) pass->static_pass_number < 0 + sprintf (num, "%u", ((int) pass->static_pass_number < 0 ? 1 : pass->static_pass_number)); /* The name is both used to identify the pass for the purposes of plugins, diff --git a/gcc/passes.def b/gcc/passes.def index 533157d621c..e98a719fc2b 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -84,6 +84,7 @@ along with GCC; see the file COPYING3. If not see /* After CCP we rewrite no longer addressed locals into SSA form if possible. */ NEXT_PASS (pass_forwprop); + NEXT_PASS (pass_early_thread_jumps); NEXT_PASS (pass_sra_early); /* pass_build_ealias is a dummy pass that ensures that we execute TODO_rebuild_alias at this point. */ diff --git a/gcc/po/ChangeLog b/gcc/po/ChangeLog index 37c7beea19a..383786c202d 100644 --- a/gcc/po/ChangeLog +++ b/gcc/po/ChangeLog @@ -1,3 +1,7 @@ +2016-09-05 Joseph Myers <joseph@codesourcery.com> + + * sv.po: Update. + 2016-08-26 Joseph Myers <joseph@codesourcery.com> * be.po, da.po, de.po, el.po, es.po, fi.po, fr.po, hr.po, id.po, @@ -1288,11 +1292,11 @@ * be.po, ca.po, da.po, de.po, el.po, es.po, fr.po, ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, zh_CN.po, zh_TW.po: Update. -2007-08-01 Philipp Thomas <pth@suse.de> +2007-08-01 Philipp Thomas <pth@suse.de> * sv.po: Update. -2007-07-31 Philipp Thomas <pth@suse.de> +2007-07-31 Philipp Thomas <pth@suse.de> * de.po: Update. @@ -3338,11 +3342,11 @@ notice and this notice are preserved. * be.po, ca.po, da.po, de.po, el.po, es.po, fr.po, ja.po, nl.po, ru.po, sr.po, sv.po, tr.po, zh_CN.po, zh_TW.po: Update. -2007-08-01 Philipp Thomas <pth@suse.de> +2007-08-01 Philipp Thomas <pth@suse.de> * sv.po: Update. -2007-07-31 Philipp Thomas <pth@suse.de> +2007-07-31 Philipp Thomas <pth@suse.de> * de.po: Update. diff --git a/gcc/po/sv.po b/gcc/po/sv.po index 20c0d0cf3fe..1ae694a5150 100644 --- a/gcc/po/sv.po +++ b/gcc/po/sv.po @@ -17,13 +17,14 @@ # store lagra msgid "" msgstr "" -"Project-Id-Version: gcc 6.1.0\n" +"Project-Id-Version: gcc 6.2.0\n" "Report-Msgid-Bugs-To: http://gcc.gnu.org/bugs.html\n" "POT-Creation-Date: 2016-08-19 21:03+0000\n" -"PO-Revision-Date: 2016-07-15 19:05+0200\n" +"PO-Revision-Date: 2016-09-03 11:38+0200\n" "Last-Translator: Göran Uddeborg <goeran@uddeborg.se>\n" "Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n" "Language: sv\n" +"X-Bugs: Report translation errors to the Language-Team address.\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8-bit\n" @@ -5819,16 +5820,12 @@ msgid "Treat lines with 'D' in column one as comments." msgstr "Tolka rader med ”D” i kolumn ett som kommentarer." #: fortran/lang.opt:421 -#, fuzzy -#| msgid "Enable Plan 9 language extensions." msgid "Enable all DEC language extensions." -msgstr "Aktivera språkutvidgningar från Plan 9." +msgstr "Aktivera språkutvidgningar från DEC." #: fortran/lang.opt:425 -#, fuzzy -#| msgid "Enable support for the old GCC ABI." msgid "Enable support for DEC STRUCTURE/RECORD." -msgstr "Aktivera stöd för det gamla GCC-ABI:et." +msgstr "Aktivera stöd för DEC STRUCTURE/RECORD." #: fortran/lang.opt:429 msgid "Set the default double precision kind to an 8 byte wide type." @@ -10018,10 +10015,8 @@ msgid "Use UltraSPARC Visual Instruction Set version 3.0 extensions." msgstr "Utnyttja UltraSPARC-utökningarna Visual Instruction Set version 3.0." #: config/sparc/sparc.opt:78 -#, fuzzy -#| msgid "Use UltraSPARC Visual Instruction Set version 1.0 extensions." msgid "Use UltraSPARC Visual Instruction Set version 4.0 extensions." -msgstr "Utnyttja UltraSPARC-utökningarna Visual Instruction Set version 1.0." +msgstr "Utnyttja UltraSPARC-utökningarna Visual Instruction Set version 4.0." #: config/sparc/sparc.opt:82 msgid "Use UltraSPARC Compare-and-Branch extensions." @@ -10400,10 +10395,8 @@ msgid "-mlong-double-<n>\tSpecify size of long double (64 or 128 bits)." msgstr "-mlong-double-<n>\tAnge storlek på long double (64 eller 128 bitar)." #: config/rs6000/rs6000.opt:474 -#, fuzzy -#| msgid "Enable clip instructions." msgid "Enable Local Register Allocation." -msgstr "Använd clip-instruktioner." +msgstr "Aktivera lokal registerallokering." #: config/rs6000/rs6000.opt:478 msgid "Determine which dependences between insns are considered costly." @@ -10514,34 +10507,24 @@ msgid "Fuse certain operations together for better performance on power9." msgstr "Smält samman vissa operationer för bättre prestanda på power9." #: config/rs6000/rs6000.opt:610 -#, fuzzy -#| msgid "Use/do not use vector and scalar instructions added in ISA 3.0." msgid "Use/do not use certain scalar instructions added in ISA 3.0." -msgstr "Använd/använd inte vektor- och skalära instruktioner som lades till i ISA 3.0." +msgstr "Använd/använd inte vissa skalära instruktioner som lades till i ISA 3.0." #: config/rs6000/rs6000.opt:614 -#, fuzzy -#| msgid "Use/do not use vector and scalar instructions added in ISA 3.0." msgid "Use/do not use vector instructions added in ISA 3.0." -msgstr "Använd/använd inte vektor- och skalära instruktioner som lades till i ISA 3.0." +msgstr "Använd/använd inte vektorinstruktioner som lades till i ISA 3.0." #: config/rs6000/rs6000.opt:618 -#, fuzzy -#| msgid "Use/do not use vector and scalar instructions added in ISA 3.0." msgid "Use/do not use scalar register+offset memory instructions added in ISA 3.0." -msgstr "Använd/använd inte vektor- och skalära instruktioner som lades till i ISA 3.0." +msgstr "Använd/använd inte skalära register+avstånd-minnesinstruktioner som lades till i ISA 3.0." #: config/rs6000/rs6000.opt:622 -#, fuzzy -#| msgid "Use/do not use vector and scalar instructions added in ISA 3.0." msgid "Use/do not use vector register+offset memory instructions added in ISA 3.0." -msgstr "Använd/använd inte vektor- och skalära instruktioner som lades till i ISA 3.0." +msgstr "Använd/använd inte register+avstånd vektorminnesinstruktioner som lades till i ISA 3.0." #: config/rs6000/rs6000.opt:626 -#, fuzzy -#| msgid "Use/do not use vector and scalar instructions added in ISA 3.0." msgid "Use/do not use register+offset memory instructions added in ISA 3.0." -msgstr "Använd/använd inte vektor- och skalära instruktioner som lades till i ISA 3.0." +msgstr "Använd/använd inte register+avstånds-minnesinstruktioner som lades till i ISA 3.0." #: config/rs6000/rs6000.opt:630 msgid "Use/do not use the new min/max instructions defined in ISA 3.0." @@ -28590,10 +28573,9 @@ msgid "-mpower9-dform requires -mupper-regs-sf" msgstr "-mpower9-dform behöver -mupper-regs-sf" #: config/rs6000/rs6000.c:4291 -#, fuzzy, gcc-internal-format -#| msgid "-mvsx-timode requires -mvsx" +#, gcc-internal-format msgid "-mvsx-timode might need -mlra" -msgstr "-mvsx-timode behöver -mvsx" +msgstr "-mvsx-timode behöver -mlra" #: config/rs6000/rs6000.c:4316 #, gcc-internal-format @@ -28706,10 +28688,9 @@ msgid "argument 2 must be a 5-bit unsigned literal" msgstr "argument 2 måste vara en 5-bitars literal utan tecken" #: config/rs6000/rs6000.c:13350 -#, fuzzy, gcc-internal-format -#| msgid "argument 1 must be a 1-bit unsigned literal" +#, gcc-internal-format msgid "argument 1 must be a 6-bit unsigned literal" -msgstr "argument 1 måste vara en 1-bitars literal utan tecken" +msgstr "argument 1 måste vara en 6-bitars literal utan tecken" #: config/rs6000/rs6000.c:13389 #, gcc-internal-format @@ -28874,22 +28855,19 @@ msgid "Builtin function %s requires the -mpower8-vector option" msgstr "Den inbyggda funktionen %s behöver flaggan -mpower8-vector" #: config/rs6000/rs6000.c:15385 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Builtin function %s requires the -mpower8-vector option" +#, gcc-internal-format, gfc-internal-format msgid "Builtin function %s requires the -mpower9-vector option" -msgstr "Den inbyggda funktionen %s behöver flaggan -mpower8-vector" +msgstr "Den inbyggda funktionen %s behöver flaggan -mpower9-vector" #: config/rs6000/rs6000.c:15388 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Builtin function %s requires the -mpower8-vector option" +#, gcc-internal-format, gfc-internal-format msgid "Builtin function %s requires the -mpower9-misc and -m64 options" -msgstr "Den inbyggda funktionen %s behöver flaggan -mpower8-vector" +msgstr "Den inbyggda funktionen %s behöver flaggorna -mpower9-misc och -m64" #: config/rs6000/rs6000.c:15391 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Builtin function %s requires the -mpower8-vector option" +#, gcc-internal-format, gfc-internal-format msgid "Builtin function %s requires the -mpower9-misc option" -msgstr "Den inbyggda funktionen %s behöver flaggan -mpower8-vector" +msgstr "Den inbyggda funktionen %s behöver flaggan -mpower9-misc" #: config/rs6000/rs6000.c:15394 #, gcc-internal-format, gfc-internal-format @@ -28902,10 +28880,9 @@ msgid "Builtin function %s requires the -mhard-float option" msgstr "Den inbyggda funktionen %s behöver flaggan -mhard-float" #: config/rs6000/rs6000.c:15399 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Builtin function %s requires the -mhard-float option" +#, gcc-internal-format, gfc-internal-format msgid "Builtin function %s requires the -mfloat128 option" -msgstr "Den inbyggda funktionen %s behöver flaggan -mhard-float" +msgstr "Den inbyggda funktionen %s behöver flaggan -mfloat128" #: config/rs6000/rs6000.c:15401 #, gcc-internal-format, gfc-internal-format @@ -36001,10 +35978,9 @@ msgid "non-constant array initialization" msgstr "ickekonstant vektorinitierare" #: cp/constexpr.c:5198 -#, fuzzy, gcc-internal-format -#| msgid "%<delete[]%> is not a constant-expression" +#, gcc-internal-format msgid "%<goto%> is not a constant-expression" -msgstr "%<delete[]%> är inte ett konstantuttryck" +msgstr "%<goto%> är inte ett konstantuttryck" # ast = abstract syntax tree #: cp/constexpr.c:5206 @@ -37234,10 +37210,9 @@ msgid "assignment (not initialization) in declaration" msgstr "tilldelning (inte initiering) i deklaration" #: cp/decl.c:6645 -#, fuzzy, gcc-internal-format -#| msgid "invalid use of member function %qD (did you forget the %<()%> ?)" +#, gcc-internal-format msgid "initializer for %<decltype(auto) %D%> has function type (did you forget the %<()%> ?)" -msgstr "ogiltig användning av medlemsfunktionen %qD (glömde du %<()%> ?)" +msgstr "initieraren för %<decltype(auto) %qD%> har funktionstyp (glömde du %<()%> ?)" #: cp/decl.c:6746 #, gcc-internal-format @@ -41114,10 +41089,9 @@ msgid "mixing declarations and function-definitions is forbidden" msgstr "att blanda deklarationer och funktionsdefinitioner är förbjudet" #: cp/parser.c:12454 -#, fuzzy, gcc-internal-format -#| msgid "types may not be defined in exception-declarations" +#, gcc-internal-format msgid "types may not be defined in a for-range-declaration" -msgstr "typer får inte definieras i undantagsdeklarationer" +msgstr "typer får inte definieras i en for-range-deklaration" #: cp/parser.c:12508 #, gcc-internal-format @@ -42655,16 +42629,14 @@ msgid "%qD is not declared in %qD" msgstr "%qD inte deklarerad i %qD" #: cp/pt.c:2965 -#, fuzzy, gcc-internal-format -#| msgid "friend declaration %qD may not have virt-specifiers" +#, gcc-internal-format msgid "friend declaration %qD is not visible to explicit specialization" -msgstr "vändeklarationen %qD får inte ha virt-specificerare" +msgstr "vändeklarationen %qD är inte synlig för en explicit specialisering" #: cp/pt.c:2968 -#, fuzzy, gcc-internal-format -#| msgid "previous declaration here" +#, gcc-internal-format msgid "friend declaration here" -msgstr "tidigare deklaration här" +msgstr "vändeklarationen här" #: cp/pt.c:3073 #, gcc-internal-format @@ -43279,10 +43251,9 @@ msgid "template constraint failure" msgstr "mallbegränsningsfel" #: cp/pt.c:8700 -#, fuzzy, gcc-internal-format -#| msgid "%qD is not a variable template" +#, gcc-internal-format msgid "use of invalid variable template %qE" -msgstr "%qD är inte en variabelmall" +msgstr "användning av felaktig variabelmall %qE" #: cp/pt.c:9094 #, gcc-internal-format, gfc-internal-format @@ -47000,52 +46971,44 @@ msgid "DATA statement at %C is not allowed in a PURE procedure" msgstr "DATA-sats vid %C får inte förekomma i en PURE-procedur" #: fortran/decl.c:638 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Old-style initialization at %C" +#, gcc-internal-format, gfc-internal-format msgid "Empty old style initializer list at %C" -msgstr "Gammaldags initiering vid %C" +msgstr "Tom gammaldags initierarlista vid %C" #: fortran/decl.c:658 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "extra elements in scalar initializer" +#, gcc-internal-format, gfc-internal-format msgid "Repeat spec invalid in scalar initializer at %C" -msgstr "extra element i skalär initierare" +msgstr "Repetitionsspecifikationen är felaktig i skalär initierare vid %C" #: fortran/decl.c:663 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "vectorlength must be an integer constant" +#, gcc-internal-format, gfc-internal-format msgid "Repeat spec must be an integer at %C" -msgstr "vektorlängd måste vara en heltalskonstant" +msgstr "Repetitionsspecifikationen måste vara ett heltal vid %C" #: fortran/decl.c:672 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Expected alternate return label at %C" +#, gcc-internal-format, gfc-internal-format msgid "Expected data constant after repeat spec at %C" -msgstr "Alternativ returetikett förväntades vid %C" +msgstr "Datakonstant förväntades efter repetitionsspecifikation vid %C" #: fortran/decl.c:703 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Expected scalar initialization expression at %C" +#, gcc-internal-format, gfc-internal-format msgid "End of scalar initializer expected at %C" -msgstr "Ett skalärt initieringsuttryck förväntades vid %C" +msgstr "Slut på skalärt initieringsuttryck förväntades vid %C" #: fortran/decl.c:730 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "excess elements in array initializer" +#, gcc-internal-format, gfc-internal-format msgid "Not enough elements in array initializer at %C" -msgstr "överflödiga element i vektorinitierare" +msgstr "Inte tillräckligt med element i vektorinitieraren vid %C" #: fortran/decl.c:732 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "excess elements in array initializer" +#, gcc-internal-format, gfc-internal-format msgid "Too many elements in array initializer at %C" -msgstr "överflödiga element i vektorinitierare" +msgstr "För många element i vektorinitieraren vid %C" #: fortran/decl.c:751 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Syntax error in OpenMP variable list at %C" +#, gcc-internal-format, gfc-internal-format msgid "Syntax error in old style initializer list at %C" -msgstr "Syntaxfel i OpenMP-variabellista vid %C" +msgstr "Syntaxfel i gammaldags initierarlista vid %C" #: fortran/decl.c:774 #, gcc-internal-format, gfc-internal-format @@ -47203,10 +47166,9 @@ msgid "Array component of structure at %C must have explicit or deferred shape" msgstr "Vektorkomponent i post vid %C måste ha fördröjd form" #: fortran/decl.c:1867 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Component %qs at %C already declared at %L" +#, gcc-internal-format, gfc-internal-format msgid "Component '%s' at %C already declared at %L" -msgstr "Komponenten %qs vid %C är redan deklarerad vid %L" +msgstr "Komponenten ”%s” vid %C är redan deklarerad vid %L" #: fortran/decl.c:1953 #, gcc-internal-format, gfc-internal-format @@ -47289,10 +47251,9 @@ msgid "Invalid old style initialization for derived type component at %C" msgstr "Felaktig gammaldags initiering av härledd typkomponent vid %C" #: fortran/decl.c:2361 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Error in pointer initialization at %C" +#, gcc-internal-format, gfc-internal-format msgid "Syntax error in old style initialization of %s at %C" -msgstr "Fel i pekarinitiering vid %C" +msgstr "Syntaxfel i gammaldags initiering av %s vid %C" #: fortran/decl.c:2381 fortran/decl.c:5584 #, gcc-internal-format, gfc-internal-format @@ -47372,13 +47333,12 @@ msgstr "Syntaxfel i CHARACTER-deklaration vid %C" #: fortran/decl.c:2951 #, gcc-internal-format, gfc-internal-format msgid "RECORD at %C is an extension, enable it with -fdec-structure" -msgstr "" +msgstr "RECORD vid %C är en utökning, aktivera den med -fdec-structure" #: fortran/decl.c:2957 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Interface-name expected after %<(%> at %C" +#, gcc-internal-format, gfc-internal-format msgid "Structure name expected after RECORD at %C" -msgstr "Gränssnittsnamn förväntades efter %<(%> vid %C" +msgstr "Postnamn förväntades efter RECORD vid %C" #: fortran/decl.c:3000 #, gcc-internal-format, gfc-internal-format @@ -47412,10 +47372,9 @@ msgid "DOUBLE COMPLEX at %C" msgstr "DOUBLE COMPLEX vid %C" #: fortran/decl.c:3146 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Type name %qs at %C is ambiguous" +#, gcc-internal-format, gfc-internal-format msgid "Type name '%s' at %C is ambiguous" -msgstr "Typnamnet %qs vid %C är tvetydigt" +msgstr "Typnamnet ”%s” vid %C är tvetydigt" #: fortran/decl.c:3224 #, gcc-internal-format, gfc-internal-format @@ -47671,22 +47630,19 @@ msgid "PURE and IMPURE must not appear both at %C" msgstr "PURE och IMPURE får inte båda finnas vid %C" #: fortran/decl.c:4998 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Mismatch in ELEMENTAL attribute between MODULE PROCEDURE at %L and its interface in %s" +#, gcc-internal-format, gfc-internal-format msgid "ELEMENTAL prefix in MODULE PROCEDURE interface is missing at %L" -msgstr "ELEMENTAL-attribut stämmer inte mellan MODULE PROCEDURE vid %L och dess gränssnitt i %s" +msgstr "ELEMENTAL-prefixet i MODULE PROCEDURE-gränssnittet saknas vid %L" #: fortran/decl.c:5005 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "double colon in MODULE PROCEDURE statement at %L" +#, gcc-internal-format, gfc-internal-format msgid "PURE prefix in MODULE PROCEDURE interface is missing at %L" -msgstr "dubbelkolon i MODULE PROCEDURE-sats vid %L" +msgstr "PURE-prefixet i MODULE PROCEDURE-gränssnittet saknas vid %L" #: fortran/decl.c:5012 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Mismatch in RECURSIVE attribute between MODULE PROCEDURE at %L and its interface in %s" +#, gcc-internal-format, gfc-internal-format msgid "RECURSIVE prefix in MODULE PROCEDURE interface is missing at %L" -msgstr "RECURSIVE-attribut stämmer inte mellan MODULE PROCEDURE vid %L och dess gränssnitt i %s" +msgstr "RECURSIVE-prefixet i MODULE PROCEDURE-gränssnittet saknas vid %L" #: fortran/decl.c:5075 fortran/primary.c:1779 #, gcc-internal-format, gfc-internal-format @@ -47836,10 +47792,9 @@ msgid "ENTRY statement at %C cannot appear within an INTERFACE" msgstr "ENTRY-sats vid %C kan inte förekomma inuti ett INTERFACE" #: fortran/decl.c:6114 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "ENTRY statement at %C cannot appear within a SELECT block" +#, gcc-internal-format, gfc-internal-format msgid "ENTRY statement at %C cannot appear within a STRUCTURE block" -msgstr "ENTRY-sats vid %C kan inte förekomma inuti ett SELECT-block" +msgstr "ENTRY-sats vid %C kan inte förekomma inuti ett STRUCTURE-block" #: fortran/decl.c:6118 #, gcc-internal-format, gfc-internal-format @@ -48220,48 +48175,42 @@ msgstr "ABSTRACT typ vid %C" #: fortran/decl.c:8391 #, gcc-internal-format, gfc-internal-format msgid "Failed to create structure type '%s' at %C" -msgstr "" +msgstr "Misslyckades att skapa en post av typen ”%s” vid %C" #: fortran/decl.c:8397 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Derived type definition of %qs at %C has already been defined" +#, gcc-internal-format, gfc-internal-format msgid "Type definition of '%s' at %C was already defined at %L" -msgstr "Härledd typdefinition %qs vid %C har redan definierats" +msgstr "Typdefinitionen av ”%s” vid %C definierades redan vid %L" #: fortran/decl.c:8444 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Junk after ASSOCIATE statement at %C" +#, gcc-internal-format, gfc-internal-format msgid "Junk after MAP statement at %C" -msgstr "Skräp efter ASSOCIATE-sats vid %C" +msgstr "Skräp efter MAP-sats vid %C" #: fortran/decl.c:8477 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Junk after ASSOCIATE statement at %C" +#, gcc-internal-format, gfc-internal-format msgid "Junk after UNION statement at %C" -msgstr "Skräp efter ASSOCIATE-sats vid %C" +msgstr "Skräp efter UNION-sats vid %C" #: fortran/decl.c:8512 #, gcc-internal-format, gfc-internal-format msgid "STRUCTURE at %C is a DEC extension, enable with -fdec-structure" -msgstr "" +msgstr "STRUCTURE vid %C är en DEC-utökning, aktivera den med -fdec-structure" #: fortran/decl.c:8525 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Unexpected junk after function declaration at %C" +#, gcc-internal-format, gfc-internal-format msgid "Structure name expected in non-nested structure declaration at %C" -msgstr "Oväntat skräp efter funktionsdeklaration vid %C" +msgstr "Postnamn förväntades i icke nästad postdeklaration vid %C" #: fortran/decl.c:8543 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Junk after ASSOCIATE statement at %C" +#, gcc-internal-format, gfc-internal-format msgid "Junk after non-nested STRUCTURE statement at %C" -msgstr "Skräp efter ASSOCIATE-sats vid %C" +msgstr "Skräp efter icke nästad STRUCTURE-sats vid %C" #: fortran/decl.c:8550 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Type name %qs at %C cannot be the same as an intrinsic type" +#, gcc-internal-format, gfc-internal-format msgid "Structure name '%s' at %C cannot be the same as an intrinsic type" -msgstr "Typnamnet %qs vid %C kan inte vara samma som en inbyggd typ" +msgstr "Postnamnet ”%s” vid %C får inte vara samma som en inbyggd typ" #: fortran/decl.c:8611 #, gcc-internal-format, gfc-internal-format @@ -50497,15 +50446,14 @@ msgid "gfc_op2string(): Bad code" msgstr "gfc_op2string(): Felaktig kod" #: fortran/match.c:186 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Expected structure component name at %C" +#, gcc-internal-format, gfc-internal-format msgid "Expected structure component or operator name after '.' at %C" -msgstr "Postkomponentnamn förväntades vid %C" +msgstr "Postkomponentnamn eller operatornamn förväntades efter ”.” vid %C" #: fortran/match.c:218 #, gcc-internal-format, gfc-internal-format msgid "'%s' is neither a defined operator nor a structure component in dotted string at %C" -msgstr "" +msgstr "”%s” är varken en definierad operator eller en postkomponent i en punktsträng vid %C" #: fortran/match.c:288 #, gcc-internal-format @@ -51602,10 +51550,9 @@ msgid "Syntax error in OpenACC expression list at %C" msgstr "Syntaxfel i OpenACC-uttryckslista vid %C" #: fortran/openmp.c:457 -#, fuzzy, gcc-internal-format -#| msgid "incorrectly nested OpenACC loop parallelism" +#, gcc-internal-format msgid "Unexpected OpenACC parallelism." -msgstr "felaktigt nästad OpenACC-slingeparallellism" +msgstr "Oväntad OpenACC-parallellism" #: fortran/openmp.c:489 #, gcc-internal-format, gfc-internal-format @@ -52728,19 +52675,17 @@ msgstr "Icke co-vektorkomponenten %s vid %L av typen EVENT_TYPE eller med en und #: fortran/parse.c:2968 #, gcc-internal-format, gfc-internal-format msgid "failed to create map component '%s'" -msgstr "" +msgstr "misslyckades att skapa en avbildningskomponent ”%s”" #: fortran/parse.c:3001 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "failed to find class '%s'" +#, gcc-internal-format, gfc-internal-format msgid "failed to create union component '%s'" -msgstr "kunde inte hitta klassen ”%s”" +msgstr "kunde inte hitta skapa unionkomponenten ”%s”" #: fortran/parse.c:3056 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "Syntax error in data declaration at %C" +#, gcc-internal-format, gfc-internal-format msgid "Syntax error in nested structure declaration at %C" -msgstr "Syntaxfel i datadeklaration vid %C" +msgstr "Syntaxfel i nästad postdeklaration vid %C" #: fortran/parse.c:3143 #, gcc-internal-format, gfc-internal-format @@ -53251,10 +53196,9 @@ msgid "Symbol %qs at %C has no IMPLICIT type" msgstr "Symbolen %qs vid %C har ingen IMPLICIT-typ" #: fortran/primary.c:1994 -#, fuzzy, gcc-internal-format -#| msgid "Unexpected %<%%%> for nonderived-type variable %qs at %C" +#, gcc-internal-format msgid "Unexpected %<%c%> for nonderived-type variable %qs at %C" -msgstr "Oväntat %<%%%> för variabel med icke härled typ %qs vid %C" +msgstr "Oväntat %<%c%> för variabel med icke härled typ %qs vid %C" #: fortran/primary.c:2012 #, gcc-internal-format, gfc-internal-format @@ -53372,10 +53316,9 @@ msgid "Symbol at %C is not appropriate for an expression" msgstr "Symbol vid %C passar inte som uttryck" #: fortran/primary.c:3342 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "The name %qs cannot be used as a defined operator at %C" +#, gcc-internal-format, gfc-internal-format msgid "Derived type '%s' cannot be used as a variable at %C" -msgstr "Namnet %qs får inte användas som en definierad operator vid %C" +msgstr "Den härledda typen ”%s” får inte användas som en variabel vid %C" #: fortran/primary.c:3383 #, gcc-internal-format, gfc-internal-format @@ -55268,10 +55211,9 @@ msgid "Component %qs with CLASS at %L must be allocatable or pointer" msgstr "Procedur %qs med CLASS vid %L måste vara allokerbar eller en pekare" #: fortran/resolve.c:13339 -#, fuzzy, gcc-internal-format, gfc-internal-format -#| msgid "non-constant initialization expression at %L" +#, gcc-internal-format, gfc-internal-format msgid "Conflicting initializers in union at %L and %L" -msgstr "ej konstant initieringsuttryck vid %L" +msgstr "Initierare som står i konflikt i unionen vid %L och %L" #: fortran/resolve.c:13383 #, gcc-internal-format @@ -58362,18 +58304,3 @@ msgstr "%<-fobjc-sjlj-exceptions%> ignoreras för %<-fnext-runtime%> när %<-fob #, gcc-internal-format msgid "creating selector for nonexistent method %qE" msgstr "skapar väljare för icke existerande metod %qE" - -#~ msgid "Clause not supported yet" -#~ msgstr "Klausulen stödjs inte än" - -#~ msgid "internal error: builtin function %s had no type" -#~ msgstr "internt fel: inbyggd funktion %s har ingen typ" - -#~ msgid "%qD is not a constant" -#~ msgstr "%qD är inte en konstant" - -#~ msgid "constraints for %qD not satisfied" -#~ msgstr "begränsningarna för %qD är inte uppfyllda" - -#~ msgid "Unexpected junk in !$ACC WAIT at %C" -#~ msgstr "Oväntat skräp efter !$ACC WAIT vid %C" diff --git a/gcc/predict.c b/gcc/predict.c index 035a0c2e7d6..b3d169770c9 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -3723,7 +3723,7 @@ force_edge_cold (edge e, bool impossible) int prob_scale = REG_BR_PROB_BASE; /* If edge is already improbably or cold, just return. */ - if (e->probability <= impossible ? PROB_VERY_UNLIKELY : 0 + if (e->probability <= (impossible ? PROB_VERY_UNLIKELY : 0) && (!impossible || !e->count)) return; FOR_EACH_EDGE (e2, ei, e->src->succs) diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 325263efd6a..a39815ea511 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -30,6 +30,8 @@ along with GCC; see the file COPYING3. If not see #include <iconv.h> #endif +static void pp_quoted_string (pretty_printer *, const char *, size_t = -1); + /* Overwrite the given location/range within this text_info's rich_location. For use e.g. when implementing "+" in client format decoders. */ @@ -555,8 +557,20 @@ pp_format (pretty_printer *pp, text_info *text) break; case 'c': - pp_character (pp, va_arg (*text->args_ptr, int)); - break; + { + /* When quoting, print alphanumeric, punctuation, and the space + character unchanged, and all others in hexadecimal with the + "\x" prefix. Otherwise print them all unchanged. */ + int chr = va_arg (*text->args_ptr, int); + if (ISPRINT (chr) || !quote) + pp_character (pp, chr); + else + { + const char str [2] = { chr, '\0' }; + pp_quoted_string (pp, str, 1); + } + break; + } case 'd': case 'i': @@ -577,7 +591,10 @@ pp_format (pretty_printer *pp, text_info *text) break; case 's': - pp_string (pp, va_arg (*text->args_ptr, const char *)); + if (quote) + pp_quoted_string (pp, va_arg (*text->args_ptr, const char *)); + else + pp_string (pp, va_arg (*text->args_ptr, const char *)); break; case 'p': @@ -939,6 +956,41 @@ pp_string (pretty_printer *pp, const char *str) pp_maybe_wrap_text (pp, str, str + strlen (str)); } +/* Append the leading N characters of STRING to the output area of + PRETTY-PRINTER, quoting in hexadecimal non-printable characters. + Setting N = -1 is as if N were set to strlen (STRING). The STRING + may be line-wrapped if in appropriate mode. */ +static void +pp_quoted_string (pretty_printer *pp, const char *str, size_t n /* = -1 */) +{ + gcc_checking_assert (str); + + const char *last = str; + const char *ps; + + /* Compute the length if not specified. */ + if (n == (size_t) -1) + n = strlen (str); + + for (ps = str; n; ++ps, --n) + { + if (ISPRINT (*ps)) + continue; + + if (last < ps) + pp_maybe_wrap_text (pp, last, ps - 1); + + /* Append the hexadecimal value of the character. Allocate a buffer + that's large enough for a 32-bit char plus the hex prefix. */ + char buf [11]; + int n = sprintf (buf, "\\x%02x", (unsigned char)*ps); + pp_maybe_wrap_text (pp, buf, buf + n); + last = ps + 1; + } + + pp_maybe_wrap_text (pp, last, ps); +} + /* Maybe print out a whitespace if needed. */ void diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 7546f19e33e..e55b6bd6fb6 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -694,8 +694,10 @@ print_node (FILE *file, const char *prefix, tree node, int indent) i = 0; FOR_EACH_CALL_EXPR_ARG (arg, iter, node) { - char temp[10]; - sprintf (temp, "arg %d", i); + /* Buffer big enough to format a 32-bit UINT_MAX into, plus + the text. */ + char temp[15]; + sprintf (temp, "arg %u", i); print_node (file, temp, arg, indent + 4); i++; } @@ -706,7 +708,9 @@ print_node (FILE *file, const char *prefix, tree node, int indent) for (i = 0; i < len; i++) { - char temp[10]; + /* Buffer big enough to format a 32-bit UINT_MAX into, plus + the text. */ + char temp[15]; sprintf (temp, "arg %d", i); print_node (file, temp, TREE_OPERAND (node, i), indent + 4); @@ -824,7 +828,9 @@ print_node (FILE *file, const char *prefix, tree node, int indent) for (i = 0; i < len; i++) if (TREE_VEC_ELT (node, i)) { - char temp[10]; + /* Buffer big enough to format a 32-bit UINT_MAX into, plus + the text. */ + char temp[15]; sprintf (temp, "elt %d", i); print_node (file, temp, TREE_VEC_ELT (node, i), indent + 4); } diff --git a/gcc/recog.c b/gcc/recog.c index 19ab5744dd0..6a95d7f9402 100644 --- a/gcc/recog.c +++ b/gcc/recog.c @@ -3901,17 +3901,6 @@ make_pass_split_all_insns (gcc::context *ctxt) return new pass_split_all_insns (ctxt); } -static unsigned int -rest_of_handle_split_after_reload (void) -{ - /* If optimizing, then go ahead and split insns now. */ -#ifndef STACK_REGS - if (optimize > 0) -#endif - split_all_insns (); - return 0; -} - namespace { const pass_data pass_data_split_after_reload = @@ -3935,9 +3924,23 @@ public: {} /* opt_pass methods: */ + virtual bool gate (function *) + { + /* If optimizing, then go ahead and split insns now. */ + if (optimize > 0) + return true; + +#ifdef STACK_REGS + return true; +#else + return false; +#endif + } + virtual unsigned int execute (function *) { - return rest_of_handle_split_after_reload (); + split_all_insns (); + return 0; } }; // class pass_split_after_reload diff --git a/gcc/reload1.c b/gcc/reload1.c index 2a9a562cbbd..da53cfa5f95 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -286,15 +286,7 @@ static const struct elim_table_1 const int to; } reg_eliminate_1[] = -/* If a set of eliminable registers was specified, define the table from it. - Otherwise, default to the normal case of the frame pointer being - replaced by the stack pointer. */ - -#ifdef ELIMINABLE_REGS ELIMINABLE_REGS; -#else - {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}; -#endif #define NUM_ELIMINABLE_REGS ARRAY_SIZE (reg_eliminate_1) @@ -3823,26 +3815,17 @@ static bool verify_initial_elim_offsets (void) { HOST_WIDE_INT t; + struct elim_table *ep; if (!num_eliminable) return true; -#ifdef ELIMINABLE_REGS - { - struct elim_table *ep; - - for (ep = reg_eliminate; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++) - { - INITIAL_ELIMINATION_OFFSET (ep->from, ep->to, t); - if (t != ep->initial_offset) - return false; - } - } -#else - INITIAL_FRAME_POINTER_OFFSET (t); - if (t != reg_eliminate[0].initial_offset) - return false; -#endif + for (ep = reg_eliminate; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++) + { + INITIAL_ELIMINATION_OFFSET (ep->from, ep->to, t); + if (t != ep->initial_offset) + return false; + } return true; } @@ -3854,16 +3837,11 @@ set_initial_elim_offsets (void) { struct elim_table *ep = reg_eliminate; -#ifdef ELIMINABLE_REGS for (; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++) { INITIAL_ELIMINATION_OFFSET (ep->from, ep->to, ep->initial_offset); ep->previous_offset = ep->offset = ep->initial_offset; } -#else - INITIAL_FRAME_POINTER_OFFSET (ep->initial_offset); - ep->previous_offset = ep->offset = ep->initial_offset; -#endif num_not_at_initial_offset = 0; } @@ -3935,9 +3913,7 @@ update_eliminables (HARD_REG_SET *pset) for (ep = reg_eliminate; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++) if ((ep->from == HARD_FRAME_POINTER_REGNUM && targetm.frame_pointer_required ()) -#ifdef ELIMINABLE_REGS || ! targetm.can_eliminate (ep->from, ep->to) -#endif ) ep->can_eliminate = 0; @@ -4058,16 +4034,13 @@ static void init_elim_table (void) { struct elim_table *ep; -#ifdef ELIMINABLE_REGS const struct elim_table_1 *ep1; -#endif if (!reg_eliminate) reg_eliminate = XCNEWVEC (struct elim_table, NUM_ELIMINABLE_REGS); num_eliminable = 0; -#ifdef ELIMINABLE_REGS for (ep = reg_eliminate, ep1 = reg_eliminate_1; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; ep++, ep1++) { @@ -4080,12 +4053,6 @@ init_elim_table (void) && (! SUPPORTS_STACK_ALIGNMENT || ! stack_realign_fp))); } -#else - reg_eliminate[0].from = reg_eliminate_1[0].from; - reg_eliminate[0].to = reg_eliminate_1[0].to; - reg_eliminate[0].can_eliminate = reg_eliminate[0].can_eliminate_previous - = ! frame_pointer_needed; -#endif /* Count the number of eliminable registers and build the FROM and TO REG rtx's. Note that code in gen_rtx_REG will cause, e.g., diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 6470c4377ea..470c143fcf2 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -345,7 +345,6 @@ rtx_varies_p (const_rtx x, bool for_alias) static HOST_WIDE_INT get_initial_register_offset (int from, int to) { -#ifdef ELIMINABLE_REGS static const struct elim_table_t { const int from; @@ -448,33 +447,6 @@ get_initial_register_offset (int from, int to) return get_initial_register_offset (from, FRAME_POINTER_REGNUM); else return 0; - -#else - HOST_WIDE_INT offset; - - if (to == from) - return 0; - - if (reload_completed) - { - INITIAL_FRAME_POINTER_OFFSET (offset); - } - else - { - offset = crtl->outgoing_args_size + get_frame_size (); -#if !STACK_GROWS_DOWNWARD - offset = - offset; -#endif - } - - if (to == STACK_POINTER_REGNUM) - return offset; - else if (from == STACK_POINTER_REGNUM) - return - offset; - else - return 0; - -#endif } /* Return nonzero if the use of X+OFFSET as an address in a MEM with SIZE @@ -4511,8 +4483,8 @@ nonzero_bits1 (const_rtx x, machine_mode mode, const_rtx known_x, int sign_index = GET_MODE_PRECISION (GET_MODE (x)) - 1; int width0 = floor_log2 (nz0) + 1; int width1 = floor_log2 (nz1) + 1; - int low0 = floor_log2 (nz0 & -nz0); - int low1 = floor_log2 (nz1 & -nz1); + int low0 = ctz_or_zero (nz0); + int low1 = ctz_or_zero (nz1); unsigned HOST_WIDE_INT op0_maybe_minusp = nz0 & (HOST_WIDE_INT_1U << sign_index); unsigned HOST_WIDE_INT op1_maybe_minusp diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 26604539ca5..eeb4cd00de0 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -33,6 +33,9 @@ along with GCC; see the file COPYING3. If not see #include "ubsan.h" #include "params.h" #include "tree-hash-traits.h" +#include "gimple-ssa.h" +#include "tree-phinodes.h" +#include "ssa-iterators.h" /* This is used to carry information about basic blocks. It is @@ -538,6 +541,28 @@ sanopt_optimize_walker (basic_block bb, struct sanopt_ctx *ctx) if (asan_check_optimize && !nonfreeing_call_p (stmt)) info->freeing_call_events++; + /* If __asan_before_dynamic_init ("module"); is followed by + __asan_after_dynamic_init (); without intervening memory loads/stores, + there is nothing to guard, so optimize both away. */ + if (asan_check_optimize + && gimple_call_builtin_p (stmt, BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT)) + { + use_operand_p use; + gimple *use_stmt; + if (single_imm_use (gimple_vdef (stmt), &use, &use_stmt)) + { + if (is_gimple_call (use_stmt) + && gimple_call_builtin_p (use_stmt, + BUILT_IN_ASAN_AFTER_DYNAMIC_INIT)) + { + unlink_stmt_vdef (use_stmt); + gimple_stmt_iterator gsi2 = gsi_for_stmt (use_stmt); + gsi_remove (&gsi2, true); + remove = true; + } + } + } + if (gimple_call_internal_p (stmt)) switch (gimple_call_internal_fn (stmt)) { diff --git a/gcc/sched-int.h b/gcc/sched-int.h index de5d3269266..b4a7f925287 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -1624,10 +1624,11 @@ sd_iterator_cond (sd_iterator_def *it_ptr, dep_t *dep_ptr) sd_next_list (it_ptr->insn, &it_ptr->types, &list, &it_ptr->resolved_p); - it_ptr->linkp = &DEPS_LIST_FIRST (list); - if (list) - continue; + { + it_ptr->linkp = &DEPS_LIST_FIRST (list); + continue; + } } *dep_ptr = NULL; diff --git a/gcc/selftest-run-tests.c b/gcc/selftest-run-tests.c index 6453e314982..d9d3ea13ab6 100644 --- a/gcc/selftest-run-tests.c +++ b/gcc/selftest-run-tests.c @@ -56,6 +56,7 @@ selftest::run_tests () ggc_tests_c_tests (); sreal_c_tests (); fibonacci_heap_c_tests (); + typed_splay_tree_c_tests (); /* Mid-level data structures. */ input_c_tests (); @@ -67,6 +68,7 @@ selftest::run_tests () rely on. */ diagnostic_show_locus_c_tests (); diagnostic_c_tests (); + edit_context_c_tests (); fold_const_c_tests (); spellcheck_c_tests (); spellcheck_tree_c_tests (); diff --git a/gcc/selftest.h b/gcc/selftest.h index 47d73503370..9b6fa952f6b 100644 --- a/gcc/selftest.h +++ b/gcc/selftest.h @@ -151,6 +151,7 @@ for_each_line_table_case (void (*testcase) (const line_table_case &)); extern void bitmap_c_tests (); extern void diagnostic_c_tests (); extern void diagnostic_show_locus_c_tests (); +extern void edit_context_c_tests (); extern void et_forest_c_tests (); extern void fold_const_c_tests (); extern void fibonacci_heap_c_tests (); @@ -166,6 +167,7 @@ extern void selftest_c_tests (); extern void spellcheck_c_tests (); extern void spellcheck_tree_c_tests (); extern void sreal_c_tests (); +extern void typed_splay_tree_c_tests (); extern void tree_c_tests (); extern void tree_cfg_c_tests (); extern void vec_c_tests (); diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index cf7171430f9..07eac874908 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1169,14 +1169,12 @@ place_field (record_layout_info rli, tree field) /* Work out the known alignment so far. Note that A & (-A) is the value of the least-significant bit in A that is one. */ if (! integer_zerop (rli->bitpos)) - known_align = (tree_to_uhwi (rli->bitpos) - & - tree_to_uhwi (rli->bitpos)); + known_align = least_bit_hwi (tree_to_uhwi (rli->bitpos)); else if (integer_zerop (rli->offset)) known_align = 0; else if (tree_fits_uhwi_p (rli->offset)) known_align = (BITS_PER_UNIT - * (tree_to_uhwi (rli->offset) - & - tree_to_uhwi (rli->offset))); + * least_bit_hwi (tree_to_uhwi (rli->offset))); else known_align = rli->offset_align; @@ -1479,14 +1477,12 @@ place_field (record_layout_info rli, tree field) approximate this by seeing if its position changed), lay out the field again; perhaps we can use an integral mode for it now. */ if (! integer_zerop (DECL_FIELD_BIT_OFFSET (field))) - actual_align = (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field)) - & - tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))); + actual_align = least_bit_hwi (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))); else if (integer_zerop (DECL_FIELD_OFFSET (field))) actual_align = MAX (BIGGEST_ALIGNMENT, rli->record_align); else if (tree_fits_uhwi_p (DECL_FIELD_OFFSET (field))) actual_align = (BITS_PER_UNIT - * (tree_to_uhwi (DECL_FIELD_OFFSET (field)) - & - tree_to_uhwi (DECL_FIELD_OFFSET (field)))); + * least_bit_hwi (tree_to_uhwi (DECL_FIELD_OFFSET (field)))); else actual_align = DECL_OFFSET_ALIGN (field); /* ACTUAL_ALIGN is still the actual alignment *within the record* . diff --git a/gcc/substring-locations.c b/gcc/substring-locations.c new file mode 100644 index 00000000000..60bf1b09417 --- /dev/null +++ b/gcc/substring-locations.c @@ -0,0 +1,195 @@ +/* Source locations within string literals. + Copyright (C) 2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "diagnostic.h" +#include "cpplib.h" +#include "tree.h" +#include "langhooks.h" +#include "substring-locations.h" + +/* Emit a warning governed by option OPT, using GMSGID as the format + string and AP as its arguments. + + Attempt to obtain precise location information within a string + literal from FMT_LOC. + + Case 1: if substring location is available, and is within the range of + the format string itself, the primary location of the + diagnostic is the substring range obtained from FMT_LOC, with the + caret at the *end* of the substring range. + + For example: + + test.c:90:10: warning: problem with '%i' here [-Wformat=] + printf ("hello %i", msg); + ~^ + + Case 2: if the substring location is available, but is not within + the range of the format string, the primary location is that of the + format string, and an note is emitted showing the substring location. + + For example: + test.c:90:10: warning: problem with '%i' here [-Wformat=] + printf("hello " INT_FMT " world", msg); + ^~~~~~~~~~~~~~~~~~~~~~~~~ + test.c:19: note: format string is defined here + #define INT_FMT "%i" + ~^ + + Case 3: if precise substring information is unavailable, the primary + location is that of the whole string passed to FMT_LOC's constructor. + For example: + + test.c:90:10: warning: problem with '%i' here [-Wformat=] + printf(fmt, msg); + ^~~ + + For each of cases 1-3, if param_range is non-NULL, then it is used + as a secondary range within the warning. For example, here it + is used with case 1: + + test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=] + printf ("foo %s bar", long_i + long_j); + ~^ ~~~~~~~~~~~~~~~ + + and here with case 2: + + test.c:90:16: warning: '%s' here but arg 2 has 'long' type [-Wformat=] + printf ("foo " STR_FMT " bar", long_i + long_j); + ^~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ + test.c:89:16: note: format string is defined here + #define STR_FMT "%s" + ~^ + + and with case 3: + + test.c:90:10: warning: '%i' here, but arg 2 is "const char *' [-Wformat=] + printf(fmt, msg); + ^~~ ~~~ + + If CORRECTED_SUBSTRING is non-NULL, use it for cases 1 and 2 to provide + a fix-it hint, suggesting that it should replace the text within the + substring range. For example: + + test.c:90:10: warning: problem with '%i' here [-Wformat=] + printf ("hello %i", msg); + ~^ + %s + + Return true if a warning was emitted, false otherwise. */ + +ATTRIBUTE_GCC_DIAG (5,0) +bool +format_warning_va (const substring_loc &fmt_loc, + const source_range *param_range, + const char *corrected_substring, + int opt, const char *gmsgid, va_list *ap) +{ + bool substring_within_range = false; + location_t primary_loc; + location_t fmt_substring_loc = UNKNOWN_LOCATION; + source_range fmt_loc_range + = get_range_from_loc (line_table, fmt_loc.get_fmt_string_loc ()); + const char *err = fmt_loc.get_location (&fmt_substring_loc); + source_range fmt_substring_range + = get_range_from_loc (line_table, fmt_substring_loc); + if (err) + /* Case 3: unable to get substring location. */ + primary_loc = fmt_loc.get_fmt_string_loc (); + else + { + if (fmt_substring_range.m_start >= fmt_loc_range.m_start + && fmt_substring_range.m_finish <= fmt_loc_range.m_finish) + /* Case 1. */ + { + substring_within_range = true; + primary_loc = fmt_substring_loc; + } + else + /* Case 2. */ + { + substring_within_range = false; + primary_loc = fmt_loc.get_fmt_string_loc (); + } + } + + rich_location richloc (line_table, primary_loc); + + if (param_range) + { + location_t param_loc = make_location (param_range->m_start, + param_range->m_start, + param_range->m_finish); + richloc.add_range (param_loc, false); + } + + if (!err && corrected_substring && substring_within_range) + richloc.add_fixit_replace (fmt_substring_range, corrected_substring); + + diagnostic_info diagnostic; + diagnostic_set_info (&diagnostic, gmsgid, ap, &richloc, DK_WARNING); + diagnostic.option_index = opt; + bool warned = report_diagnostic (&diagnostic); + + if (!err && fmt_substring_loc && !substring_within_range) + /* Case 2. */ + if (warned) + { + rich_location substring_richloc (line_table, fmt_substring_loc); + if (corrected_substring) + substring_richloc.add_fixit_replace (fmt_substring_range, + corrected_substring); + inform_at_rich_loc (&substring_richloc, + "format string is defined here"); + } + + return warned; +} + +/* Variadic call to format_warning_va. */ + +bool +format_warning_at_substring (const substring_loc &fmt_loc, + const source_range *param_range, + const char *corrected_substring, + int opt, const char *gmsgid, ...) +{ + va_list ap; + va_start (ap, gmsgid); + bool warned = format_warning_va (fmt_loc, param_range, corrected_substring, + opt, gmsgid, &ap); + va_end (ap); + + return warned; +} + +/* Attempt to determine the source location of the substring. + If successful, return NULL and write the source location to *OUT_LOC. + Otherwise return an error message. Error messages are intended + for GCC developers (to help debugging) rather than for end-users. */ + +const char * +substring_loc::get_location (location_t *out_loc) const +{ + gcc_assert (out_loc); + return lang_hooks.get_substring_location (*this, out_loc); +} diff --git a/gcc/substring-locations.h b/gcc/substring-locations.h index f839c745635..f8788c9b3c4 100644 --- a/gcc/substring-locations.h +++ b/gcc/substring-locations.h @@ -20,6 +20,77 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_SUBSTRING_LOCATIONS_H #define GCC_SUBSTRING_LOCATIONS_H +/* The substring_loc class encapsulates information on the source location + of a range of characters within a STRING_CST. + + If needed by a diagnostic, the actual location_t of the substring_loc + can be calculated by calling its get_location method. This calls a + langhook, since this is inherently frontend-specific. For the C family + of frontends, it calls back into libcpp to reparse the strings. This + gets the location information "on demand", rather than storing the + location information in the initial lex for every string. Thus the + substring_loc can also be thought of as a deferred call into libcpp, + to allow the non-trivial work of reparsing the string to be delayed + until we actually need it (to emit a diagnostic for a particular range + of characters). + + substring_loc::get_location returns NULL if it succeeds, or an + error message if it fails. Error messages are intended for GCC + developers (to help debugging) rather than for end-users. + + The easiest way to use a substring_loc is via the format_warning_* APIs, + which gracefully handle failure of substring_loc::get_location by using + the location of the string as a whole if substring-information is + unavailable. */ + +class substring_loc +{ + public: + /* Constructor. FMT_STRING_LOC is the location of the string as + a whole. STRING_TYPE is the type of the string. It should be an + ARRAY_TYPE of INTEGER_TYPE, or a POINTER_TYPE to such an ARRAY_TYPE. + CARET_IDX, START_IDX, and END_IDX are offsets from the start + of the string data. */ + substring_loc (location_t fmt_string_loc, tree string_type, + int caret_idx, int start_idx, int end_idx) + : m_fmt_string_loc (fmt_string_loc), m_string_type (string_type), + m_caret_idx (caret_idx), m_start_idx (start_idx), m_end_idx (end_idx) {} + + void set_caret_index (int caret_idx) { m_caret_idx = caret_idx; } + + const char *get_location (location_t *out_loc) const; + + location_t get_fmt_string_loc () const { return m_fmt_string_loc; } + tree get_string_type () const { return m_string_type; } + int get_caret_idx () const { return m_caret_idx; } + int get_start_idx () const { return m_start_idx; } + int get_end_idx () const { return m_end_idx; } + + private: + location_t m_fmt_string_loc; + tree m_string_type; + int m_caret_idx; + int m_start_idx; + int m_end_idx; +}; + +/* Functions for emitting a warning about a format string. */ + +extern bool format_warning_va (const substring_loc &fmt_loc, + const source_range *param_range, + const char *corrected_substring, + int opt, const char *gmsgid, va_list *ap) + ATTRIBUTE_GCC_DIAG (5,0); + +extern bool format_warning_at_substring (const substring_loc &fmt_loc, + const source_range *param_range, + const char *corrected_substring, + int opt, const char *gmsgid, ...) + ATTRIBUTE_GCC_DIAG (5,0); + +/* Implementation detail, for use when implementing + LANG_HOOKS_GET_SUBSTRING_LOCATION. */ + extern const char *get_source_location_for_substring (cpp_reader *pfile, string_concat_db *concats, location_t strloc, diff --git a/gcc/target.def b/gcc/target.def index 8d506912063..a4e4cbb6645 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4929,8 +4929,8 @@ DEFHOOK (lra_p, "A target hook which returns true if we use LRA instead of reload pass.\ \ - The default version of this target hook returns always false, but new\ - ports should use LRA.", + The default version of this target hook returns always true. New ports\ + should use LRA, and existing ports are encouraged to convert.", bool, (void), default_lra_p) @@ -5289,7 +5289,7 @@ five otherwise. This is best for most machines.", unsigned int, (void), default_case_values_threshold) -/* Retutn true if a function must have and use a frame pointer. */ +/* Return true if a function must have and use a frame pointer. */ DEFHOOK (frame_pointer_required, "This target hook should return @code{true} if a function must have and use\n\ @@ -5306,7 +5306,7 @@ pointer.\n\ In certain cases, the compiler does not know how to produce valid code\n\ without a frame pointer. The compiler recognizes those cases and\n\ automatically gives the function a frame pointer regardless of what\n\ -@code{TARGET_FRAME_POINTER_REQUIRED} returns. You don't need to worry about\n\ +@code{targetm.frame_pointer_required} returns. You don't need to worry about\n\ them.\n\ \n\ In a function that does not require a frame pointer, the frame pointer\n\ @@ -5321,11 +5321,10 @@ Default return value is @code{false}.", from-reg with register number to-reg. */ DEFHOOK (can_eliminate, - "This target hook should returns @code{true} if the compiler is allowed to\n\ + "This target hook should return @code{true} if the compiler is allowed to\n\ try to replace register number @var{from_reg} with register number\n\ -@var{to_reg}. This target hook need only be defined if @code{ELIMINABLE_REGS}\n\ -is defined, and will usually be @code{true}, since most of the cases\n\ -preventing register elimination are things that the compiler already\n\ +@var{to_reg}. This target hook will usually be @code{true}, since most of the\n\ +cases preventing register elimination are things that the compiler already\n\ knows about.\n\ \n\ Default return value is @code{true}.", @@ -5341,7 +5340,7 @@ DEFHOOK @code{fixed_regs}, @code{call_used_regs}, @code{global_regs},\n\ @code{reg_names}, and @code{reg_class_contents}, to take into account\n\ any dependence of these register sets on target flags. The first three\n\ -of these are of type @code{char []} (interpreted as Boolean vectors).\n\ +of these are of type @code{char []} (interpreted as boolean vectors).\n\ @code{global_regs} is a @code{const char *[]}, and\n\ @code{reg_class_contents} is a @code{HARD_REG_SET}. Before the macro is\n\ called, @code{fixed_regs}, @code{call_used_regs},\n\ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 97856face38..67cc53a2641 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -995,7 +995,7 @@ default_ira_change_pseudo_allocno_class (int regno ATTRIBUTE_UNUSED, extern bool default_lra_p (void) { - return false; + return true; } int diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 864215d9dc4..6edcc7d5f27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,501 @@ +2016-09-19 Fritz Reese <fritzoreese@gmail.com> + + PR fortran/77584 + * gfortran.dg/dec_structure_15.f90: New testcase. + +2016-09-19 Richard Biener <rguenther@suse.de> + + PR middle-end/77605 + * gcc.dg/torture/pr77605.c: New testcase. + +2016-09-18 Louis Krupp <louis.krupp@zoho.com> + + * gfortran.dg/pr68078.f90: XFAIL run on Darwin + +2016-09-17 Jan Hubicka <hubicka@ucw.cz> + + * g++.dg/predict-loop-exit-1.C: Disable early jump threading. + * g++.dg/predict-loop-exit-2.C: Disable early jump threading. + * g++.dg/predict-loop-exit-3.C: Disable early jump threading. + * gcc.dg/tree-ssa/pr69196-1.c: Disable early jump threading. + * gcc.dg/tree-ssa/vrp01.c: Disable early jump threading. + * gcc.dg/tree-ssa/ssa-dom-thread-2b.c: Disable early jump threading. + * gcc.dg/tree-ssa/pr68198.c: Scan ethread dump. + * gcc.dg/tree-ssa/ssa-thread-13.c: Scan ethread dump. + * gcc.dg/tree-ssa/vrp56.c: Scan ethread dump. + * gcc.dg/tree-ssa/vrp92.c: Scan ethread dump. + * gcc.dg/uninit-15.c: Swap xfailed and non-xfailed alternative. + +2016-09-18 Kirill Yukhin <kirill.yukhin@gmaile.com> + + * gcc.target/i386/pr68633.c: Fix expected result. + +2016-09-17 Louis Krupp <louis.krupp@gmail.com> + + PR fortran/68078 + * gfortran.dg/pr68078.f90: New test. + * gfortran.dg/set_vm_limit.c: New, called by pr68078. + +2016-09-16 Bill Schmidt <wschmidt@linux.vnet.ibm.com> + + PR target/77613 + * gcc.target/powerpc/swaps-p8-25.c: New. + +2016-09-16 Jakub Jelinek <jakub@redhat.com> + + PR c++/77482 + * g++.dg/cpp0x/constexpr-77482.C: New test. + + PR c++/77379 + * g++.dg/abi/abi-tag23.C: Adjust scan-assembler regex for differing + thunk offsets. + * g++.dg/abi/abi-tag23a.C: Likewise. + + PR c++/77338 + * g++.dg/cpp0x/decltype-77338.C: New test. + + PR c++/77375 + * g++.dg/cpp0x/mutable1.C: New test. + +2016-09-16 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77612 + * gfortran.dg/pr77612.f90: New test. + +2016-09-16 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + * gcc.dg/torture/pr70421.c: Require int32plus. + +2016-09-16 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/77475 + * gcc.target/i386/pr65990.c: Adjust dg-error regexp. + + PR target/77526 + * gcc.target/i386/pr77526.c: New test. + +2016-09-16 Jakub Jelinek <jakub@redhat.com> + Eric Botcazou <ebotcazou@adacore.com> + + PR middle-end/77594 + * gcc.target/i386/pr77594.c: New test. + +2016-09-15 Louis Krupp <louis.krupp@zoho.com> + + PR fortran/69963 + * gfortran.dg/misplaced_implicit_character.f90: New test. + +2016-09-15 Bin Cheng <bin.cheng@arm.com> + + PR tree-optimization/77503 + * gcc.dg/vect/pr77503.c: New test. + +2016-09-15 Richard Biener <rguenther@suse.de> + + PR middle-end/77544 + * c-c++-common/torture/pr77544.c: New testcase. + +2016-09-15 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/77475 + * gcc.target/i386/pr65990.c: Adjust expected diagnostics. + * gcc.dg/march-generic.c: Likewise. + * gcc.target/i386/spellcheck-options-1.c: New test. + * gcc.target/i386/spellcheck-options-2.c: New test. + * gcc.target/i386/spellcheck-options-3.c: New test. + * gcc.target/i386/spellcheck-options-4.c: New test. + +2016-09-15 Chung-Lin Tang <cltang@codesourcery.com> + + PR fortran/72743 + * gfortran.dg/goacc/pr72743.f90: New test. + +2016-09-15 Richard Biener <rguenther@suse.de> + + * gcc.dg/fold-reassoc-2.c: Fix dump scan. + +2016-09-15 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77514 + * gcc.dg/torture/pr77514.c: New testcase. + +2016-09-14 Jakub Jelinek <jakub@redhat.com> + + PR c++/77549 + * g++.dg/lookup/pr77549.C: New test. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * c-c++-common/gomp/atomic-12.c: Use -Wno-deprecated. + * c-c++-common/gomp/atomic-13.c: Likewise. + * c-c++-common/gomp/atomic-14.c: Likewise. + * g++.dg/cpp1y/lambda-init11.C: Remove invalid code. + * g++.dg/cpp1z/bool-increment1.C: New test. + * c-c++-common/pr60439.c: Add dg-warning. + * g++.dg/expr/bitfield4.C: Likewise. + * g++.dg/expr/bitfield5.C: Likewise. + * g++.dg/expr/bitfield6.C: Likewise. + * g++.dg/expr/bool1.C: Likewise. + * g++.dg/expr/bool3.C: Likewise. + * g++.dg/expr/lval3.C: Likewise. + * g++.dg/expr/lval4.C: Likewise. + * g++.old-deja/g++.jason/bool5.C: Likewise. + * g++.dg/expr/bitfield3.C: Adjust dg-error. + * g++.dg/other/error18.C: Likewise. + * g++.dg/gomp/atomic-14.C: Likewise. + +2016-09-14 Nathan Sidwell <nathan@acm.org> + + PR c++/77539 + * g++.dg/cpp1y/pr77539.C: New. + +2016-09-14 Christophe Lyon <christophe.lyon@linaro.org> + + * g++.dg/cpp0x/lambda/lambda-mangle.C: Move dg-do directive before + dg-require. + * g++.dg/ext/builtin_alloca.C: Likewise. + * g++.dg/template/spec35.C: Likewise. + * gcc.dg/builtins-68.c: Likewise. + * gcc.misc-tests/gcov-13.c: Likewise. + * gcc.misc-tests/gcov-14.c: Likewise. + +2016-09-13 Jim MacArthur <jim.macarthur@codethink.co.uk> + + * gfortran.dg/dec_structure_14.f90: New testcase. + +2016-09-14 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/68260 + * c-c++-common/tsan/pr68260.c: New test. + +2016-09-13 Joe Seymour <joe.s@somniumtech.com> + + PR target/70713 + * gcc.target/msp430/function-attributes-1.c: New test. + * gcc.target/msp430/function-attributes-2.c: New test. + * gcc.target/msp430/function-attributes-3.c: New test. + +2016-09-13 Jakub Jelinek <jakub@redhat.com> + + * g++.dg/cpp0x/gen-attrs-61.C: New test. + * g++.dg/cpp1z/gen-attrs1.C: New test. + + PR tree-optimization/77454 + * gcc.dg/pr77454.c: New test. + + PR c++/77553 + * g++.dg/cpp1y/constexpr-77553.C: New test. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c + (test_show_locus): Replace rich_location::add_fixit_insert calls + with add_fixit_insert_before and add_fixit_insert_after. + +2016-09-13 Jason Merrill <jason@redhat.com> + Tom de Vries <tom@codesourcery.com> + + PR c++/77427 + * g++.dg/pr77427.C: New test. + +2016-09-13 Martin Liska <mliska@suse.cz> + + * g++.dg/gcov/gcov-threads-1.C: Use profile_update_atomic + effective target. + * gcc.dg/tree-prof/val-profiler-threads-1.c: Likewise. + * lib/target-supports.exp: Define the new target. + +2016-09-12 Andrew Pinski <apinski@cavium.com> + + * gcc.target/aarch64/thunderxloadpair.c: New testcase. + * gcc.target/aarch64/thunderxnoloadpair.c: New testcase. + +2016-09-12 Uros Bizjak <ubizjak@gmail.com> + + * gcc.dg/compat/scalar-by-value-4_x.c: Also test passing of + variable arguments. + * gcc.dg/compat/scalar-by-value-4_y.c (testva##NAME): New. + * gcc.dg/compat/scalar-by-value-4_main.c: Update description comment. + * gcc.dg/compat/scalar-return-4_x.c: Also test returning of + variable argument. + * gcc.dg/compat/scalar-return-4_y.c (testva##NAME): New. + * gcc.dg/compat/scalar-return-4_main.c: Update description comment. + +2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> + + PR c++/77496 + * c-c++-common/warn-ommitted-condop.c: Add more test cases. + * g++.dg/ext/pr77496.C: New test. + * g++.dg/warn/pr77496.C: New test. + +2016-09-12 David Malcolm <dmalcolm@redhat.com> + + PR c/72858 + * gcc.dg/format/diagnostic-ranges.c: Update expected suggestions + to preserve conversion chars, and to preserve prefix information. + * gcc.dg/format/pr72858.c: New test case. + +2016-09-11 Steven G. Kargl <kargl@gcc.gnu.org> + + * gfortran.dg/pr77507.f90: Move to ... + * gfortran.dg/ieee/pr77507.f90: here. + +2016-08-09 Jan Hubicka <hubicka@ucw.cz> + + PR ipa/61159 + * compile/pr61159.c: New testcase + +2016-08-09 Jan Hubicka <hubicka@ucw.cz> + + PR ipa/64316 + * gcc.dg/ipa/pr63416.c: New testcase. + +2016-09-10 Paul Thomas <pault@gcc.gnu.org> + Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77532 + * gfortran.dg/dtio_11.f90: new test. + +2016-09-10 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77507 + * gfortran.dg/c_assoc_2.f03: Update error message for revision 240050 + * gfortran.dg/c_assoc_4.f90: Ditto. + +2016-09-10 Tom de Vries <tom@codesourcery.com> + + PR C/71602 + * c-c++-common/va-arg-va-list-type.c: New test. + +2016-09-09 Peter Bergner <bergner@vnet.ibm.com> + + PR rtl-optimization/77289 + * gcc.target/powerpc/pr77289.c: New test. + +2016-09-09 Martin Sebor <msebor@redhat.com> + + PR c/77520 + PR c/77521 + * gcc.dg/pr77520.c: New test. + * gcc.dg/pr77521.c: New test. + +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77506 + * gfortran.dg/pr77506.f90: New test. + +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77507 + * gfortran.dg/pr77507.f90: New test. + +2016-09-09 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/limits-width-1.c, gcc.dg/stdint-width-1.c: New tests. + +2016-09-08 Steven G. Kargl <kargl@gcc.gnu.org> + Louis Krupp <lkrupp@gcc.gnu.org> + + PR fortran/69514 + * gfortran.dg/pr69514_1.f90: New test. + * gfortran.dg/pr69514_2.f90: New test. + +2016-09-08 Jakub Jelinek <jakub@redhat.com> + + PR fortran/77500 + * gfortran.dg/gomp/pr77500.f90: New test. + + PR fortran/77516 + * gfortran.dg/gomp/pr77516.f90: New test. + +2016-09-07 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/77475 + * gcc.target/aarch64/arch-diagnostics-1.c: Expect error on line 0. + * gcc.target/aarch64/arch-diagnostics-2.c: Likewise. + * gcc.target/aarch64/cpu-diagnostics-1.c: Likewise. + * gcc.target/aarch64/cpu-diagnostics-2.c: Likewise. + * gcc.target/aarch64/cpu-diagnostics-3.c: Likewise. + * gcc.target/aarch64/cpu-diagnostics-4.c: Likewise. + +2016-09-07 David Malcolm <dmalcolm@redhat.com> + + * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Include + "substring-locations.h". + +2016-09-07 Richard Biener <rguenther@suse.de> + + PR c/77450 + * c-c++-common/vector-subscript-8.c: Move .. + * gcc.dg/pr77450.c: ... here. + +2016-09-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libgfortran/77393 + * gfortran.dg/fmt_f0_2.f90: Update test. + * gfortran.dg/fmt_f0_3.f90: New test. + +2016-09-07 Dominique d'Humieres <dominiq@lps.ens.fr> + + PR debug/77389 + * g++.dg/debug/dwarf2/template-params-12g.C: Pass -gno-strict-dwarf + in dg-options. + + PR debug/57519 + * g++.dg/debug/dwarf2/imported-decl-2.C: Likewise. + +2016-09-06 Jakub Jelinek <jakub@redhat.com> + + PR target/69255 + * gcc.target/i386/pr69255-1.c: New test. + * gcc.target/i386/pr69255-2.c: New test. + * gcc.target/i386/pr69255-3.c: New test. + +2016-09-06 Martin Sebor <msebor@redhat.com> + + PR c/77336 + * gcc.dg/format/miss-7.c: New test. + +2016-09-06 Uros Bizjak <ubizjak@gmail.com> + + * gfortran.dg/c_by_val_1.f: Correct the call to c_to_c and c_to_c8. + +2016-09-06 Martin Liska <mliska@suse.cz> + + PR gcov-profile/77378 + PR gcov-profile/77466 + * gcc.dg/profile-update-warning.c: New test. + +2016-09-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/77479 + * gcc.dg/torture/pr77479.c: New testcase. + +2016-09-06 Richard Biener <rguenther@suse.de> + + PR c/77450 + * c-c++-common/vector-subscript-7.c: Adjust. + * c-c++-common/vector-subscript-8.c: New testcase. + +2016-09-06 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + * gcc.dg/Wno-frame-address.c: Skip for avr-*-*. + +2016-09-05 Jakub Jelinek <jakub@redhat.com> + + PR target/77476 + * gcc.target/i386/avx512f-pr77476.c: New test. + * gcc.target/i386/avx512bw-pr77476.c: New test. + * gcc.target/i386/avx512dq-pr77476.c: New test. + + * lib/target-supports.exp (check_effective_target_vect_simd_clones): + Update comment to mention also avx512f. + + PR sanitizer/77396 + * g++.dg/asan/pr77396-2.C: New test. + +2016-09-05 Uros Bizjak <ubizjak@gmail.com> + + PR rtl-optimization/77452 + * gcc.target/i386/pr77452.c: New test. + +2016-09-05 Marek Polacek <polacek@redhat.com> + + PR c/77423 + * c-c++-common/Wlogical-not-parentheses-3.c: New test. + +2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77391 + * gfortran.dg/pr77391.f90: New test. + +2016-09-04 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77460 + * gfortran.dg/pr77460.f90: New test. + +2016-09-03 Jakub Jelinek <jakub@redhat.com> + + PR c/65467 + * gcc.dg/gomp/_Atomic-4.c: Require vect_simd_clones effective target. + +2016-09-02 Kirill Yukhin <kirill.yukhin@gmaile.com> + + * gcc.target/i386/avx512f-klogic-2.c: Fix operand calculation order. + +2016-09-02 David Malcolm <dmalcolm@redhat.com> + + * gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c: New + test case. + * gcc.dg/plugin/plugin.exp (plugin_test_list): Add + diagnostic-test-show-locus-generate-patch.c to the sources + for diagnostic_plugin_test_show_locus.c. + +2016-09-02 Jakub Jelinek <jakub@redhat.com> + + PR c/65467 + * gcc.dg/gomp/_Atomic-1.c: New test. + * gcc.dg/gomp/_Atomic-2.c: New test. + * gcc.dg/gomp/_Atomic-3.c: New test. + * gcc.dg/gomp/_Atomic-4.c: New test. + * gcc.dg/gomp/_Atomic-5.c: New test. + + PR sanitizer/77396 + * g++.dg/asan/pr77396.C: New test. + +2016-09-01 Martin Sebor <msebor@redhat.com> + + PR tree-optimization/71831 + * gcc.dg/builtin-object-size-16.c: New test. + * gcc.dg/builtin-object-size-17.c: New test. + +2016-09-01 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libgfortran/77393 + * gfortran.dg/fmt_f0_2.f90: Update tests for available kinds. + +2016-09-01 Uros Bizjak <ubizjak@gmail.com> + + * gcc.dg/torture/float128-builtin.c, gcc.dg/torture/float128-floath.c, + gcc.dg/torture/float128-ieee-nan.c, gcc.dg/torture/float128-tg-2.c, + gcc.dg/torture/float128-tg.c, gcc.dg/torture/float128x-builtin.c, + gcc.dg/torture/float128x-floath.c, gcc.dg/torture/float128x-nan.c, + gcc.dg/torture/float128x-tg-2.c, gcc.dg/torture/float128x-tg.c, + gcc.dg/torture/float16-builtin.c, gcc.dg/torture/float16-floath.c, + gcc.dg/torture/float16-nan.c, gcc.dg/torture/float16-tg-2.c, + gcc.dg/torture/float16-tg.c, gcc.dg/torture/float32-builtin.c, + gcc.dg/torture/float32-floath.c, gcc.dg/torture/float32-nan.c, + gcc.dg/torture/float32-tg-2.c, gcc.dg/torture/float32-tg.c, + gcc.dg/torture/float32x-builtin.c, gcc.dg/torture/float32x-floath.c, + gcc.dg/torture/float32x-nan.c, gcc.dg/torture/float32x-tg-2.c, + gcc.dg/torture/float32x-tg.c, gcc.dg/torture/float64-builtin.c, + gcc.dg/torture/float64-floath.c, gcc.dg/torture/float64-nan.c, + gcc.dg/torture/float64-tg-2.c, gcc.dg/torture/float64-tg.c, + gcc.dg/torture/float64x-builtin.c, gcc.dg/torture/float64x-floath.c, + gcc.dg/torture/float64x-nan.c, gcc.dg/torture/float64x-tg-2.c, + gcc.dg/torture/float64x-tg.c: Use dg-add-options ieee. + +2016-09-01 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/opt58.adb: New test. + * gnat.dg/opt58_pkg.ads: New helper. + +2016-09-01 Richard Biener <rguenther@suse.de> + + PR middle-end/77436 + * gcc.dg/torture/pr77436.c: New testcase. + +2016-09-01 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> + + * gcc.dg/pr64252.c: Require int32plus. + * gcc.dg/pr66299-1.c: Likewise. + * gcc.dg/pr66299-2.c: Likewise. + * gcc.dg/torture/20131115-1.c: Skip for avr. + +2016-09-01 Kyrylo Tkachov <kyrylo.tkachov@arm.com> + + * gcc.target/aarch64/ands_3.c: New test. + 2016-08-31 Jakub Jelinek <jakub@redhat.com> PR fortran/77352 @@ -137,12 +635,12 @@ PR tree-optimization/71077 * gcc.target/i386/pr71077.c: New test. -2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> +2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77380 * gfortran.dg/pr77380.f90: New test. -2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> +2016-08-27 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77372 gfortran.dg/pr77372.f90: New test. @@ -196,8 +694,8 @@ PR fortran/77358 * gfortran.dg/submodule_17.f08: New test. -2016-08-24 Michael Collison <michael.collison@linaro.org> - Michael Collison <michael.collison@arm.com> +2016-08-24 Michael Collison <michael.collison@linaro.org> + Michael Collison <michael.collison@arm.com> * gcc.target/arm/builtin_saddl.c: New testcase. * gcc.target/arm/builtin_saddll.c: New testcase. @@ -503,7 +1001,7 @@ PR fortran/67496 * gfortran.dg/pr67496.f90: New test. -2015-08-17 Alan Hayward <alan.hayward@arm.com> +2015-08-17 Alan Hayward <alan.hayward@arm.com> PR tree-optimization/71752 * gcc.dg/vect/pr71752.c: New. @@ -731,7 +1229,7 @@ PR tree-optimization/72851 * gcc.dg/torture/pr72851.c: New testcase. -2016-08-12 Alexandre Oliva <aoliva@redhat.com> +2016-08-12 Alexandre Oliva <aoliva@redhat.com> PR debug/63240 * g++.dg/debug/dwarf2/defaulted-member-function-1.C: New. @@ -1052,7 +1550,7 @@ * gcc.dg/tree-ssa/vrp105.c: New test. * gcc.dg/tree-ssa/vrp106.c: New test. -2016-08-05 Martin Sebor <msebor@redhat.com> +2016-08-05 Martin Sebor <msebor@redhat.com> * g++.dg/cpp0x/constexpr-cast.C: Avoid assuming (void*)1 is spelled 1ul in diagnostics. Remove hyphen from "constant-expression." @@ -1246,7 +1744,7 @@ PR target/72748 * gcc.target/i386/pr72748.c: New test. -2015-08-01 Alan Hayward <alan.hayward@arm.com> +2015-08-01 Alan Hayward <alan.hayward@arm.com> PR tree-optimization/71818 * gcc.dg/vect/pr71818.c: New @@ -1274,7 +1772,7 @@ * lib/target-supports.exp (check_effective_target_c): Fix indentation. (check_effective_target_c++): Likewise. Also match for libstdc++. -2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org> +2016-07-30 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/41922 * gfortran.dg/equiv_constraint_5.f90: Adjust the error message. @@ -1286,7 +1784,7 @@ PR fortran/68566 * gfortran.dg/pr68566.f90: new test. -2016-07-30 Martin Sebor <msebor@redhat.com> +2016-07-30 Martin Sebor <msebor@redhat.com> PR c++/60760 PR c++/71091 @@ -1602,7 +2100,7 @@ EFFECTIVE_TARGETS list. Return the number of supported targets. 2016-07-26 Richard Biener <rguenther@suse.de> - Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> + Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR middle-end/70920 * gcc.dg/pr70920-1.c: New test-case. @@ -1634,7 +2132,7 @@ * gfortran.dg/c_sizeof_6.f90: here. Test for error. * gfortran.dg/pr71935.f90: New test. -2016-07-22 Martin Sebor <msebor@redhat.com> +2016-07-22 Martin Sebor <msebor@redhat.com> PR c++/71675 * g++.dg/ext/atomic-3.C: New test. @@ -1871,7 +2369,7 @@ * g++.dg/cpp0x/nullptr35.C (caught): Fix typo. 2016-07-15 Jerry DeLisle <jvdelisle@gcc.gnu.org> - Marco Restelli <mrestelli@gmail.com> + Marco Restelli <mrestelli@gmail.com> PR fortran/62125 * gfortran.dg/pr62125.f90: New test. @@ -2317,7 +2815,7 @@ * gcc.target/i386/mpx/mpx-check.h: Check XGETBV output if kernel supports MPX. -2016-07-05 Kito Cheng <kito.cheng@gmail.com> +2016-07-05 Kito Cheng <kito.cheng@gmail.com> * gcc.c-torture/compile/pr69102.c: Require fpic support. @@ -3287,7 +3785,7 @@ PR target/71103 * gcc.target/avr/torture/pr71103-2.c: New test. -2016-06-19 Martin Sebor <msebor@redhat.com> +2016-06-19 Martin Sebor <msebor@redhat.com> PR c/69507 * gcc.dg/alignof.c: New test. @@ -6446,7 +6944,7 @@ PR tree-optimization/70780 * gcc.dg/torture/pr70780.c: New testcase. -2016-04-25 Michael Collison <michael.collison@arm.com> +2016-04-25 Michael Collison <michael.collison@arm.com> * gcc.target/arm/neon-vaddws16.c: New test. * gcc.target/arm/neon-vaddws32.c: New test. @@ -7158,7 +7656,7 @@ * g++.dg/ipa/devirt-51.C: New testcase. 2016-04-04 Bill Schmidt <wschmidt@linux.vnet.ibm.com> - Jakub Jelinek <jakub@redhat.com> + Jakub Jelinek <jakub@redhat.com> PR middle-end/70457 * gcc.dg/torture/pr70457.c: New. @@ -7388,7 +7886,7 @@ PR tree-optimization/59124 * gcc.dg/Warray-bounds-19.c: New test. -2016-03-29 Zachary T Welch <zwelch@codesourcery.com> +2016-03-29 Zachary T Welch <zwelch@codesourcery.com> * lib/prune.exp (escape_regex_chars): New. (prune_file_path): Update to quote metcharacters for regexp. diff --git a/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c new file mode 100644 index 00000000000..00aa747652b --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wlogical-not-parentheses-3.c @@ -0,0 +1,31 @@ +/* PR c/77423 */ +/* { dg-do compile } */ +/* { dg-options "-Wlogical-not-parentheses" } */ + +#ifndef __cplusplus +# define bool _Bool +#endif + +int +f (int a, bool b, bool c) +{ + int r = 0; + + r += !a == (b | c); + r += !a == (b ^ c); + r += !a == (b & c); + r += !a == ~b; + r += !a == ~(int) b; + r += !a == ((b & c) | c); + r += !a == ((b & c) | (b ^ c)); + r += !a == (int) (b ^ c); + r += !a == (int) ~b; + r += !a == ~~b; + r += !a == ~(b | c); + r += !a == ~(b | (a == 1)); + r += !a == ~(a == 1); + + r += !a == ((b & c) | (b ^ a)); /* { dg-warning "logical not is only applied to the left hand side of comparison" } */ + + return r; +} diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-12.c b/gcc/testsuite/c-c++-common/gomp/atomic-12.c index 145e4201642..e9ca6503cfe 100644 --- a/gcc/testsuite/c-c++-common/gomp/atomic-12.c +++ b/gcc/testsuite/c-c++-common/gomp/atomic-12.c @@ -1,6 +1,6 @@ /* PR middle-end/45423 */ /* { dg-do compile } */ -/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -Wno-deprecated" } */ /* atomicvar should never be referenced in between the barrier and following #pragma omp atomic_load. */ /* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-13.c b/gcc/testsuite/c-c++-common/gomp/atomic-13.c index 2452035da5b..7f4afcf63ad 100644 --- a/gcc/testsuite/c-c++-common/gomp/atomic-13.c +++ b/gcc/testsuite/c-c++-common/gomp/atomic-13.c @@ -1,6 +1,6 @@ /* PR middle-end/45423 */ /* { dg-do compile } */ -/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2 -Wno-deprecated" } */ /* atomicvar should never be referenced in between the barrier and following #pragma omp atomic_load. */ /* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-14.c b/gcc/testsuite/c-c++-common/gomp/atomic-14.c index f8fc9d87257..7e2345387d4 100644 --- a/gcc/testsuite/c-c++-common/gomp/atomic-14.c +++ b/gcc/testsuite/c-c++-common/gomp/atomic-14.c @@ -1,6 +1,6 @@ /* PR middle-end/45423 */ /* { dg-do compile } */ -/* { dg-options "-fopenmp" } */ +/* { dg-options "-fopenmp -Wno-deprecated" } */ #ifdef __cplusplus bool *baz (); diff --git a/gcc/testsuite/c-c++-common/pr60439.c b/gcc/testsuite/c-c++-common/pr60439.c index 68bd33c22cb..71b397a1c7d 100644 --- a/gcc/testsuite/c-c++-common/pr60439.c +++ b/gcc/testsuite/c-c++-common/pr60439.c @@ -132,6 +132,7 @@ f6 (bool b) break; } switch (b++) /* { dg-warning "switch condition has" } */ + /* { dg-warning "is deprecated" "" { target c++ } 134 } */ { case 3: break; diff --git a/gcc/testsuite/c-c++-common/torture/pr77544.c b/gcc/testsuite/c-c++-common/torture/pr77544.c new file mode 100644 index 00000000000..1d1ce3ff74f --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/pr77544.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +struct { + long a : 17; +} b; +int c, d; +void e() { b.a = d + c + ~(long)(302806U >> 0); } diff --git a/gcc/testsuite/c-c++-common/tsan/pr68260.c b/gcc/testsuite/c-c++-common/tsan/pr68260.c new file mode 100644 index 00000000000..86ffd2b2823 --- /dev/null +++ b/gcc/testsuite/c-c++-common/tsan/pr68260.c @@ -0,0 +1,28 @@ +/* PR sanitizer/68260 */ + +#include <pthread.h> +#include <stdbool.h> + +bool lock; +int counter; + +void * +tf (void *arg) +{ + (void) arg; + while (__atomic_test_and_set (&lock, __ATOMIC_ACQUIRE)) + ; + ++counter; + __atomic_clear (&lock, __ATOMIC_RELEASE); + return (void *) 0; +} + +int +main () +{ + pthread_t thr; + pthread_create (&thr, 0, tf, 0); + tf ((void *) 0); + pthread_join (thr, 0); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/va-arg-va-list-type.c b/gcc/testsuite/c-c++-common/va-arg-va-list-type.c new file mode 100644 index 00000000000..cdd97cfb037 --- /dev/null +++ b/gcc/testsuite/c-c++-common/va-arg-va-list-type.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +__builtin_va_list *pap; + +void +fn1 (void) +{ + __builtin_va_arg (pap, double); /* { dg-error "first argument to 'va_arg' not of type 'va_list'" } */ +} diff --git a/gcc/testsuite/c-c++-common/vector-subscript-7.c b/gcc/testsuite/c-c++-common/vector-subscript-7.c index e8418f24be9..8e8fa0c1bdc 100644 --- a/gcc/testsuite/c-c++-common/vector-subscript-7.c +++ b/gcc/testsuite/c-c++-common/vector-subscript-7.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-ccp1" } */ +/* { dg-options "-O -fdump-tree-fre1" } */ typedef int v4si __attribute__ ((vector_size (16))); @@ -11,4 +11,4 @@ main (int argc, char** argv) return ((v4si){1, 2, 42, 0})[j]; } -/* { dg-final { scan-tree-dump "return 42;" "ccp1" } } */ +/* { dg-final { scan-tree-dump "return 42;" "fre1" } } */ diff --git a/gcc/testsuite/c-c++-common/warn-ommitted-condop.c b/gcc/testsuite/c-c++-common/warn-ommitted-condop.c index 0726f043916..678373f3d70 100644 --- a/gcc/testsuite/c-c++-common/warn-ommitted-condop.c +++ b/gcc/testsuite/c-c++-common/warn-ommitted-condop.c @@ -1,11 +1,15 @@ /* { dg-options "-Wparentheses -ftrack-macro-expansion=0" } */ +#ifndef __cplusplus +#define bool _Bool +#endif + extern void f2 (int); -void bar (int x, int y, int z) +void bar (int x, int y, int z, bool b) { -#define T(op) f2 (x op y ? : 1) -#define T2(op) f2 (x op y ? 2 : 1) +#define T(op) f2 (x op y ? : 1) +#define T2(op) f2 (x op y ? 2 : 1) T(<); /* { dg-warning "omitted middle operand" } */ T(>); /* { dg-warning "omitted middle operand" } */ @@ -16,6 +20,8 @@ void bar (int x, int y, int z) T(||); /* { dg-warning "omitted middle operand" } */ T(&&); /* { dg-warning "omitted middle operand" } */ f2 (!x ? : 1); /* { dg-warning "omitted middle operand" } */ + f2 ((x,!x) ? : 1); /* { dg-warning "omitted middle operand" } */ + f2 ((x,y,!x) ? : 1); /* { dg-warning "omitted middle operand" } */ T2(<); /* { dg-bogus "omitted middle operand" } */ T2(>); /* { dg-bogus "omitted middle operand" } */ T2(==); /* { dg-bogus "omitted middle operand" } */ @@ -26,4 +32,5 @@ void bar (int x, int y, int z) T(*); /* { dg-bogus "omitted middle operand" } */ T(/); /* { dg-bogus "omitted middle operand" } */ T(^); /* { dg-bogus "omitted middle operand" } */ + f2 (b ? : 1); /* { dg-warning "omitted middle operand" } */ } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag23.C b/gcc/testsuite/g++.dg/abi/abi-tag23.C index 5e310a4a42a..4a1c38bc580 100644 --- a/gcc/testsuite/g++.dg/abi/abi-tag23.C +++ b/gcc/testsuite/g++.dg/abi/abi-tag23.C @@ -32,4 +32,4 @@ int main() Final().get_foo(); } -// { dg-final { scan-assembler "_ZThn16_N7Derived7get_fooB3barEv" } } +// { dg-final { scan-assembler "_ZThn\[0-9]+_N7Derived7get_fooB3barEv" } } diff --git a/gcc/testsuite/g++.dg/abi/abi-tag23a.C b/gcc/testsuite/g++.dg/abi/abi-tag23a.C index 72aa037f0b8..10645bf74cf 100644 --- a/gcc/testsuite/g++.dg/abi/abi-tag23a.C +++ b/gcc/testsuite/g++.dg/abi/abi-tag23a.C @@ -32,4 +32,4 @@ int main() Final().get_foo(); } -// { dg-final { scan-assembler "_ZThn16_N7Derived7get_fooEv" } } +// { dg-final { scan-assembler "_ZThn\[0-9]+_N7Derived7get_fooEv" } } diff --git a/gcc/testsuite/g++.dg/asan/pr77396-2.C b/gcc/testsuite/g++.dg/asan/pr77396-2.C new file mode 100644 index 00000000000..0570a14940e --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr77396-2.C @@ -0,0 +1,12 @@ +// PR sanitizer/77396 +// { dg-do run } +// { dg-set-target-env-var ASAN_OPTIONS "check_initialization_order=true" } + +struct S { S () { asm volatile ("" : : : "memory"); } }; +static S c; + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/asan/pr77396.C b/gcc/testsuite/g++.dg/asan/pr77396.C new file mode 100644 index 00000000000..3b3195ec1ec --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr77396.C @@ -0,0 +1,12 @@ +// PR sanitizer/77396 +// { dg-do run } +// { dg-set-target-env-var ASAN_OPTIONS "check_initialization_order=true" } + +static int a = 0; +static int b = a; + +int +main () +{ + return 0; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C index dd9011b8870..b0a1e864eff 100644 --- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C +++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C @@ -5,4 +5,4 @@ #include <new> __attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" } -// { dg-message "previous declaration" "" { target *-*-* } 116 } +// { dg-message "previous declaration" "" { target *-*-* } 120 } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C new file mode 100644 index 00000000000..6f5c91621ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C @@ -0,0 +1,6 @@ +// PR c++/77482 +// { dg-do compile { target c++11 } } + +constexpr auto x; // { dg-error "declaration\[^\n\r]*has no initializer" } +extern struct S s; +constexpr auto y = s; // { dg-error "has incomplete type" } diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-77338.C b/gcc/testsuite/g++.dg/cpp0x/decltype-77338.C new file mode 100644 index 00000000000..4ba7c96d32c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-77338.C @@ -0,0 +1,7 @@ +// PR c++/77338 +// { dg-do compile { target c++11 } } + +struct S; + +template <typename> +auto f (S s) -> decltype (s (s)); // { dg-error "no match for call to" } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-52.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-52.C index 0f87fd490e5..ad7cffc6b99 100644 --- a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-52.C +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-52.C @@ -3,19 +3,22 @@ struct A {int i;} a [[gnu::aligned(16)]]; struct B {int i;} __attribute__((aligned(16))) b; +constexpr unsigned si = sizeof(int); +constexpr unsigned ai = alignof(int); + int main () { A aa; B bb; - static_assert (sizeof (a) == 4, "sizeof (a) should be 4"); + static_assert (sizeof (a) == si, "sizeof (a) should be 4"); static_assert (sizeof (b) == 16, "sizeof (b) should be 16"); - static_assert (sizeof (aa) == 4, "sizeof (aa) should be 4"); + static_assert (sizeof (aa) == si, "sizeof (aa) should be 4"); static_assert (sizeof (bb) == 16, "sizeof (bb) should be 16"); static_assert (__alignof__ (a) == 16, "alignof (a) should be 16"); static_assert (__alignof__ (b) == 16, "alignof (b) should be 16"); - static_assert (__alignof__ (aa) == 4, "alignof (aa) should be 4"); + static_assert (__alignof__ (aa) == ai, "alignof (aa) should be 4"); static_assert (__alignof__ (bb) == 16, "alignof (bb) should be 16"); } diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-61.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-61.C new file mode 100644 index 00000000000..fd7f4437dbb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-61.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } +int +foo () +{ + int i [[and::bitor, bar::xor_eq, compl::baz(1), bitand::xor_eq(2, 3)]]; // { dg-warning "ignored" } + int j [[using, using::baz, bar::using, using::using (2)]]; // { dg-warning "ignored" } + i = 0; + j = 0; + return i + j; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C index 20ef282ac24..15b8b79ecbc 100644 --- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mangle.C @@ -1,6 +1,6 @@ // Test lambda mangling -// { dg-require-weak "" } // { dg-do compile { target c++11 } } +// { dg-require-weak "" } // { dg-options "-fno-inline" } template<typename F> int algo(F fn) { return fn(); } diff --git a/gcc/testsuite/g++.dg/cpp0x/mutable1.C b/gcc/testsuite/g++.dg/cpp0x/mutable1.C new file mode 100644 index 00000000000..4dd37185d72 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/mutable1.C @@ -0,0 +1,12 @@ +// PR c++/77375 +// { dg-do run { target c++11 } } + +struct Base { mutable int i; }; +struct Derived : Base {}; +const Derived foo{}; + +int +main () +{ + foo.i = 42; +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-77553.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-77553.C new file mode 100644 index 00000000000..b924b3830dd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-77553.C @@ -0,0 +1,29 @@ +// PR c++/77553 +// { dg-do compile { target c++14 } } + +constexpr void +bar (int *x) +{ + int i = 0; + x[i++] = 1; + x[3] = i; +} + +constexpr int +foo () +{ + int a[] = { 0, 0, 0, 0 }; + bar (a); + + return a[0] + 8 * a[1] + 64 * a[2] + 512 * a[3]; +} + +constexpr int b = foo (); + +int +main () +{ + static_assert (b == 513, ""); + if (foo () != 513) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C index f7525d8664a..4d434cd9ca0 100644 --- a/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-init11.C @@ -16,5 +16,4 @@ int main(){ foo(3.14f); foo(0); foo('a'); - foo(false); } diff --git a/gcc/testsuite/g++.dg/cpp1y/pr77539.C b/gcc/testsuite/g++.dg/cpp1y/pr77539.C new file mode 100644 index 00000000000..d1fba24c625 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr77539.C @@ -0,0 +1,14 @@ +// PR c++/77539 +// { dg-do compile { target c++14 } } + +constexpr int foobar() +{ + int array[100] = {}; + int *ar = array; + if (ar == nullptr) // Error... + { + return 0; + } + return 1; +} +static_assert(foobar(),""); diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C new file mode 100644 index 00000000000..735296fd8fa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C @@ -0,0 +1,17 @@ +// { dg-options -std=c++1z } +// { dg-do run } + +#ifndef __STDCPP_DEFAULT_NEW_ALIGNMENT__ +#error __STDCPP_DEFAULT_NEW_ALIGNMENT__ not defined +#endif + +#include <cstdint> + +struct alignas(64) A { int i; }; + +int main() +{ + A *p = new A; + if (std::intptr_t(p) % 64 != 0) + __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C new file mode 100644 index 00000000000..fe159692b3b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new2.C @@ -0,0 +1,31 @@ +// { dg-options -std=c++1z } +// { dg-do run } + +#include <new> + +struct alignas(64) A { + int i; + A() { throw 42; } +}; +struct B { int i; } b; + +void *operator new (std::size_t s, std::align_val_t a, B b) +{ + return operator new (s, a); +} + +bool deleted = false; +void operator delete (void *p, std::align_val_t, B) +{ + deleted = true; +} + +int main() +{ + try { + A *p = new (b) A; + __builtin_abort (); + } catch (...) {} + if (!deleted) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C new file mode 100644 index 00000000000..73e33432542 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new3.C @@ -0,0 +1,23 @@ +// { dg-options -std=c++1z } +// { dg-do run } + +#include <new> + +struct alignas(64) A { + int i; +}; + +bool deleted = false; +void operator delete (void *p, std::size_t, std::align_val_t) +{ + deleted = true; + operator delete (p); +} + +int main() +{ + A *p = new A; + delete p; + if (!deleted) + __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C new file mode 100644 index 00000000000..cc63a145589 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++14 -Waligned-new" } + +struct alignas(64) A { int i; }; +struct alignas(64) B { + int i; + void *operator new(__SIZE_TYPE__); +}; + +int main() +{ + A* ap = new A; // { dg-warning "-Waligned-new" } + B* bp = new B; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C new file mode 100644 index 00000000000..eb178d46dff --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new4a.C @@ -0,0 +1,13 @@ +// { dg-options "-std=c++14 -Waligned-new=all" } + +struct alignas(64) A { int i; }; +struct alignas(64) B { + int i; + void *operator new(__SIZE_TYPE__); +}; + +int main() +{ + A* ap = new A; // { dg-warning "-Waligned-new" } + B* bp = new B; // { dg-warning "-Waligned-new" } +} diff --git a/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C b/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C new file mode 100644 index 00000000000..525129e4c40 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aligned-new5.C @@ -0,0 +1,14 @@ +// { dg-options -faligned-new } +// { dg-do run } + +#include <new> +#include <stdint.h> + +struct A { int i; }; + +int main() +{ + A* ap = new (std::align_val_t(64)) A; + if (intptr_t(ap) % 64 != 0) + __builtin_abort(); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C b/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C new file mode 100644 index 00000000000..ae2dcf9f391 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/bool-increment1.C @@ -0,0 +1,14 @@ +// { dg-options -std=c++1z } + +int +fn (bool b) +{ + int r = 0; + + r += b++; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" } + r += ++b; // { dg-error "use of an operand of type .bool. in .operator\\+\\+. is forbidden in" } + r += b--; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" } + r += --b; // { dg-error "use of an operand of type .bool. in .operator--. is forbidden" } + + return r; +} diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C index 41b61114537..982572e65cc 100644 --- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C +++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C @@ -350,6 +350,12 @@ # error "__cpp_if_constexpr != 201606" #endif +#ifndef __cpp_aligned_new +# error "__cpp_aligned_new" +#elif __cpp_aligned_new != 201606 +# error "__cpp_aligned_new != 201606" +#endif + #ifdef __has_cpp_attribute # if ! __has_cpp_attribute(maybe_unused) diff --git a/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C b/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C new file mode 100644 index 00000000000..fe1ebb29a1d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/gen-attrs1.C @@ -0,0 +1,43 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +int +foo () +{ + static int a [[using gnu: unused, used]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } } + int b [[ using foo : bar (2), baz ]]; // { dg-warning "'foo::bar' scoped attribute directive ignored" } + // { dg-warning "'foo::baz' scoped attribute directive ignored" "" { target *-*-* } 8 } + // { dg-warning "attribute using prefix only available" "" { target c++14_down } 8 } + int c [[ using foo : using ("foo")]]; // { dg-warning "'foo::using' scoped attribute directive ignored" } + // { dg-warning "attribute using prefix only available" "" { target c++14_down } 11 } + b = 0; + c = 0; + return b + c; +} + +int +bar () +{ + int a [[ using BAR: foo::bar]]; // { dg-error "attribute using prefix used together with scoped attribute token" } + // { dg-warning "ignored" "" { target *-*-* } 21 } + // { dg-warning "attribute using prefix only available" "" { target c++14_down } 21 } + int b [[ using BAZ: bar(2), bar::bar(3, 4) ]];// { dg-error "attribute using prefix used together with scoped attribute token" } + // { dg-warning "ignored" "" { target *-*-* } 24 } + // { dg-warning "attribute using prefix only available" "" { target c++14_down } 24 } + a = 0; + b = 0; + return a + b; +} + +int +baz () +{ + int a [[ using using: using]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } } + // { dg-warning "'using::using' scoped attribute directive ignored" "" { target *-*-* } 35 } + int b [[ using bitand: bitor, xor]]; // { dg-warning "attribute using prefix only available" "" { target c++14_down } } + // { dg-warning "'bitand::bitor' scoped attribute directive ignored" "" { target *-*-* } 37 } + // { dg-warning "'bitand::xor' scoped attribute directive ignored" "" { target *-*-* } 37 } + a = 0; + b = 0; + return a + b; +} diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C index 58f19bee324..22458c0cb45 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-gdwarf-2 -dA -O0 -fno-merge-debug-strings" } +// { dg-options "-gdwarf-2 -gno-strict-dwarf -dA -O0 -fno-merge-debug-strings" } class AAAA { diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-12g.C b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-12g.C index 813f71d1bc0..1d0960a2851 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/template-params-12g.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/template-params-12g.C @@ -1,4 +1,4 @@ -// { dg-options "-gdwarf-2 -dA" } +// { dg-options "-gdwarf-2 -gno-strict-dwarf -dA" } // { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_template_value_param" 1 } } // { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_template_value_param\[^\n\]*\n\[^\n\]* DW_AT_name\n\[^\n\]* DW_AT_type\n\[^\n\]*\[^\n\]* DW_AT_location\n\[^\n\]* DW_OP_addr\n\[^\n\]*_ZN1B1gEv\[^\n\]*\n\[^\n\]* DW_OP_stack_value\n\[^\n\]* DW_OP_piece\n\[^\n\]*\n\[^\n\]* DW_OP_lit0\n\[^\n\]* DW_OP_stack_value\n\[^\n\]* DW_OP_piece" 1 } } #include "template-params-12.H" diff --git a/gcc/testsuite/g++.dg/expr/bitfield3.C b/gcc/testsuite/g++.dg/expr/bitfield3.C index 3221263a906..3f30337c2db 100644 --- a/gcc/testsuite/g++.dg/expr/bitfield3.C +++ b/gcc/testsuite/g++.dg/expr/bitfield3.C @@ -7,6 +7,6 @@ struct S { S s; void f() { - s.x--; // { dg-error "Boolean expression" } - --s.x; // { dg-error "Boolean expression" } + s.x--; // { dg-error "use of an operand of type .bool." } + --s.x; // { dg-error "use of an operand of type .bool." } } diff --git a/gcc/testsuite/g++.dg/expr/bitfield4.C b/gcc/testsuite/g++.dg/expr/bitfield4.C index d824964e187..7fae086b857 100644 --- a/gcc/testsuite/g++.dg/expr/bitfield4.C +++ b/gcc/testsuite/g++.dg/expr/bitfield4.C @@ -14,6 +14,6 @@ template <> void f(bool) {} int main() { - f(s.x++); - f(++s.x); + f(s.x++); // { dg-warning "deprecated" } + f(++s.x); // { dg-warning "deprecated" } } diff --git a/gcc/testsuite/g++.dg/expr/bitfield5.C b/gcc/testsuite/g++.dg/expr/bitfield5.C index 3d18e159cc0..0a37f9f166b 100644 --- a/gcc/testsuite/g++.dg/expr/bitfield5.C +++ b/gcc/testsuite/g++.dg/expr/bitfield5.C @@ -8,10 +8,10 @@ struct S { S s; int main() { - s.x++; + s.x++; // { dg-warning "deprecated" } if (s.x != 1) return 1; - ++s.x; + ++s.x; // { dg-warning "deprecated" } if (s.x != 1) return 2; } diff --git a/gcc/testsuite/g++.dg/expr/bitfield6.C b/gcc/testsuite/g++.dg/expr/bitfield6.C index 6f6d559a38e..8523866cd9d 100644 --- a/gcc/testsuite/g++.dg/expr/bitfield6.C +++ b/gcc/testsuite/g++.dg/expr/bitfield6.C @@ -7,5 +7,5 @@ struct S { S s; void f() { - ++s.x = false; + ++s.x = false; // { dg-warning "deprecated" } } diff --git a/gcc/testsuite/g++.dg/expr/bool1.C b/gcc/testsuite/g++.dg/expr/bool1.C index bfb40e33092..503e8b40c8c 100644 --- a/gcc/testsuite/g++.dg/expr/bool1.C +++ b/gcc/testsuite/g++.dg/expr/bool1.C @@ -10,8 +10,8 @@ int main() my_bool b = false; int i; - b++; - b++; + b++; // { dg-warning "deprecated" } + b++; // { dg-warning "deprecated" } i = b; if (i != 1) abort (); diff --git a/gcc/testsuite/g++.dg/expr/bool3.C b/gcc/testsuite/g++.dg/expr/bool3.C index 61669e27bef..1866ed47e9d 100644 --- a/gcc/testsuite/g++.dg/expr/bool3.C +++ b/gcc/testsuite/g++.dg/expr/bool3.C @@ -10,8 +10,8 @@ int main() my_bool b = false; int i; - b++; - b++; + b++; // { dg-warning "deprecated" } + b++; // { dg-warning "deprecated" } i = b; if (i != 1) abort (); diff --git a/gcc/testsuite/g++.dg/expr/lval3.C b/gcc/testsuite/g++.dg/expr/lval3.C index f106e69619d..8e0aeade4b9 100644 --- a/gcc/testsuite/g++.dg/expr/lval3.C +++ b/gcc/testsuite/g++.dg/expr/lval3.C @@ -4,6 +4,7 @@ f() { bool i = 0; i++ = 3; // { dg-error "" } + // { dg-warning "deprecated" "" { target *-*-* } 6 } } diff --git a/gcc/testsuite/g++.dg/expr/lval4.C b/gcc/testsuite/g++.dg/expr/lval4.C index c66e2f6af25..b903ec8c39e 100644 --- a/gcc/testsuite/g++.dg/expr/lval4.C +++ b/gcc/testsuite/g++.dg/expr/lval4.C @@ -4,6 +4,7 @@ f() { bool i = 0; ++i = 3; + // { dg-warning "deprecated" "" { target *-*-* } 6 } } diff --git a/gcc/testsuite/g++.dg/ext/builtin_alloca.C b/gcc/testsuite/g++.dg/ext/builtin_alloca.C index 7a0d331ced0..e857502685a 100644 --- a/gcc/testsuite/g++.dg/ext/builtin_alloca.C +++ b/gcc/testsuite/g++.dg/ext/builtin_alloca.C @@ -1,7 +1,7 @@ // PR middle-end/69780 - [4.9/5/6 Regression] ICE on // __builtin_alloca_with_align with small alignment -// { dg-require-effective-target alloca } // { dg-do compile } +// { dg-require-effective-target alloca } #define CHAR_BIT __CHAR_BIT__ #define SIZE_MAX __SIZE_MAX__ diff --git a/gcc/testsuite/g++.dg/ext/pr77496.C b/gcc/testsuite/g++.dg/ext/pr77496.C new file mode 100644 index 00000000000..0b21e0cee39 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr77496.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "" } + +template <class x> +class z : x +{ +public: + bool zz () { return false; } + int f () { return zz ? : 1; } // { dg-error "cannot convert" } +}; + +class t +{ +}; + +int +main () +{ + z<t> x; + return x.f (); +} diff --git a/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C b/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C index a4a6f0a6ae3..cc9266ab8ea 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-threads-1.C @@ -1,5 +1,6 @@ /* { dg-options "-fprofile-arcs -ftest-coverage -pthread -fprofile-update=atomic" } */ /* { dg-do run { target native } } */ +/* { dg-require-effective-target profile_update_atomic } */ #include <stdint.h> #include <pthread.h> diff --git a/gcc/testsuite/g++.dg/gomp/atomic-14.C b/gcc/testsuite/g++.dg/gomp/atomic-14.C index ae1eb50dcd6..982f44fae92 100644 --- a/gcc/testsuite/g++.dg/gomp/atomic-14.C +++ b/gcc/testsuite/g++.dg/gomp/atomic-14.C @@ -8,12 +8,12 @@ int foo (void) { #pragma omp atomic - (*baz ())--; // { dg-error "invalid use of Boolean" } + (*baz ())--; // { dg-error "use of an operand of type .bool." } #pragma omp atomic - --(*baz ()); // { dg-error "invalid use of Boolean" } + --(*baz ()); // { dg-error "use of an operand of type .bool." } #pragma omp atomic - atomicvar--; // { dg-error "invalid use of Boolean" } + atomicvar--; // { dg-error "use of an operand of type .bool." } #pragma omp atomic - --atomicvar; // { dg-error "invalid use of Boolean" } + --atomicvar; // { dg-error "use of an operand of type .bool." } return 0; } diff --git a/gcc/testsuite/g++.dg/lookup/pr77549.C b/gcc/testsuite/g++.dg/lookup/pr77549.C new file mode 100644 index 00000000000..6fe1a0e6b53 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr77549.C @@ -0,0 +1,76 @@ +// PR c++/77549 +// { dg-do compile } + +struct A +{ + static int x; +}; + +void +f1 () +{ + using ::A; + x; // { dg-error "'x' was not declared in this scope" } +} + +namespace N +{ + int bar; +} + +void +f2 () +{ + using N::bar; + baz++; // { dg-error "'baz' was not declared in this scope" } +} // { dg-message "note: suggested alternative: 'bar'" "" { target *-*-* } 25 } + +int +bar () +{ + return 0; +} + +namespace M +{ + int + bar () + { + return 0; + } +} + +void +f3 () +{ + using M::bar; + baz (); // { dg-error "'baz' was not declared in this scope" } +} // { dg-message "note: suggested alternative: 'bar'" "" { target *-*-* } 47 } + +namespace O +{ + int + foo () + { + return 0; + } +} + +namespace P +{ + int + bar () + { + return 0; + } +} + +void +f4 () +{ + using O::foo; + using P::bar; + fooo (); // { dg-error "'fooo' was not declared in this scope" } + // { dg-message "note: suggested alternative: 'foo'" "" { target *-*-* } 73 } + baz (); // { dg-error "'baz' was not declared in this scope" } +} // { dg-message "note: suggested alternative: 'bar'" "" { target *-*-* } 75 } diff --git a/gcc/testsuite/g++.dg/other/error18.C b/gcc/testsuite/g++.dg/other/error18.C index 9e4d21cfde0..05ddf116675 100644 --- a/gcc/testsuite/g++.dg/other/error18.C +++ b/gcc/testsuite/g++.dg/other/error18.C @@ -7,5 +7,5 @@ struct A void f(A a) { - a.b--; // { dg-error "Boolean expression" } + a.b--; // { dg-error "use of an operand of type .bool." } } diff --git a/gcc/testsuite/g++.dg/pr77427.C b/gcc/testsuite/g++.dg/pr77427.C new file mode 100644 index 00000000000..544946d70b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr77427.C @@ -0,0 +1,17 @@ +// { dg-do compile } + +void bar (__builtin_va_list &); + +struct c +{ + operator const __builtin_va_list &(); + operator __builtin_va_list &(); +}; + +void +foo (void) +{ + struct c c1; + + bar (c1); +} diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-1.C b/gcc/testsuite/g++.dg/predict-loop-exit-1.C index 88262eb9d00..47bdf5182c1 100644 --- a/gcc/testsuite/g++.dg/predict-loop-exit-1.C +++ b/gcc/testsuite/g++.dg/predict-loop-exit-1.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate -fdisable-tree-ethread" } */ int g; int foo(); diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-2.C b/gcc/testsuite/g++.dg/predict-loop-exit-2.C index 15e9866d897..15b63eeb0fa 100644 --- a/gcc/testsuite/g++.dg/predict-loop-exit-2.C +++ b/gcc/testsuite/g++.dg/predict-loop-exit-2.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate -fdisable-tree-ethread" } */ int g; int foo(); diff --git a/gcc/testsuite/g++.dg/predict-loop-exit-3.C b/gcc/testsuite/g++.dg/predict-loop-exit-3.C index 61af84b6f56..8d417422b60 100644 --- a/gcc/testsuite/g++.dg/predict-loop-exit-3.C +++ b/gcc/testsuite/g++.dg/predict-loop-exit-3.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ +/* { dg-options "-O2 -fdump-tree-profile_estimate -fdisable-tree-ethread" } */ int g; int foo(); diff --git a/gcc/testsuite/g++.dg/template/spec35.C b/gcc/testsuite/g++.dg/template/spec35.C index 709ece5dd90..e82323ce448 100644 --- a/gcc/testsuite/g++.dg/template/spec35.C +++ b/gcc/testsuite/g++.dg/template/spec35.C @@ -2,8 +2,8 @@ // C++ DR 605 -- "...the linkage of an explicit specialization must be that of // the template." -// { dg-require-weak "" } // { dg-do compile { target i?86-*-* x86_64-*-* } } +// { dg-require-weak "" } template<class T> static void f1 (T) { } diff --git a/gcc/testsuite/g++.dg/warn/pr77496.C b/gcc/testsuite/g++.dg/warn/pr77496.C new file mode 100644 index 00000000000..4b97d0990cc --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/pr77496.C @@ -0,0 +1,21 @@ +// { dg-do compile } +// { dg-options "-Wparentheses" } + +template <class x> +class z : x +{ +public: + bool zz () { return false; } + int f () { return zz () ? : 1; } // { dg-warning "omitted middle operand" } +}; + +class t +{ +}; + +int +main () +{ + z<t> x; + return x.f (); +} diff --git a/gcc/testsuite/g++.old-deja/g++.jason/bool5.C b/gcc/testsuite/g++.old-deja/g++.jason/bool5.C index 1d2f5b60b46..0a16ccb16ac 100644 --- a/gcc/testsuite/g++.old-deja/g++.jason/bool5.C +++ b/gcc/testsuite/g++.old-deja/g++.jason/bool5.C @@ -2,10 +2,10 @@ int main () { bool b = false; - int i = b++; + int i = b++; // { dg-warning "deprecated" } if (i != false || b != true) return 1; - i = b++; + i = b++; // { dg-warning "deprecated" } if (i != true || b != true) return 1; } diff --git a/gcc/testsuite/gcc.c-torture/compile/pr61159.c b/gcc/testsuite/gcc.c-torture/compile/pr61159.c new file mode 100644 index 00000000000..5afa6eaa4d5 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr61159.c @@ -0,0 +1,7 @@ +/* { dg-require-alias "" } */ +/* { dg-require-weak "" } */ + +static int dummy = 0; +extern int foo __attribute__((__weak__, __alias__("dummy"))); +typedef char check[2*!__builtin_constant_p(dummy)-1]; +typedef char check[2*!__builtin_constant_p(foo)-1]; diff --git a/gcc/testsuite/gcc.dg/Wno-frame-address.c b/gcc/testsuite/gcc.dg/Wno-frame-address.c index de5a8b8d7bc..e6dfe52038a 100644 --- a/gcc/testsuite/gcc.dg/Wno-frame-address.c +++ b/gcc/testsuite/gcc.dg/Wno-frame-address.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* hppa*-*-* ia64-*-* visium-*-* } } */ +/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* avr-*-* hppa*-*-* ia64-*-* visium-*-* } } */ /* { dg-options "-Werror" } */ /* { dg-additional-options "-mbackchain" { target { s390*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-16.c b/gcc/testsuite/gcc.dg/builtin-object-size-16.c new file mode 100644 index 00000000000..15721e5ce89 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-16.c @@ -0,0 +1,201 @@ +/* PR 71831 - __builtin_object_size poor results with no optimization + Verify that even without optimization __builtin_object_size returns + a meaningful result for a subset of simple expressins. In cases + where the result could not easily be made to match the one obtained + with optimization the built-in was made to fail instead. */ +/* { dg-do run } */ +/* { dg-options "-O0" } */ + +static int nfails; + +#define TEST_FAILURE(line, obj, type, expect, result) \ + __builtin_printf ("FAIL: line %i: __builtin_object_size(" \ + #obj ", %i) == %zu, got %zu\n", \ + line, type, expect, result), ++nfails + +#define bos(obj, type) __builtin_object_size (obj, type) +#define size(obj, n) ((size_t)n == X ? sizeof *obj : (size_t)n) + +#define test(expect, type, obj) \ + do { \ + if (bos (obj, type) != size (obj, expect)) \ + TEST_FAILURE (__LINE__, obj, type, size (obj, expect), bos (obj, type)); \ + } while (0) + +#define T(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r1, 1, obj); \ + test (r2, 2, obj); \ + test (r3, 3, obj); \ + } while (0) + +/* For convenience. Substitute for 'sizeof object' in test cases where + the size can vary from target to target. */ +#define X (size_t)0xdeadbeef + +/* __builtin_object_size checking results are inconsistent for equivalent + expressions (see bug 71831). To avoid having duplicate the inconsistency + at -O0 the built-in simply fails. The results hardcoded in this test + are those obtained with optimization (for easy comparison) but without + optimization the macros below turn them into expected failures . */ +#if __OPTIMIZE__ +# define F0(n) n +# define F1(n) n +# define F2(n) n +# define F3(n) n +#else +# define F0(n) -1 +# define F1(n) -1 +# define F2(n) 0 +# define F3(n) 0 +#endif + +typedef __SIZE_TYPE__ size_t; + +extern char ax[]; +char ax2[]; /* { dg-warning "assumed to have one element" } */ + +extern char a0[0]; +static char a1[1]; +static char a2[2]; +static char a9[9]; + +#if __SIZEOF_SHORT__ == 4 +extern short ia0[0]; +static short ia1[1]; +static short ia9[9]; +#elif __SIZEOF_INT__ == 4 +extern int ia0[0]; +static int ia1[1]; +static int ia9[9]; +#endif + +static char a2x2[2][2]; +static char a3x5[3][5]; + +struct Sx { char n, a[]; } sx; +struct S0 { char n, a[0]; } s0; +struct S1 { char n, a[1]; } s1; +struct S2 { char n, a[2]; } s2; +struct S9 { char n, a[9]; } s9; + +struct S2x2 { char n, a[2][2]; } s2x2; +struct S3x5 { char n, a[3][5]; } s3x5; + +static __attribute__ ((noclone, noinline)) void +test_arrays () +{ + T ( -1, -1, 0, 0, ax); + + T ( 0, 0, 0, 0, a0); + T ( 1, 1, 1, 1, ax2); + + T ( 1, 1, 1, 1, a1); + T ( 2, 2, 2, 2, a2); + T ( 9, 9, 9, 9, a9); + + T ( 0, 0, 0, 0, a0); + T ( 1, 1, 1, 1, ax2); + + T ( 0, 0, 0, 0, ia0); + T ( 4, 4, 4, 4, ia1); + T ( 36, 36, 36, 36, ia9); + + /* Not all results for multidimensional arrays make sense (see + bug 77293). The expected results below simply reflect those + obtained at -O2 (modulo the known limitations at -O1). */ + T ( 4, 4, 4, 4, a2x2); + T ( 4, 4, 4, 4, &a2x2[0]); + T ( 4, 2, 4, 2, &a2x2[0][0]); + T ( 0, F1 (0), 0, 0, &a2x2 + 1); + T ( 2, F1 ( 2), 2, F3 ( 2), &a2x2[0] + 1); + T ( 3, F1 ( 1), 3, F3 ( 3), &a2x2[0][0] + 1); + + T ( 15, 15, 15, 15, a3x5); + T ( 15, 5, 15, 5, &a3x5[0][0] + 0); + T ( 14, F1 ( 4), 14, F3 (14), &a3x5[0][0] + 1); + + T ( 1, 1, 1, 1, a1 + 0); + T ( 0, F1 (0), 0, 0, a1 + 1); + T ( 0, F1 ( 0), 0, 0, &a1 + 1); + /* In the following the offset is out of bounds which makes + the expression undefined. Still, verify that the returned + size is zero (and not some large number). */ + T ( 0, F1 (0), 0, 0, a1 + 2); + + T ( 2, 2, 2, 2, a2 + 0); + T ( 1, F1 ( 1), 1, F3 ( 1), a2 + 1); + T ( 0, F1 ( 0), 0, 0, a2 + 2); +} + +static __attribute__ ((noclone, noinline)) void +test_structs (struct Sx *psx, struct S0 *ps0, struct S1 *ps1, struct S9 *ps9) +{ + /* The expected size of a declared object with a flexible array member + is sizeof sx in all __builtin_object_size types. */ + T ( X, X, X, X, &sx); + + /* The expected size of an unknown object with a flexible array member + is unknown in all __builtin_object_size types. */ + T ( -1, -1, 0, 0, psx); + + /* The expected size of a flexible array member of a declared object + is zero. */ + T ( 0, 0, 0, 0, sx.a); + + /* The expected size of a flexible array member of an unknown object + is unknown. */ + T ( -1, -1, 0, 0, psx->a); + + /* The expected size of a declared object with a zero-length array member + is sizeof sx in all __builtin_object_size types. */ + T ( X, X, X, X, &s0); + + /* The expected size of an unknown object with a zero-length array member + is unknown in all __builtin_object_size types. */ + T ( -1, -1, 0, 0, ps0); + + /* The expected size of a zero-length array member of a declared object + is zero. */ + T ( 0, 0, 0, 0, s0.a); + + /* The expected size of a zero-length array member of an unknown object + is unknown. */ + T ( -1, -1, 0, 0, ps0->a); + + T ( X, X, X, X, &s1); + T ( 1, 1, 1, 1, s1.a); + T ( 0, F1 (0), 0, 0, s1.a + 1); + + /* GCC treats arrays of all sizes that are the last member of a struct + as flexible array members. */ + T ( -1, -1, 0, 0, ps1); + T ( -1, -1, 0, 0, ps1->a); + T ( -1, -1, 0, 0, ps1->a + 1); + + T ( X, X, X, X, &s9); + T ( 9, 9, 9, 9, s9.a); + T ( 9, 9, 9, 9, s9.a + 0); + T ( 8, F1 ( 8), 8, F3 ( 8), s9.a + 1); + T ( 7, F1 ( 7), 7, F3 ( 7), s9.a + 2); + T ( 0, F1 ( 0), 0, F3 ( 0), s9.a + 9); + + /* The following make little sense but see bug 77301. */ + T ( -1, -1, 0, 0, ps9); + T ( -1, -1, 0, 0, ps9->a); + T ( -1, -1, 0, 0, ps9->a + 1); +} + +int +main() +{ + test_arrays (); + + test_structs (&sx, &s0, &s1, &s9); + + if (nfails) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-17.c b/gcc/testsuite/gcc.dg/builtin-object-size-17.c new file mode 100644 index 00000000000..03664d5d9a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtin-object-size-17.c @@ -0,0 +1,158 @@ +/* PR 71831 - __builtin_object_size poor results with no optimization + Verify that even without optimization __builtin_object_size result + is folded into a constant and dead code that depends on it is + eliminated. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -fdump-tree-ssa" } */ + +#define concat(a, b) a ## b +#define CAT(a, b) concat (a, b) + +/* Create a symbol name unique to each tes and object size type. */ +#define SYM(type) CAT (CAT (CAT (failure_on_line_, __LINE__), _type_), type) + +/* References to the following undefined symbol which is unique for each + test case are expected to be eliminated. */ +#define TEST_FAILURE(type) \ + do { \ + extern void SYM (type)(void); \ + SYM (type)(); \ + } while (0) + +#define bos(obj, type) __builtin_object_size (obj, type) +#define size(obj, n) ((size_t)n == X ? sizeof *obj : (size_t)n) + +#define test(expect, type, obj) \ + do { \ + if (bos (obj, type) != size (obj, expect)) \ + TEST_FAILURE (type); \ + } while (0) + +#define FOLD_ALL(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r1, 1, obj); \ + test (r2, 2, obj); \ + test (r3, 3, obj); \ + } while (0) + +#define FOLD_0_2(r0, r1, r2, r3, obj) \ + do { \ + test (r0, 0, obj); \ + test (r2, 2, obj); \ + } while (0) + +/* For convenience. Substitute for 'sizeof object' in test cases where + the size can vary from target to target. */ +#define X (size_t)0xdeadbeef + +typedef __SIZE_TYPE__ size_t; + +extern char ax[]; +char ax2[]; /* { dg-warning "assumed to have one element" } */ + +extern char a0[0]; +static char a1[1]; +static char a2[2]; +static char a9[9]; + +#if __SIZEOF_SHORT__ == 4 +extern short ia0[0]; +static short ia1[1]; +static short ia9[9]; +#elif __SIZEOF_INT__ == 4 +extern int ia0[0]; +static int ia1[1]; +static int ia9[9]; +#endif + +static char a2x2[2][2]; +static char a3x5[3][5]; + +struct Sx { char n, a[]; } sx; +struct S0 { char n, a[0]; } s0; +struct S1 { char n, a[1]; } s1; +struct S2 { char n, a[2]; } s2; +struct S9 { char n, a[9]; } s9; + +struct S2x2 { char n, a[2][2]; } s2x2; +struct S3x5 { char n, a[3][5]; } s3x5; + +static __attribute__ ((noclone, noinline)) void +test_arrays () +{ + FOLD_ALL ( 1, 1, 1, 1, ax2); + + FOLD_ALL ( 1, 1, 1, 1, a1); + FOLD_ALL ( 2, 2, 2, 2, a2); + FOLD_ALL ( 9, 9, 9, 9, a9); + + FOLD_ALL ( 0, 0, 0, 0, a0); + FOLD_ALL ( 1, 1, 1, 1, ax2); + + FOLD_ALL ( 0, 0, 0, 0, ia0); + FOLD_ALL ( 4, 4, 4, 4, ia1); + FOLD_ALL ( 36, 36, 36, 36, ia9); + + /* Not all results for multidimensional arrays make sense (see + bug 77293). The expected results below simply reflect those + obtained at -O2 (modulo the known limitations at -O1). */ + FOLD_ALL ( 4, 4, 4, 4, a2x2); + FOLD_ALL ( 4, 4, 4, 4, &a2x2[0]); + FOLD_ALL ( 4, 2, 4, 2, &a2x2[0][0]); + FOLD_0_2 ( 0, F1 (0), 0, 0, &a2x2 + 1); + FOLD_0_2 ( 2, F1 ( 2), 2, F3 ( 2), &a2x2[0] + 1); + FOLD_0_2 ( 3, F1 ( 1), 3, F3 ( 3), &a2x2[0][0] + 1); + + FOLD_ALL ( 15, 15, 15, 15, a3x5); + FOLD_ALL ( 15, 5, 15, 5, &a3x5[0][0] + 0); + FOLD_0_2 ( 14, F1 ( 4), 14, F3 (14), &a3x5[0][0] + 1); + + FOLD_ALL ( 1, 1, 1, 1, a1 + 0); + FOLD_0_2 ( 0, F1 ( 0), 0, 0, &a1 + 1); + FOLD_ALL ( 2, 2, 2, 2, a2 + 0); + FOLD_0_2 ( 1, F1 ( 1), 1, F3 ( 1), a2 + 1); + FOLD_0_2 ( 0, F1 ( 0), 0, 0, a2 + 2); +} + +static __attribute__ ((noclone, noinline)) void +test_structs (void) +{ + /* The expected size of a declared object with a flexible array member + is sizeof sx in all __builtin_object_size types. */ + FOLD_ALL ( X, X, X, X, &sx); + + /* The expected size of a flexible array member of a declared object + is zero. */ + FOLD_ALL ( 0, 0, 0, 0, sx.a); + + /* The expected size of a declared object with a zero-length array member + is sizeof sx in all __builtin_object_size types. */ + FOLD_ALL ( X, X, X, X, &s0); + + /* The expected size of a zero-length array member of a declared object + is zero. */ + FOLD_ALL ( 0, 0, 0, 0, s0.a); + + FOLD_ALL ( X, X, X, X, &s1); + FOLD_ALL ( 1, 1, 1, 1, s1.a); + FOLD_0_2 ( 0, F1 (0), 0, 0, s1.a + 1); + + FOLD_ALL ( X, X, X, X, &s9); + FOLD_ALL ( 9, 9, 9, 9, s9.a); + FOLD_ALL ( 9, 9, 9, 9, s9.a + 0); + FOLD_0_2 ( 8, F1 ( 8), 8, F3 ( 8), s9.a + 1); + FOLD_0_2 ( 7, F1 ( 7), 7, F3 ( 7), s9.a + 2); + FOLD_0_2 ( 0, F1 ( 0), 0, F3 ( 0), s9.a + 9); +} + +int +main() +{ + test_arrays (); + test_structs (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "failure_on_line" "ssa" } } */ diff --git a/gcc/testsuite/gcc.dg/builtins-68.c b/gcc/testsuite/gcc.dg/builtins-68.c index c0cc1ebdcb9..1247394e4d9 100644 --- a/gcc/testsuite/gcc.dg/builtins-68.c +++ b/gcc/testsuite/gcc.dg/builtins-68.c @@ -1,7 +1,7 @@ /* PR middle-end/69780 - [4.9/5/6 Regression] ICE on __builtin_alloca_with_align with small alignment */ -/* { dg-require-effective-target alloca } */ /* { dg-do compile } */ +/* { dg-require-effective-target alloca } */ /* { dg-options "-Wno-long-long" } */ #define CHAR_BIT __CHAR_BIT__ diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c index 8164b44283a..bd024c0542d 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_main.c @@ -1,5 +1,5 @@ /* Test passing scalars by value. This test includes _Complex types - whose real and imaginary parts cannot be used in variable-length + whose real and imaginary parts can be used in variable-length argument lists. */ extern void scalar_by_value_4_x (void); diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c index a4e73c9fdb6..a36a06081f1 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_x.c @@ -13,6 +13,7 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ TYPE x05, TYPE x06, TYPE x07, TYPE x08, \ TYPE x09, TYPE x10, TYPE x11, TYPE x12, \ TYPE x13, TYPE x14, TYPE x15, TYPE x16); \ +extern void testva##NAME (int n, ...); \ \ void \ check##NAME (TYPE x, TYPE v) \ @@ -62,6 +63,81 @@ testit##NAME (void) \ g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ DEBUG_NL; \ DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva:"); \ + DEBUG_NL; \ + testva##NAME (1, \ + g01##NAME); \ + DEBUG_NL; \ + testva##NAME (2, \ + g01##NAME, g02##NAME); \ + DEBUG_NL; \ + testva##NAME (3, \ + g01##NAME, g02##NAME, g03##NAME); \ + DEBUG_NL; \ + testva##NAME (4, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME); \ + DEBUG_NL; \ + testva##NAME (5, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME); \ + DEBUG_NL; \ + testva##NAME (6, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME); \ + DEBUG_NL; \ + testva##NAME (7, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME); \ + DEBUG_NL; \ + testva##NAME (8, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME); \ + DEBUG_NL; \ + testva##NAME (9, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME); \ + DEBUG_NL; \ + testva##NAME (10, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME); \ + DEBUG_NL; \ + testva##NAME (11, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME); \ + DEBUG_NL; \ + testva##NAME (12, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME); \ + DEBUG_NL; \ + testva##NAME (13, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME); \ + DEBUG_NL; \ + testva##NAME (14, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME); \ + DEBUG_NL; \ + testva##NAME (15, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME); \ + DEBUG_NL; \ + testva##NAME (16, \ + g01##NAME, g02##NAME, g03##NAME, g04##NAME, \ + g05##NAME, g06##NAME, g07##NAME, g08##NAME, \ + g09##NAME, g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, g16##NAME); \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ DEBUG_FPUTS (" test2: "); \ test2_##NAME (g01##NAME, g03##NAME, g05##NAME, g07##NAME, \ g09##NAME, g11##NAME, g13##NAME, g15##NAME); \ diff --git a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c index e0fa7053996..38b17d50066 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-by-value-4_y.c @@ -65,6 +65,23 @@ test##NAME (TYPE x01, TYPE x02, TYPE x03, TYPE x04, \ check##NAME (x14, 14); \ check##NAME (x15, 15); \ check##NAME (x16, 16); \ +} \ + \ +void \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + va_list ap; \ + if (test_va) \ + { \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + { \ + TYPE t = va_arg (ap, TYPE); \ + check##NAME (t, i+1); \ + } \ + va_end (ap); \ + } \ } #ifndef SKIP_COMPLEX diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c index 2bcfa04872f..866121e5dd3 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_main.c @@ -1,5 +1,5 @@ /* Test function return values. This test includes _Complex types - whose real and imaginary parts cannot be used in variable-length + whose real and imaginary parts can be used in variable-length argument lists. */ extern void scalar_return_4_x (void); diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c index 50305be4d35..11f4688a6d0 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_x.c @@ -1,12 +1,22 @@ #include "compat-common.h" +#ifdef SKIP_VA +const int test_va = 0; +#else +const int test_va = 1; +#endif + #define T(NAME, TYPE, INITVAL) \ -TYPE g01##NAME; \ +TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ \ extern void init##NAME (TYPE *p, TYPE v); \ extern void checkg##NAME (void); \ extern TYPE test0##NAME (void); \ extern TYPE test1##NAME (TYPE); \ +extern TYPE testva##NAME (int n, ...); \ \ void \ check##NAME (TYPE x, TYPE v) \ @@ -22,6 +32,21 @@ testit##NAME (void) \ DEBUG_FPUTS (#NAME); \ DEBUG_FPUTS (" init: "); \ init##NAME (&g01##NAME, 1); \ + init##NAME (&g02##NAME, 2); \ + init##NAME (&g03##NAME, 3); \ + init##NAME (&g04##NAME, 4); \ + init##NAME (&g05##NAME, 5); \ + init##NAME (&g06##NAME, 6); \ + init##NAME (&g07##NAME, 7); \ + init##NAME (&g08##NAME, 8); \ + init##NAME (&g09##NAME, 9); \ + init##NAME (&g10##NAME, 10); \ + init##NAME (&g11##NAME, 11); \ + init##NAME (&g12##NAME, 12); \ + init##NAME (&g13##NAME, 13); \ + init##NAME (&g14##NAME, 14); \ + init##NAME (&g15##NAME, 15); \ + init##NAME (&g16##NAME, 16); \ checkg##NAME (); \ DEBUG_NL; \ DEBUG_FPUTS (#NAME); \ @@ -33,13 +58,35 @@ testit##NAME (void) \ DEBUG_FPUTS (" test1: "); \ rslt = test1##NAME (g01##NAME); \ check##NAME (rslt, g01##NAME); \ + if (test_va) \ + { \ + DEBUG_NL; \ + DEBUG_FPUTS (#NAME); \ + DEBUG_FPUTS (" testva: "); \ + rslt = testva##NAME (1, g01##NAME); \ + check##NAME (rslt, g01##NAME); \ + rslt = testva##NAME (5, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME); \ + check##NAME (rslt, g05##NAME); \ + rslt = testva##NAME (9, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME); \ + check##NAME (rslt, g09##NAME); \ + rslt = testva##NAME (16, g01##NAME, g02##NAME, g03##NAME, \ + g04##NAME, g05##NAME, g06##NAME, \ + g07##NAME, g08##NAME, g09##NAME, \ + g10##NAME, g11##NAME, g12##NAME, \ + g13##NAME, g14##NAME, g15##NAME, \ + g16##NAME); \ + check##NAME (rslt, g16##NAME); \ + } \ DEBUG_NL; \ } #ifndef SKIP_COMPLEX #ifndef SKIP_COMPLEX_INT T(cc, _Complex char, CINT (0, 1)) -T(cs, _Complex short, CINT (1 + 2)) +T(cs, _Complex short, CINT (1, 2)) #endif T(cf, _Complex float, CDBL (1.0, 2.0)) #endif diff --git a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c index 3c96856975f..3ae0749bab8 100644 --- a/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c +++ b/gcc/testsuite/gcc.dg/compat/scalar-return-4_y.c @@ -2,14 +2,11 @@ #include "compat-common.h" -#ifdef SKIP_VA -const int test_va = 0; -#else -const int test_va = 1; -#endif - #define T(NAME, TYPE, INITVAL) \ -extern TYPE g01##NAME; \ +extern TYPE g01##NAME, g02##NAME, g03##NAME, g04##NAME; \ +extern TYPE g05##NAME, g06##NAME, g07##NAME, g08##NAME; \ +extern TYPE g09##NAME, g10##NAME, g11##NAME, g12##NAME; \ +extern TYPE g13##NAME, g14##NAME, g15##NAME, g16##NAME; \ \ extern void check##NAME (TYPE x, TYPE v); \ \ @@ -23,6 +20,21 @@ void \ checkg##NAME (void) \ { \ check##NAME (g01##NAME, 1+INITVAL); \ + check##NAME (g02##NAME, 2+INITVAL); \ + check##NAME (g03##NAME, 3+INITVAL); \ + check##NAME (g04##NAME, 4+INITVAL); \ + check##NAME (g05##NAME, 5+INITVAL); \ + check##NAME (g06##NAME, 6+INITVAL); \ + check##NAME (g07##NAME, 7+INITVAL); \ + check##NAME (g08##NAME, 8+INITVAL); \ + check##NAME (g09##NAME, 9+INITVAL); \ + check##NAME (g10##NAME, 10+INITVAL); \ + check##NAME (g11##NAME, 11+INITVAL); \ + check##NAME (g12##NAME, 12+INITVAL); \ + check##NAME (g13##NAME, 13+INITVAL); \ + check##NAME (g14##NAME, 14+INITVAL); \ + check##NAME (g15##NAME, 15+INITVAL); \ + check##NAME (g16##NAME, 16+INITVAL); \ } \ \ TYPE \ @@ -35,6 +47,19 @@ TYPE \ test1##NAME (TYPE x01) \ { \ return x01; \ +} \ + \ +TYPE \ +testva##NAME (int n, ...) \ +{ \ + int i; \ + TYPE rslt; \ + va_list ap; \ + va_start (ap, n); \ + for (i = 0; i < n; i++) \ + rslt = va_arg (ap, TYPE); \ + va_end (ap); \ + return rslt; \ } #ifndef SKIP_COMPLEX diff --git a/gcc/testsuite/gcc.dg/fold-reassoc-2.c b/gcc/testsuite/gcc.dg/fold-reassoc-2.c index 98890b10be3..a334ec6122a 100644 --- a/gcc/testsuite/gcc.dg/fold-reassoc-2.c +++ b/gcc/testsuite/gcc.dg/fold-reassoc-2.c @@ -1,13 +1,13 @@ -/* { dg-do compile } */
-/* { dg-options "-O -fdump-tree-original" } */
-
-int foo (int i)
-{
- return (i + 2) - (i + 1);
-}
-int bar (int i)
-{
- return (i + 2) + ~i;
-}
-
-/* { dg-final { scan-tree-dump "return 1;" "original" } } */
+/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-original" } */ + +int foo (int i) +{ + return (i + 2) - (i + 1); +} +int bar (int i) +{ + return (i + 2) + ~i; +} + +/* { dg-final { scan-tree-dump-times "return 1;" 2 "original" } } */ diff --git a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c index 63075c80609..e5e6ade6bbe 100644 --- a/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c +++ b/gcc/testsuite/gcc.dg/format/diagnostic-ranges.c @@ -30,7 +30,7 @@ void test_mismatching_types (const char *msg) /* { dg-begin-multiline-output "" } printf("hello %i", (long)0); ~^ - %ld + %li { dg-end-multiline-output "" } */ } @@ -88,7 +88,7 @@ void test_hex (const char *msg) /* { dg-begin-multiline-output "" } printf("hello \x25\x69", msg); ~~~~^~~~ - %s + \x25s { dg-end-multiline-output "" } */ } @@ -102,7 +102,7 @@ void test_oct (const char *msg) /* { dg-begin-multiline-output "" } printf("hello \045\151", msg); ~~~~^~~~ - %s + \045s { dg-end-multiline-output "" } */ } @@ -121,7 +121,7 @@ void test_multiple (const char *msg) /* { dg-begin-multiline-output "" } printf("prefix" "\x25" "\151" "suffix", ~~~~~~~~^~~~ - %s + \x25" "s { dg-end-multiline-output "" } */ } @@ -267,7 +267,7 @@ void test_non_contiguous_strings (void) /* { dg-begin-multiline-output "" } __builtin_printf(" %" "d ", 0.5); ~~~~^ - %f + %" "f { dg-end-multiline-output "" } */ } diff --git a/gcc/testsuite/gcc.dg/format/miss-7.c b/gcc/testsuite/gcc.dg/format/miss-7.c new file mode 100644 index 00000000000..828b781e0e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/miss-7.c @@ -0,0 +1,36 @@ +/* PR77336 - -Wsuggest-attribute=format warning overly simplistic */ +/* { dg-do compile } */ +/* { dg-options "-Wsuggest-attribute=format" } */ + +#include "format.h" + +const char format[] = "%i"; + +void foo (char *d, unsigned n, va_list va) +{ + (void)&n; + + /* The following calls don't imply that the enclosing function is + a candiate for the format attribute because it uses a string + constant as the format. */ + vsnprintf (d, n, "%i", va); + + vsnprintf (d, n, format, va); + + /* In theory this should not trigger the warning either but GCC + doesn't treat the local static constant the same way as the + global and issues a false positive. + const char fmt[] = "%i"; + vsnprintf (d, n, fmt, va); + */ +} + +void bar (char *d, unsigned n, const char *f, va_list va) +{ + (void)&n; + + /* The following call suggests that the enclosing function might + be a candiate for the format attribute because it doesn't use + a string literal as the format. */ + vsnprintf (d, n, f, va); /* { dg-warning "function .bar. might be a candidate for .gnu_printf. format attribute" } */ +} diff --git a/gcc/testsuite/gcc.dg/format/pr72858.c b/gcc/testsuite/gcc.dg/format/pr72858.c new file mode 100644 index 00000000000..d8d0499b778 --- /dev/null +++ b/gcc/testsuite/gcc.dg/format/pr72858.c @@ -0,0 +1,410 @@ +/* { dg-options "-Wformat -fdiagnostics-show-caret" } */ + +#include "format.h" + +/* Various format tests, some containing type mismatches. Verify that for + the type mismatch cases that we offer "good" suggestions. Specifically, + any suggestions should preserve flags characters, field width and precision, + and, if possible, the conversion specifier character, whilst giving a + corrected length modifier appropriate to the argument type. */ + +/* Tests of "x" without a length modifier, with various param types. + Suggestions should preserve the "x" for integer arguments. */ + +void +test_x (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr, + float fexpr, double dexpr, long double ldexpr, + void *ptr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8x ", iexpr); + sprintf (d, " %-8x ", uiexpr); + + sprintf (d, " %-8x ", lexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", lexpr); + ~~~^ + %-8lx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ulexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ulexpr); + ~~~^ + %-8lx + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8x ", llexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", llexpr); + ~~~^ + %-8llx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ullexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ullexpr); + ~~~^ + %-8llx + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8x ", fexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "fexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", fexpr); + ~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", dexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "dexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", dexpr); + ~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8x ", ldexpr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ldexpr); + ~~~^ + %-8Lf + { dg-end-multiline-output "" } */ + + /* Pointer. */ + sprintf (d, " %-8x ", ptr); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'void \\*'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", ptr); + ~~~^ + %-8p + { dg-end-multiline-output "" } */ + + /* Something unrecognized. */ + struct s { int i; }; + struct s s; + sprintf (d, " %-8x ", s); /* { dg-warning "20: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'struct s'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8x ", s); + ~~~^ + { dg-end-multiline-output "" } */ +} + +/* Tests of "x" with "l", with various param types. + Suggestions should preserve the "x" for integer arguments. */ + +void +test_lx (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr, + float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8lx ", iexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", iexpr); + ~~~~^ + %-8x + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", uiexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int'" } */ +/* TODO: ideally would also underline "uiexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", uiexpr); + ~~~~^ + %-8x + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8lx ", lexpr); + sprintf (d, " %-8lx ", ulexpr); + + sprintf (d, " %-8lx ", llexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "llexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", llexpr); + ~~~~^ + %-8llx + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", ullexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "ullexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", ullexpr); + ~~~~^ + %-8llx + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8lx ", fexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "fexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", fexpr); + ~~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", dexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'double'" } */ +/* TODO: ideally would also underline "dexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", dexpr); + ~~~~^ + %-8f + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lx ", ldexpr); /* { dg-warning "21: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lx ", ldexpr); + ~~~~^ + %-8Lf + { dg-end-multiline-output "" } */ +} + +/* Tests of "o" without a length modifier, with various param types. + Suggestions should preserve the "o" for integer arguments. */ + +void +test_o (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8o ", iexpr); + sprintf (d, " %-8o ", uiexpr); + + sprintf (d, " %-8o ", lexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", lexpr); + ~~~^ + %-8lo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8o ", ulexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", ulexpr); + ~~~^ + %-8lo + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8o ", llexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", llexpr); + ~~~^ + %-8llo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8o ", ullexpr); /* { dg-warning "20: format '%o' expects argument of type 'unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "lexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8o ", ullexpr); + ~~~^ + %-8llo + { dg-end-multiline-output "" } */ +} + +/* Tests of "o" with "l", with various param types. + Suggestions should preserve the "o" for integer arguments. */ + +void +test_lo (char *d, + int iexpr, unsigned int uiexpr, + long lexpr, unsigned long ulexpr, + long long llexpr, unsigned long long ullexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8lo ", iexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", iexpr); + ~~~~^ + %-8o + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lo ", uiexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int'" } */ +/* TODO: ideally would also underline "uiexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", uiexpr); + ~~~~^ + %-8o + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8lo ", lexpr); + sprintf (d, " %-8lo ", ulexpr); + + sprintf (d, " %-8lo ", llexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'long long int'" } */ +/* TODO: ideally would also underline "llexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", llexpr); + ~~~~^ + %-8llo + { dg-end-multiline-output "" } */ + sprintf (d, " %-8lo ", ullexpr); /* { dg-warning "21: format '%lo' expects argument of type 'long unsigned int', but argument 3 has type 'long long unsigned int'" } */ +/* TODO: ideally would also underline "ullexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8lo ", ullexpr); + ~~~~^ + %-8llo + { dg-end-multiline-output "" } */ +} + +/* Tests of "e" without a length modifier, with various param types. + Suggestions should preserve the "e" for float arguments. */ + +void +test_e (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8e ", iexpr); /* { dg-warning "20: format '%e' expects argument of type 'double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8e ", iexpr); + ~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8e ", fexpr); + sprintf (d, " %-8e ", dexpr); + sprintf (d, " %-8e ", ldexpr); /* { dg-warning "20: format '%e' expects argument of type 'double', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8e ", ldexpr); + ~~~^ + %-8Le + { dg-end-multiline-output "" } */ +} + +/* Tests of "e" with "L", with various param types. + Suggestions should preserve the "e" for float arguments. */ + +void +test_Le (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8Le ", iexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", iexpr); + ~~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8Le ", fexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", fexpr); + ~~~~^ + %-8e + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8Le ", dexpr); /* { dg-warning "21: format '%Le' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8Le ", dexpr); + ~~~~^ + %-8e + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8Le ", ldexpr); +} + +/* Tests of "E" without a length modifier, with various param types. + Suggestions should preserve the "E" for floating-point arguments. */ + +void +test_E (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8E ", iexpr); /* { dg-warning "20: format '%E' expects argument of type 'double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8E ", iexpr); + ~~~^ + %-8d + { dg-end-multiline-output "" } */ + + /* Floating-point arguments. */ + + sprintf (d, " %-8E ", fexpr); + sprintf (d, " %-8E ", dexpr); + sprintf (d, " %-8E ", ldexpr); /* { dg-warning "20: format '%E' expects argument of type 'double', but argument 3 has type 'long double'" } */ +/* TODO: ideally would also underline "ldexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8E ", ldexpr); + ~~~^ + %-8LE + { dg-end-multiline-output "" } */ +} + +/* Tests of "E" with "L", with various param types. + Suggestions should preserve the "E" for floating-point arguments. */ + +void +test_LE (char *d, int iexpr, float fexpr, double dexpr, long double ldexpr) +{ + /* Integer arguments. */ + + sprintf (d, " %-8LE ", iexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'int'" } */ +/* TODO: ideally would also underline "iexpr". */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", iexpr); + ~~~~^ + %-8d + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", fexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", fexpr); + ~~~~^ + %-8E + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", dexpr); /* { dg-warning "21: format '%LE' expects argument of type 'long double', but argument 3 has type 'double'" } */ +/* { dg-begin-multiline-output "" } + sprintf (d, " %-8LE ", dexpr); + ~~~~^ + %-8E + { dg-end-multiline-output "" } */ + + sprintf (d, " %-8LE ", ldexpr); +} + +/* Test of a suggestion for a conversion specification containing + all features (flags, width, precision, length modifier), where + all the other arguments have mismatching types. */ + +void +test_everything (char *d, long lexpr) +{ + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); /* { dg-warning "26: field width specifier '\\*' expects argument of type 'int', but argument 3 has type 'long int'" } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~^~~~~~ + { dg-end-multiline-output "" } */ + + /* { dg-warning "28: field precision specifier '\\.\\*' expects argument of type 'int', but argument 4 has type 'long int'" "" { target *-*-* } 392 } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~~~^~~~ + { dg-end-multiline-output "" } */ + + /* { dg-warning "31: format '%lld' expects argument of type 'long long int', but argument 5 has type 'long int'" "" { target *-*-* } 392 } */ + /* { dg-begin-multiline-output "" } + sprintf (d, "before %-+*.*lld after", lexpr, lexpr, lexpr); + ~~~~~~~~^ + %-+*.*ld + { dg-end-multiline-output "" } */ +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c new file mode 100644 index 00000000000..1f784524f67 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-1.c @@ -0,0 +1,103 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +_Atomic int t; +#pragma omp threadprivate (t) + +void +foo (void) +{ + _Atomic int a = 4, b = 0, c, d = 3, e; + a++; + #pragma omp parallel sections num_threads (a) shared (b) private (c) firstprivate (d) lastprivate (e) + { + #pragma omp section + { + a++; + b++; + c = 5; + c++; + d++; + e = 9; + e++; + } + #pragma omp section + { + a++; + b++; + c = 5; + c++; + d++; + e = 3; + e++; + } + } + e++; + t++; + #pragma omp parallel copyin (t) private (e) + { + t++; + e = t; + #pragma omp single copyprivate (e) + { + e++; + } + e++; + } +} + +void +bar (void) +{ + int a[4]; + _Atomic int b = 1, c = 2, f = 8, g = 8, h = 0; + _Atomic int d, e[3]; + int *_Atomic p; + _Atomic int *_Atomic q; + int i, j; + p = a; + q = e; + #pragma omp target teams map (tofrom: a[b:c]) num_teams (b) thread_limit (c) + a[1]++; + #pragma omp target device(h) + ; + #pragma omp task depend (inout: a[b:c]) + ; + #pragma omp task depend (out: d, e[b:c]) priority (b) + ; + #pragma omp task depend (out: p[b:c]) + ; + #pragma omp task depend (out: q[b:c]) + ; + #pragma omp taskloop num_tasks (c) + for (i = 0; i < 16; i++) + ; + #pragma omp taskloop grainsize (c) + for (i = 0; i < 16; i++) + ; + #pragma omp parallel for schedule (dynamic, b) + for (i = 0; i < 16; i++) + ; + j = 0; + #pragma omp simd linear(j:b) + for (i = 0; i < 16; i++) + j += b; + j = 4; + #pragma omp atomic read + b = j; + #pragma omp atomic write + j = c; + #pragma omp atomic + j += c; + #pragma omp atomic capture + b = j += c; + #pragma omp atomic capture + b = ++j; + #pragma omp atomic capture + { b = j; j = c; } + #pragma omp atomic capture + { b = j; j++; } + #pragma omp atomic capture + { j *= c; b = j; } +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c new file mode 100644 index 00000000000..159a5b3ee7d --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-2.c @@ -0,0 +1,76 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + _Atomic int i; + #pragma omp for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp parallel for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp parallel for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp parallel for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp parallel for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; +} + +void +f2 (void) +{ + _Atomic int i; + #pragma omp distribute /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute parallel for /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute parallel for simd /* { dg-error "'_Atomic' iteration variable 'i'" } */ + for (i = 0; i < 64; i++) + ; + #pragma omp distribute /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp distribute parallel for /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; + #pragma omp distribute parallel for simd /* { dg-error "'_Atomic' iteration variable 'j'" } */ + for (_Atomic int j = 0; j < 64; j++) + ; +} + +void +f3 (void) +{ + int i; + _Atomic int j = 0; + #pragma omp simd linear(j:2) /* { dg-error "'_Atomic' 'j' in 'linear' clause" } */ + for (i = 0; i < 64; i++) + j += 2; + #pragma omp parallel for linear(j:1) /* { dg-error "'_Atomic' 'j' in 'linear' clause" } */ + for (i = 0; i < 64; i++) + j++; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c new file mode 100644 index 00000000000..31dd1cb1122 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-3.c @@ -0,0 +1,65 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + _Atomic int i = 0, k[4]; + int j = 0; + k[0] = 0; + k[1] = 0; + k[2] = 0; + k[3] = 0; + #pragma omp parallel reduction (+:i) /* { dg-error "'_Atomic' 'i' in 'reduction' clause" } */ + i++; + #pragma omp declare reduction (foo: _Atomic int: omp_out += omp_in) initializer (omp_priv = omp_orig * 0) /* { dg-error "'_Atomic' qualified type in '#pragma omp declare reduction'" } */ + #pragma omp declare reduction (bar: int: omp_out += omp_in) initializer (omp_priv = omp_orig * 0) + #pragma omp parallel reduction (bar:j) + j++; + #pragma omp parallel reduction (bar:i) /* { dg-error "'_Atomic' 'i' in 'reduction' clause" } */ + i++; + #pragma omp parallel reduction (+:k) /* { dg-error "'_Atomic' 'k' in 'reduction' clause" } */ + k[1]++; + #pragma omp parallel reduction (+:k[1:2]) /* { dg-error "'_Atomic' \[^\n\r]* in 'reduction' clause" } */ + k[1]++; +} + +void +f2 (int *_Atomic p) +{ + #pragma omp simd aligned (p : 16) /* { dg-error "'_Atomic' 'p' in 'aligned' clause" } */ + for (int i = 0; i < 16; i++) + p[i]++; +} + +_Atomic int x; + +void +f3 (_Atomic int *p) +{ + int i; + #pragma omp atomic write + x = 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic read + i = x; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic update + x += 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic capture + i = x *= 2; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic write + p[2] = 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic read + i = p[2]; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic update + p[2] += 6; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ + #pragma omp atomic capture + i = p[2] *= 2; /* { dg-error "'_Atomic' expression in '#pragma omp atomic'" } */ +} + +#pragma omp declare simd linear(x:1) /* { dg-error "'_Atomic' 'x' in 'linear' clause" } */ +int +f4 (_Atomic int x, int y) +{ + return x + y; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c new file mode 100644 index 00000000000..f790dd094dc --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-4.c @@ -0,0 +1,18 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ +/* { dg-require-effective-target vect_simd_clones } */ + +#pragma omp declare simd +int +f1 (_Atomic int x, int y) /* { dg-warning "ignoring '#pragma omp declare simd' on function with '_Atomic' qualified non-'uniform' argument" } */ +{ + return x + y; +} + +#pragma omp declare simd uniform(x) +int +f2 (_Atomic int x, int y) +{ + return x + y; +} diff --git a/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c b/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c new file mode 100644 index 00000000000..9b7f58f0329 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/_Atomic-5.c @@ -0,0 +1,74 @@ +/* PR c/65467 */ +/* { dg-do compile } */ +/* { dg-additional-options "-std=c11" } */ + +void +f1 (void) +{ + struct S { int a; int b[2]; _Atomic int *c; }; + _Atomic int a = 0, b[2]; + _Atomic int d[3]; + _Atomic struct S c = (struct S) { 3, { 4, 5 }, d }; + int *_Atomic p; + _Atomic int *q; + int e[3] = { 1, 2, 3 }; + b[0] = 1; + b[1] = 2; + d[0] = 6; + d[1] = 7; + d[2] = 8; + p = e; + #pragma omp target map(tofrom: a) /* { dg-error "'_Atomic' 'a' in 'map' clause" } */ + ; + #pragma omp target map(to: b) /* { dg-error "'_Atomic' 'b' in 'map' clause" } */ + ; + #pragma omp target map(from: b[1:1]) /* { dg-error "'_Atomic' 'b' in 'map' clause" } */ + ; + #pragma omp target map(to: c.a) /* { dg-error "'_Atomic' 'c.a' in 'map' clause" } */ + /* { dg-warning "accessing a member 'a' of an atomic structure 'c'" "" { target *-*-* } 27 } */ + ; + #pragma omp target map(to: c.b[1]) /* { dg-error "'_Atomic' 'c.b' in 'map' clause" } */ + /* { dg-warning "accessing a member 'b' of an atomic structure 'c'" "" { target *-*-* } 30 } */ + ; + #pragma omp target data map(c) /* { dg-error "'_Atomic' 'c' in 'map' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 33 } */ + { + #pragma omp target update to (c.a) /* { dg-error "'_Atomic' 'c.a' in 'to' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 36 } */ + /* { dg-warning "accessing a member 'a' of an atomic structure 'c'" "" { target *-*-* } 36 } */ + #pragma omp target update from (c.b[1]) /* { dg-error "'_Atomic' 'c.b' in 'from' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 39 } */ + /* { dg-warning "accessing a member 'b' of an atomic structure 'c'" "" { target *-*-* } 39 } */ + #pragma omp target update to (c) /* { dg-error "'_Atomic' 'c' in 'to' clause" } */ + /* { dg-error "must contain at least one" "" { target *-*-* } 42 } */ + } + #pragma omp target map(to: c.c[0:]) /* { dg-error "'_Atomic' 'c.c' in 'map' clause" } */ + /* { dg-warning "accessing a member 'c' of an atomic structure 'c'" "" { target *-*-* } 45 } */ + ; + #pragma omp target map(to: p[1:2]) /* { dg-error "'_Atomic' 'p' in 'map' clause" } */ + ; + #pragma omp target map(to: q[1:2]) /* { dg-error "'_Atomic' '\[^\n\r]*' in 'map' clause" } */ + ; +} + +void +f2 (void) +{ + _Atomic int a = 0, b[2] = { 1, 2 }; + #pragma omp target defaultmap(tofrom:scalar) /* { dg-error "'_Atomic' 'a' in implicit 'map' clause" } */ + a++; + #pragma omp target /* { dg-error "'_Atomic' 'b' in implicit 'map' clause" } */ + b[0]++; +} + +void +f3 (void) +{ + _Atomic int a = 0, b[2] = { 1, 2 }; + #pragma omp target /* { dg-error "'_Atomic' 'a' in implicit 'firstprivate' clause on 'target' construct" } */ + a++; + #pragma omp target firstprivate (a) /* { dg-error "'_Atomic' 'a' in 'firstprivate' clause on 'target' construct" } */ + a++; + #pragma omp target firstprivate (b) /* { dg-error "'_Atomic' 'b' in 'firstprivate' clause on 'target' construct" } */ + b[0]++; +} diff --git a/gcc/testsuite/gcc.dg/ipa/pr63416.c b/gcc/testsuite/gcc.dg/ipa/pr63416.c new file mode 100644 index 00000000000..b5374c51fe9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr63416.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +#define _UNUSED_ __attribute__((__unused__)) + +typedef int TEST_F30 (int *v); +typedef void TEST_F31 (int *v); +typedef void TEST_F32 (int *v, int r); + +typedef struct TEST_T30_ { + TEST_F30 * pf30; + TEST_F31 * pf31; + TEST_F32 * pf32; +} TEST_T30; + +static inline +int test_f30 (int *v) +{ + *v = 1; + return 0; +}//test_f30() + +static inline +void test_f31 (int *v _UNUSED_) +{ +}//test_f31() + +static inline +void test_f32 (int *v, int r _UNUSED_) +{ + *v = 0; +}//test_f32() + +static const +TEST_T30 test_t30 = { + .pf30 = test_f30, + .pf31 = test_f31, + .pf32 = test_f32, +}; + +static inline +int test_f10 (const TEST_T30 *pt30, int *v) +{ + int r = pt30->pf30(v); + pt30->pf31(v); + pt30->pf32(v, r); + return 0; +}//test_f10() + +int test_f00 (int *v) +{ + return test_f10(&test_t30, v); +}//test_f00() + +/* Everything should be inlined and only test_f00 body should appear. */ +/* { dg-final { scan-tree-dump-not "test_f10" "optimized" } } */ +/* { dg-final { scan-tree-dump-not "test_f3" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/limits-width-1.c b/gcc/testsuite/gcc.dg/limits-width-1.c new file mode 100644 index 00000000000..7a87014526c --- /dev/null +++ b/gcc/testsuite/gcc.dg/limits-width-1.c @@ -0,0 +1,55 @@ +/* Test TS 18661-1 width macros in <limits.h>. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11" } */ + +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include <limits.h> + +#define CHECK_WIDTH(TYPE, MAX, WIDTH) \ + _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \ + "width must match type") + +#ifndef CHAR_WIDTH +# error "missing CHAR_WIDTH" +#endif +CHECK_WIDTH (char, CHAR_MAX, CHAR_WIDTH); +#ifndef SCHAR_WIDTH +# error "missing SCHAR_WIDTH" +#endif +CHECK_WIDTH (signed char, SCHAR_MAX, SCHAR_WIDTH); +#ifndef UCHAR_WIDTH +# error "missing UCHAR_WIDTH" +#endif +CHECK_WIDTH (unsigned char, UCHAR_MAX, UCHAR_WIDTH); +#ifndef SHRT_WIDTH +# error "missing SHRT_WIDTH" +#endif +CHECK_WIDTH (signed short, SHRT_MAX, SHRT_WIDTH); +#ifndef USHRT_WIDTH +# error "missing USHRT_WIDTH" +#endif +CHECK_WIDTH (unsigned short, USHRT_MAX, USHRT_WIDTH); +#ifndef INT_WIDTH +# error "missing INT_WIDTH" +#endif +CHECK_WIDTH (signed int, INT_MAX, INT_WIDTH); +#ifndef UINT_WIDTH +# error "missing UINT_WIDTH" +#endif +CHECK_WIDTH (unsigned int, UINT_MAX, UINT_WIDTH); +#ifndef LONG_WIDTH +# error "missing LONG_WIDTH" +#endif +CHECK_WIDTH (signed long, LONG_MAX, LONG_WIDTH); +#ifndef ULONG_WIDTH +# error "missing ULONG_WIDTH" +#endif +CHECK_WIDTH (unsigned long, ULONG_MAX, ULONG_WIDTH); +#ifndef LLONG_WIDTH +# error "missing LLONG_WIDTH" +#endif +CHECK_WIDTH (signed long long, LLONG_MAX, LLONG_WIDTH); +#ifndef ULLONG_WIDTH +# error "missing ULLONG_WIDTH" +#endif +CHECK_WIDTH (unsigned long long, ULLONG_MAX, ULLONG_WIDTH); diff --git a/gcc/testsuite/gcc.dg/march-generic.c b/gcc/testsuite/gcc.dg/march-generic.c index 6b0923919e3..fb5b83c7d74 100644 --- a/gcc/testsuite/gcc.dg/march-generic.c +++ b/gcc/testsuite/gcc.dg/march-generic.c @@ -1,6 +1,6 @@ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ /* { dg-skip-if "" { *-*-* } { "-march=*" } { "" } } */ /* { dg-options "-march=generic" } */ -/* { dg-error "generic CPU can be used only for -mtune" "" { target *-*-* } 0 } */ +/* { dg-error "'generic' CPU can be used only for '-mtune=' switch" "" { target *-*-* } 0 } */ /* { dg-bogus "march" "" { target *-*-* } 0 } */ int i; diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c new file mode 100644 index 00000000000..afbaf635401 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-generate-patch.c @@ -0,0 +1,77 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdiagnostics-generate-patch" } */ + +/* This is a collection of unittests for diagnostic_show_locus; + see the overview in diagnostic_plugin_test_show_locus.c. + + In particular, note the discussion of why we need a very long line here: +01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 + and that we can't use macros in this file. */ + +/* Unit test for rendering of insertion fixit hints + (example taken from PR 62316). */ + +void test_fixit_insert (void) +{ +#if 0 + int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */ +#endif +} + +/* Unit test for rendering of "remove" fixit hints. */ + +void test_fixit_remove (void) +{ +#if 0 + int a;; /* { dg-warning "example of a removal hint" } */ +#endif +} + +/* Unit test for rendering of "replace" fixit hints. */ + +void test_fixit_replace (void) +{ +#if 0 + gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */ +#endif +} + + + +/* Verify the output from -fdiagnostics-generate-patch. + We expect a header, containing the filename. This is the absolute path, + so we can only capture it via regexps. */ + +/* { dg-regexp "\\-\\-\\- .*" } */ +/* { dg-regexp "\\+\\+\\+ .*" } */ + +/* Next, we expect the diff itself. */ +/* { dg-begin-multiline-output "" } +@@ -14,7 +14,7 @@ + void test_fixit_insert (void) + { + #if 0 +- int a[2][2] = { 0, 1 , 2, 3 }; ++ int a[2][2] = { {0, 1} , 2, 3 }; + #endif + } + +@@ -23,7 +23,7 @@ + void test_fixit_remove (void) + { + #if 0 +- int a;; ++ int a; + #endif + } + +@@ -32,7 +32,7 @@ + void test_fixit_replace (void) + { + #if 0 +- gtk_widget_showall (dlg); ++ gtk_widget_show_all (dlg); + #endif + } + + { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c index ea28f046e8d..3efc7dfa0b4 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_show_locus.c @@ -263,8 +263,8 @@ test_show_locus (function *fun) location_t start = get_loc (line, 19); location_t finish = get_loc (line, 22); rich_location richloc (line_table, make_location (start, start, finish)); - richloc.add_fixit_insert (start, "{"); - richloc.add_fixit_insert (get_loc (line, 23), "}"); + richloc.add_fixit_insert_before ("{"); + richloc.add_fixit_insert_after ("}"); warning_at_rich_loc (&richloc, 0, "example of insertion hints"); } diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c index dff999c3aa9..99a504dc541 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_string_literals.c @@ -33,6 +33,7 @@ #include "print-tree.h" #include "cpplib.h" #include "c-family/c-pragma.h" +#include "substring-locations.h" int plugin_is_GPL_compatible; diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index 715038a0279..32ca748e2cb 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -65,7 +65,8 @@ set plugin_test_list [list \ { diagnostic_plugin_test_show_locus.c \ diagnostic-test-show-locus-bw.c \ diagnostic-test-show-locus-color.c \ - diagnostic-test-show-locus-parseable-fixits.c } \ + diagnostic-test-show-locus-parseable-fixits.c \ + diagnostic-test-show-locus-generate-patch.c } \ { diagnostic_plugin_test_tree_expression_range.c \ diagnostic-test-expressions-1.c } \ { diagnostic_plugin_show_trees.c \ diff --git a/gcc/testsuite/gcc.dg/pr64252.c b/gcc/testsuite/gcc.dg/pr64252.c index 71f9c7812a4..a813f5aedc4 100644 --- a/gcc/testsuite/gcc.dg/pr64252.c +++ b/gcc/testsuite/gcc.dg/pr64252.c @@ -1,6 +1,7 @@ /* PR target/64252 */ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* { dg-require-effective-target int32plus } */ typedef unsigned int V __attribute__((vector_size (32))); diff --git a/gcc/testsuite/gcc.dg/pr66299-1.c b/gcc/testsuite/gcc.dg/pr66299-1.c index e75146bf3eb..df8476462f9 100644 --- a/gcc/testsuite/gcc.dg/pr66299-1.c +++ b/gcc/testsuite/gcc.dg/pr66299-1.c @@ -1,6 +1,7 @@ /* PR tree-optimization/66299 */ /* { dg-do run } */ /* { dg-options "-fdump-tree-original" } */ +/* { dg-require-effective-target int32plus } */ void test1 (int x) diff --git a/gcc/testsuite/gcc.dg/pr66299-2.c b/gcc/testsuite/gcc.dg/pr66299-2.c index 45e92184764..c75c539a41f 100644 --- a/gcc/testsuite/gcc.dg/pr66299-2.c +++ b/gcc/testsuite/gcc.dg/pr66299-2.c @@ -1,6 +1,7 @@ /* PR tree-optimization/66299 */ /* { dg-do run } */ /* { dg-options "-fdump-tree-optimized -O" } */ +/* { dg-require-effective-target int32plus } */ void test1 (int x, unsigned u) diff --git a/gcc/testsuite/gcc.dg/pr77450.c b/gcc/testsuite/gcc.dg/pr77450.c new file mode 100644 index 00000000000..7c19e86ca02 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77450.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu90" } */ + +typedef int V __attribute__((vector_size(4))); + +void +foo(void) +{ + (V){ 0 }[0] = 0; +} diff --git a/gcc/testsuite/gcc.dg/pr77454.c b/gcc/testsuite/gcc.dg/pr77454.c new file mode 100644 index 00000000000..1bb41c2b176 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77454.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/77454 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo (unsigned char x, char y) +{ + while (x != 0) + { + unsigned char *a = &x; + int b; + + if (y != 0) + a = (unsigned char *) &y; + else if (y + 1 != 0) + a = (unsigned char *) &y; + for (x = 0; x < 1; ++x) + b = 0; + for (y = 0; y < 3; ++y) + { + y = !!y; + if (y != 0) + x = y; + } + if ((b != 0 ? -1 : *a) < (y = b)) + b = 1; + } +} diff --git a/gcc/testsuite/gcc.dg/pr77520.c b/gcc/testsuite/gcc.dg/pr77520.c new file mode 100644 index 00000000000..b237639fb20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77520.c @@ -0,0 +1,10 @@ +/* PR c/77520 - wrong value for extended ASCII characters in -Wformat message + Verify that characters in the extended ASCII range are quoted and not + allowed to be printed raw. */ +/* { dg-do compile } */ +/* { dg-options "-Wformat" } */ + +void f (void) +{ + __builtin_printf ("%\x80"); /* { dg-warning "unknown conversion type character .\\\\x80. in format" } */ +} diff --git a/gcc/testsuite/gcc.dg/pr77521.c b/gcc/testsuite/gcc.dg/pr77521.c new file mode 100644 index 00000000000..f6b1e3ed269 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr77521.c @@ -0,0 +1,8 @@ +/* PR c/77521 - %qc format directive should quote non-printable characters. + Verify that non-printable characters in assembly constraints are quoted + and not allowed to be printed raw. */ + +void f (int a, int b) +{ + __asm__ ("combine %2, %0" : "=r" (a) : "0" (a), "\n" (b)); /* { dg-error "invalid punctuation .\\\\x0a. in constraint" } */ +} diff --git a/gcc/testsuite/gcc.dg/profile-update-warning.c b/gcc/testsuite/gcc.dg/profile-update-warning.c new file mode 100644 index 00000000000..0614fad960f --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-update-warning.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fprofile-update=atomic -fprofile-generate -march=i386 -m32" } */ + +int main(int argc, char *argv[]) +{ + return 0; +} /* { dg-warning "target does not support atomic profile update, single mode is selected" } */ diff --git a/gcc/testsuite/gcc.dg/stdint-width-1.c b/gcc/testsuite/gcc.dg/stdint-width-1.c new file mode 100644 index 00000000000..a28feee38db --- /dev/null +++ b/gcc/testsuite/gcc.dg/stdint-width-1.c @@ -0,0 +1,175 @@ +/* Test TS 18661-1 width macros in <stdint.h>. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -ffreestanding" } */ + +#include <stddef.h> +#define __STDC_WANT_IEC_60559_BFP_EXT__ +#include <stdint.h> +#ifndef SIGNAL_SUPPRESS +#include <signal.h> +#endif +typedef __WINT_TYPE__ wint_t; + +#define CHECK_WIDTH(TYPE, MAX, WIDTH) \ + _Static_assert ((MAX >> ((TYPE) -1 < 0 ? (WIDTH - 2) : (WIDTH - 1))) == 1, \ + "width must match type") + +#ifdef INT8_MAX +# ifndef INT8_WIDTH +# error "missing INT8_WIDTH" +# endif +CHECK_WIDTH (int8_t, INT8_MAX, INT8_WIDTH); +#endif +#ifdef INT16_MAX +# ifndef INT16_WIDTH +# error "missing INT16_WIDTH" +# endif +CHECK_WIDTH (int16_t, INT16_MAX, INT16_WIDTH); +#endif +#ifdef INT32_MAX +# ifndef INT32_WIDTH +# error "missing INT32_WIDTH" +# endif +CHECK_WIDTH (int32_t, INT32_MAX, INT32_WIDTH); +#endif +#ifdef INT64_MAX +# ifndef INT64_WIDTH +# error "missing INT64_WIDTH" +# endif +CHECK_WIDTH (int64_t, INT64_MAX, INT64_WIDTH); +#endif +#ifdef UINT8_MAX +# ifndef UINT8_WIDTH +# error "missing UINT8_WIDTH" +# endif +CHECK_WIDTH (uint8_t, UINT8_MAX, UINT8_WIDTH); +#endif +#ifdef UINT16_MAX +# ifndef UINT16_WIDTH +# error "missing UINT16_WIDTH" +# endif +CHECK_WIDTH (uint16_t, UINT16_MAX, UINT16_WIDTH); +#endif +#ifdef UINT32_MAX +# ifndef UINT32_WIDTH +# error "missing UINT32_WIDTH" +# endif +CHECK_WIDTH (uint32_t, UINT32_MAX, UINT32_WIDTH); +#endif +#ifdef UINT64_MAX +# ifndef UINT64_WIDTH +# error "missing UINT64_WIDTH" +# endif +CHECK_WIDTH (uint64_t, UINT64_MAX, UINT64_WIDTH); +#endif + +#ifndef INT_LEAST8_WIDTH +# error "missing INT_LEAST8_WIDTH" +#endif +CHECK_WIDTH (int_least8_t, INT_LEAST8_MAX, INT_LEAST8_WIDTH); +#ifndef INT_LEAST16_WIDTH +# error "missing INT_LEAST16_WIDTH" +#endif +CHECK_WIDTH (int_least16_t, INT_LEAST16_MAX, INT_LEAST16_WIDTH); +#ifndef INT_LEAST32_WIDTH +# error "missing INT_LEAST32_WIDTH" +#endif +CHECK_WIDTH (int_least32_t, INT_LEAST32_MAX, INT_LEAST32_WIDTH); +#ifndef INT_LEAST64_WIDTH +# error "missing INT_LEAST64_WIDTH" +#endif +CHECK_WIDTH (int_least64_t, INT_LEAST64_MAX, INT_LEAST64_WIDTH); +#ifndef INT_LEAST8_WIDTH +# error "missing INT_LEAST8_WIDTH" +#endif +CHECK_WIDTH (uint_least8_t, UINT_LEAST8_MAX, UINT_LEAST8_WIDTH); +#ifndef UINT_LEAST16_WIDTH +# error "missing UINT_LEAST16_WIDTH" +#endif +CHECK_WIDTH (uint_least16_t, UINT_LEAST16_MAX, UINT_LEAST16_WIDTH); +#ifndef UINT_LEAST32_WIDTH +# error "missing UINT_LEAST32_WIDTH" +#endif +CHECK_WIDTH (uint_least32_t, UINT_LEAST32_MAX, UINT_LEAST32_WIDTH); +#ifndef UINT_LEAST64_WIDTH +# error "missing UINT_LEAST64_WIDTH" +#endif +CHECK_WIDTH (uint_least64_t, UINT_LEAST64_MAX, UINT_LEAST64_WIDTH); + +#ifndef INT_FAST8_WIDTH +# error "missing INT_FAST8_WIDTH" +#endif +CHECK_WIDTH (int_fast8_t, INT_FAST8_MAX, INT_FAST8_WIDTH); +#ifndef INT_FAST16_WIDTH +# error "missing INT_FAST16_WIDTH" +#endif +CHECK_WIDTH (int_fast16_t, INT_FAST16_MAX, INT_FAST16_WIDTH); +#ifndef INT_FAST32_WIDTH +# error "missing INT_FAST32_WIDTH" +#endif +CHECK_WIDTH (int_fast32_t, INT_FAST32_MAX, INT_FAST32_WIDTH); +#ifndef INT_FAST64_WIDTH +# error "missing INT_FAST64_WIDTH" +#endif +CHECK_WIDTH (int_fast64_t, INT_FAST64_MAX, INT_FAST64_WIDTH); +#ifndef INT_FAST8_WIDTH +# error "missing INT_FAST8_WIDTH" +#endif +CHECK_WIDTH (uint_fast8_t, UINT_FAST8_MAX, UINT_FAST8_WIDTH); +#ifndef UINT_FAST16_WIDTH +# error "missing UINT_FAST16_WIDTH" +#endif +CHECK_WIDTH (uint_fast16_t, UINT_FAST16_MAX, UINT_FAST16_WIDTH); +#ifndef UINT_FAST32_WIDTH +# error "missing UINT_FAST32_WIDTH" +#endif +CHECK_WIDTH (uint_fast32_t, UINT_FAST32_MAX, UINT_FAST32_WIDTH); +#ifndef UINT_FAST64_WIDTH +# error "missing UINT_FAST64_WIDTH" +#endif +CHECK_WIDTH (uint_fast64_t, UINT_FAST64_MAX, UINT_FAST64_WIDTH); + +#ifdef INTPTR_MAX +# ifndef INTPTR_WIDTH +# error "missing INTPTR_WIDTH" +# endif +CHECK_WIDTH (intptr_t, INTPTR_MAX, INTPTR_WIDTH); +#endif +#ifdef UINTPTR_MAX +# ifndef UINTPTR_WIDTH +# error "missing UINTPTR_WIDTH" +# endif +CHECK_WIDTH (uintptr_t, UINTPTR_MAX, UINTPTR_WIDTH); +#endif + +#ifndef INTMAX_WIDTH +# error "missing INTMAX_WIDTH" +#endif +CHECK_WIDTH (intmax_t, INTMAX_MAX, INTMAX_WIDTH); +#ifndef UINTMAX_WIDTH +# error "missing UINTMAX_WIDTH" +#endif +CHECK_WIDTH (uintmax_t, UINTMAX_MAX, UINTMAX_WIDTH); + +#ifndef PTRDIFF_WIDTH +# error "missing PTRDIFF_WIDTH" +#endif +CHECK_WIDTH (ptrdiff_t, PTRDIFF_MAX, PTRDIFF_WIDTH); +#ifndef SIGNAL_SUPPRESS +# ifndef SIG_ATOMIC_WIDTH +# error "missing SIG_ATOMIC_WIDTH" +# endif +CHECK_WIDTH (sig_atomic_t, SIG_ATOMIC_MAX, SIG_ATOMIC_WIDTH); +#endif +#ifndef SIZE_WIDTH +# error "missing SIZE_WIDTH" +#endif +CHECK_WIDTH (size_t, SIZE_MAX, SIZE_WIDTH); +#ifndef WCHAR_WIDTH +# error "missing WCHAR_WIDTH" +#endif +CHECK_WIDTH (wchar_t, WCHAR_MAX, WCHAR_WIDTH); +#ifndef WINT_WIDTH +# error "missing WINT_WIDTH" +#endif +CHECK_WIDTH (wint_t, WINT_MAX, WINT_WIDTH); diff --git a/gcc/testsuite/gcc.dg/torture/20131115-1.c b/gcc/testsuite/gcc.dg/torture/20131115-1.c index edb05f04c47..d0cdfa5a220 100644 --- a/gcc/testsuite/gcc.dg/torture/20131115-1.c +++ b/gcc/testsuite/gcc.dg/torture/20131115-1.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-skip-if "RAM usage too large" { "avr-*-*" } } */ struct S { int i; }; __attribute__((const, noinline, noclone)) diff --git a/gcc/testsuite/gcc.dg/torture/float128-builtin.c b/gcc/testsuite/gcc.dg/torture/float128-builtin.c index e4a50ceecff..ea3497ce9a8 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float128-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-floath.c b/gcc/testsuite/gcc.dg/torture/float128-floath.c index 68147c35fb6..7b5b046e79f 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float128-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c b/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c index 5dfbff9e8ad..2f3b5c0d95e 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float128-ieee-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c index c7a32b176e8..eda98e58bbc 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg.c b/gcc/testsuite/gcc.dg/torture/float128-tg.c index c1b6398d92b..d252ec545c1 100644 --- a/gcc/testsuite/gcc.dg/torture/float128-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float128-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-builtin.c b/gcc/testsuite/gcc.dg/torture/float128x-builtin.c index 2e6bbaf28df..d75bc55a7dd 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-floath.c b/gcc/testsuite/gcc.dg/torture/float128x-floath.c index 0fc3db2744f..3ac96ce3177 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-nan.c b/gcc/testsuite/gcc.dg/torture/float128x-nan.c index ad0052fc434..c3eaf1218df 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c index e5c1b0c6989..31fa34eec7e 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg.c b/gcc/testsuite/gcc.dg/torture/float128x-tg.c index 0dc1e0f6823..751a3c64ffa 100644 --- a/gcc/testsuite/gcc.dg/torture/float128x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float128x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float128x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float128x_runtime } */ #define WIDTH 128 diff --git a/gcc/testsuite/gcc.dg/torture/float16-builtin.c b/gcc/testsuite/gcc.dg/torture/float16-builtin.c index 43f9b1936b5..4efe177c566 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float16-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-floath.c b/gcc/testsuite/gcc.dg/torture/float16-floath.c index 6857c2e9aa8..3748f4197df 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float16-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-nan.c b/gcc/testsuite/gcc.dg/torture/float16-nan.c index 859f30ca414..34cc50bdc20 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float16-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg-2.c b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c index 4236018b0e7..ecb0fe448d1 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg.c b/gcc/testsuite/gcc.dg/torture/float16-tg.c index 39e8285b6e8..56c4e31394e 100644 --- a/gcc/testsuite/gcc.dg/torture/float16-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float16-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float16 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float16_runtime } */ #define WIDTH 16 diff --git a/gcc/testsuite/gcc.dg/torture/float32-builtin.c b/gcc/testsuite/gcc.dg/torture/float32-builtin.c index fc14ad1e112..9b510266f82 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float32-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-floath.c b/gcc/testsuite/gcc.dg/torture/float32-floath.c index 795cb21082f..dd503bef51f 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float32-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-nan.c b/gcc/testsuite/gcc.dg/torture/float32-nan.c index c46b388a1c3..58ee6004a21 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float32-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c index 80441d720e2..c205ba2319e 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg.c b/gcc/testsuite/gcc.dg/torture/float32-tg.c index da480ca87c5..b5ea060f8a2 100644 --- a/gcc/testsuite/gcc.dg/torture/float32-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float32-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c index 3a5c2d0aa67..71eb7e2cdc8 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-floath.c b/gcc/testsuite/gcc.dg/torture/float32x-floath.c index 49e7ba4ed3a..ef2005ca74c 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-nan.c b/gcc/testsuite/gcc.dg/torture/float32x-nan.c index 770499d0660..d976d379732 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c index 897130a280f..6179aba7cdd 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg.c b/gcc/testsuite/gcc.dg/torture/float32x-tg.c index 9f9a3bf8682..b65b03f558b 100644 --- a/gcc/testsuite/gcc.dg/torture/float32x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float32x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float32x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float32x_runtime } */ #define WIDTH 32 diff --git a/gcc/testsuite/gcc.dg/torture/float64-builtin.c b/gcc/testsuite/gcc.dg/torture/float64-builtin.c index ff3cb295676..413768443ae 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float64-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-floath.c b/gcc/testsuite/gcc.dg/torture/float64-floath.c index a03d2e7dab7..3fb443b3726 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float64-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-nan.c b/gcc/testsuite/gcc.dg/torture/float64-nan.c index 5f1a2e8f933..51a6437fd52 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float64-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c index dddaa82122a..d0e4316611f 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg.c b/gcc/testsuite/gcc.dg/torture/float64-tg.c index c970d53b5ec..a7188312d57 100644 --- a/gcc/testsuite/gcc.dg/torture/float64-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float64-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64 } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-builtin.c b/gcc/testsuite/gcc.dg/torture/float64x-builtin.c index 2f95e8ad6d7..cc78ac011ad 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-builtin.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-builtin.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-floath.c b/gcc/testsuite/gcc.dg/torture/float64x-floath.c index 11eddc7036b..7fce730f386 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-floath.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-floath.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-nan.c b/gcc/testsuite/gcc.dg/torture/float64x-nan.c index 3d6496dee02..30e24b11e57 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-nan.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-nan.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "-fsignaling-nans" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ /* { dg-require-effective-target fenv_exceptions } */ diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c index 647d10406f0..8c3e4bdb802 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg.c b/gcc/testsuite/gcc.dg/torture/float64x-tg.c index ac14675a669..54a566c1e30 100644 --- a/gcc/testsuite/gcc.dg/torture/float64x-tg.c +++ b/gcc/testsuite/gcc.dg/torture/float64x-tg.c @@ -2,6 +2,7 @@ /* { dg-do run } */ /* { dg-options "" } */ /* { dg-add-options float64x } */ +/* { dg-add-options ieee } */ /* { dg-require-effective-target float64x_runtime } */ #define WIDTH 64 diff --git a/gcc/testsuite/gcc.dg/torture/pr70421.c b/gcc/testsuite/gcc.dg/torture/pr70421.c index 8f97acd42be..1aa4d534599 100644 --- a/gcc/testsuite/gcc.dg/torture/pr70421.c +++ b/gcc/testsuite/gcc.dg/torture/pr70421.c @@ -1,5 +1,6 @@ /* PR target/70421 */ /* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ /* { dg-additional-options "-Wno-psabi -w" } */ typedef unsigned V __attribute__ ((vector_size (64))); diff --git a/gcc/testsuite/gcc.dg/torture/pr77436.c b/gcc/testsuite/gcc.dg/torture/pr77436.c new file mode 100644 index 00000000000..513867db7ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77436.c @@ -0,0 +1,11 @@ +/* { dg-do run } */ + +int main() +{ + unsigned short sum = 0; + for (short x = -(__SHRT_MAX__ -1); x <= (__SHRT_MAX__ -1); x++) + sum += x; + if (sum != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77479.c b/gcc/testsuite/gcc.dg/torture/pr77479.c new file mode 100644 index 00000000000..354ae5986ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77479.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fstrict-overflow -ftree-vrp" } */ + +void +vr (int of, unsigned char bw) +{ + int d1; + int lm = 0; + + for (d1 = 0; d1 < 3; ++d1) + { + const int vl = 2; + + while (bw < vl) + { + } + if (bw != vl) + lm -= vl; + } + while (++of < 1) + { + lm /= bw; + of += lm; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77514.c b/gcc/testsuite/gcc.dg/torture/pr77514.c new file mode 100644 index 00000000000..464841ce364 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77514.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +void +m1 (char l0, char e8, int hw) +{ + char *rs = &l0; + +yu: + l0 = 1; + while (l0 != 0) + { + l0 = -l0; + l0 += (*rs ^ (l0 &= 1)); + } + for (;;) + { + if (hw != 0) + goto yu; + rs = &e8; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr77605.c b/gcc/testsuite/gcc.dg/torture/pr77605.c new file mode 100644 index 00000000000..3f1a26bc8d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr77605.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ + +int a, b, c[2][8]; + +int main () +{ + for (a = 0; a < 8; a++) + for (b = 0; b < 2; b++) + c[b][a] = c[b][b + 6] ^ 1; + + if (c[0][7] != 0) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c index e9b04a0e67d..95d6ee3b4a3 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c @@ -1,4 +1,6 @@ /* { dg-options "-O0 -pthread -fprofile-update=atomic" } */ +/* { dg-require-effective-target profile_update_atomic } */ + #include <pthread.h> #define NUM_THREADS 8 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c index d678dc8c2cd..79e65aa01f4 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr68198.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ +/* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */ extern void abort (void); @@ -40,4 +40,4 @@ c_finish_omp_clauses (tree clauses) /* There are 3 FSM jump threading opportunities, two of which will get filtered out. */ /* { dg-final { scan-tree-dump-times "Registering FSM" 1 "thread1"} } */ -/* { dg-final { scan-tree-dump-times "FSM Thread through multiway branch without threading a multiway branch" 2 "thread1"} } */ +/* { dg-final { scan-tree-dump-times "FSM Thread through multiway branch without threading a multiway branch" 2 "ethread"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c index 5842e28b94b..5f92447854b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr69196-1.c @@ -1,5 +1,5 @@ /* { dg-do compile { target sparc*-*-* x86_64-*-* } } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ +/* { dg-options "-O2 -fdump-tree-thread1-details -fdisable-tree-ethread" } */ /* { dg-final { scan-tree-dump "FSM did not thread around loop and would copy too many statements" "thread1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c index eb66136e47f..e1c33e86cd7 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2b.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-dom2-stats" } */ +/* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-dom2-stats -fdisable-tree-ethread" } */ void foo(); void bla(); diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c index f5f338ba357..061f2235533 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-13.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-details" } */ -/* { dg-final { scan-tree-dump "FSM" "thread1" } } */ +/* { dg-options "-O2 -fdump-tree-ethread-details" } */ +/* { dg-final { scan-tree-dump "FSM" "ethread" } } */ typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c index c6d10c2dbcf..f25f2761d47 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp01.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1" } */ +/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-ethread" } */ int foo (int *p, int i) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c index 3a64b017c18..c2870c45907 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp56.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-thread1-stats" } */ +/* { dg-options "-O2 -fdump-tree-ethread-stats" } */ typedef struct basic_block_def *basic_block; struct basic_block_def; struct edge_def; @@ -38,5 +38,5 @@ cleanup_empty_eh (basic_block bb) foo (); } } -/* { dg-final { scan-tree-dump "Jumps threaded: 1" "thread1"} } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 1" "ethread"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c index b096e9b3602..5d5375073e6 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp92.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-vrp1-details" } */ +/* { dg-options "-O2 -fdump-tree-vrp1-details -fdisable-tree-ethread" } */ void bar (void); int foo (int i, int j) diff --git a/gcc/testsuite/gcc.dg/uninit-15.c b/gcc/testsuite/gcc.dg/uninit-15.c index 20bea95acd8..6154f4b638a 100644 --- a/gcc/testsuite/gcc.dg/uninit-15.c +++ b/gcc/testsuite/gcc.dg/uninit-15.c @@ -1,16 +1,16 @@ /* PR tree-optimization/17506 We issue an uninitialized variable warning at a wrong location at line 11, which is very confusing. Make sure we print out a note to - make it less confusing. (xfailed alternative) + make it less confusing. (not xfailed alternative) But it is of course ok if we warn in bar about uninitialized use - of j. (not xfailed alternative) */ + of j. (xfailed alternative) */ /* { dg-do compile } */ /* { dg-options "-O1 -Wuninitialized" } */ inline int foo (int i) { - if (i) /* { dg-warning "used uninitialized in this function" "" { xfail *-*-* } } */ + if (i) /* { dg-warning "used uninitialized in this function" } */ return 1; return 0; } @@ -20,7 +20,7 @@ void baz (void); void bar (void) { - int j; /* { dg-message "note: 'j' was declared here" "" { xfail *-*-* } } */ - for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" } */ + int j; /* { dg-message "note: 'j' was declared here" } */ + for (; foo (j); ++j) /* { dg-warning "'j' is used uninitialized" "" { xfail *-*-* } } */ baz (); } diff --git a/gcc/testsuite/gcc.dg/vect/pr77503.c b/gcc/testsuite/gcc.dg/vect/pr77503.c new file mode 100644 index 00000000000..609e7fb5fd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr77503.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_condition } */ +/* { dg-skip-if "need vect_max_reduc support" { ! vect_max_reduc } } */ + +extern void d(void); +void a() { + char *b; + char c = 0; + for (; b < (char *)a; b++) { + if (*b) + c = 1; + *b = 0; + } + if (c) + d(); +} +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */ diff --git a/gcc/testsuite/gcc.misc-tests/gcov-13.c b/gcc/testsuite/gcc.misc-tests/gcov-13.c index e443f48532e..2c80559a34b 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-13.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-13.c @@ -1,8 +1,8 @@ /* Test gcov weak ellision. */ +/* { dg-do run { target native } } */ /* { dg-options "-fprofile-arcs -ftest-coverage" } */ /* { dg-require-weak "" } */ -/* { dg-do run { target native } } */ /* { dg-additional-sources "gcovpart-13b.c" } */ /* { dg-skip-if "weak ellision not supported" { { hppa*-*-hpux* } && { ! lp64 } } { "*" } { "" } } */ diff --git a/gcc/testsuite/gcc.misc-tests/gcov-14.c b/gcc/testsuite/gcc.misc-tests/gcov-14.c index 78dd7bedd76..2bebf7e4a93 100644 --- a/gcc/testsuite/gcc.misc-tests/gcov-14.c +++ b/gcc/testsuite/gcc.misc-tests/gcov-14.c @@ -1,10 +1,10 @@ /* Test gcov extern inline. */ +/* { dg-do run { target native } } */ /* { dg-options "-O2 -fprofile-arcs -ftest-coverage -fgnu89-inline" } */ /* The following line arranges that Darwin has behavior like elf weak import. */ /* { dg-additional-options "-flat_namespace -undefined suppress" { target *-*-darwin* } } */ /* { dg-require-weak "" } */ -/* { dg-do run { target native } } */ /* { dg-skip-if "undefined weak not supported" { { hppa*-*-hpux* } && { ! lp64 } } } */ /* { dg-skip-if "undefined weak not supported" { powerpc-ibm-aix* } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/ands_3.c b/gcc/testsuite/gcc.target/aarch64/ands_3.c new file mode 100644 index 00000000000..42cb7f0f0bc --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/ands_3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +f9 (unsigned char x, int y) +{ + if (y > 1 && x == 0) + return 10; + return x; +} + +/* { dg-final { scan-assembler "ands\t(x|w)\[0-9\]+,\[ \t\]*(x|w)\[0-9\]+,\[ \t\]*255" } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-1.c b/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-1.c index a0f59825227..0d60ef59509 100644 --- a/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-1.c +++ b/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-1.c @@ -1,4 +1,4 @@ -/* { dg-error "unknown" "" {target "aarch64*-*-*" } } */ +/* { dg-error "unknown" "" {target "aarch64*-*-*" } 0 } */ /* { dg-options "-O2 -march=dummy" } */ void f () diff --git a/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-2.c b/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-2.c index f1f3ea38c2a..cecba918818 100644 --- a/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-2.c +++ b/gcc/testsuite/gcc.target/aarch64/arch-diagnostics-2.c @@ -1,4 +1,4 @@ -/* { dg-error "missing" "" {target "aarch64*-*-*" } } */ +/* { dg-error "missing" "" {target "aarch64*-*-*" } 0 } */ /* { dg-options "-O2 -march=+dummy" } */ void f () diff --git a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-1.c b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-1.c index ddba6554471..4f330e8fda7 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-1.c +++ b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-1.c @@ -1,4 +1,4 @@ -/* { dg-error "unknown" "" {target "aarch64*-*-*" } } */ +/* { dg-error "unknown" "" {target "aarch64*-*-*" } 0 } */ /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "" } } */ /* { dg-options "-O2 -mcpu=dummy" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-2.c b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-2.c index ae42436031b..3701b10ac20 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-2.c +++ b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-2.c @@ -1,4 +1,4 @@ -/* { dg-error "missing" "" {target "aarch64*-*-*" } } */ +/* { dg-error "missing" "" {target "aarch64*-*-*" } 0 } */ /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "" } } */ /* { dg-options "-O2 -mcpu=cortex-a53+no" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-3.c b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-3.c index 8bc6e2fe049..04acba67353 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-3.c +++ b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-3.c @@ -1,4 +1,4 @@ -/* { dg-error "invalid feature" "" {target "aarch64*-*-*" } } */ +/* { dg-error "invalid feature" "" {target "aarch64*-*-*" } 0 } */ /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "" } } */ /* { dg-options "-O2 -mcpu=cortex-a53+dummy" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-4.c b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-4.c index 58355b42f84..268321e16e3 100644 --- a/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-4.c +++ b/gcc/testsuite/gcc.target/aarch64/cpu-diagnostics-4.c @@ -1,4 +1,4 @@ -/* { dg-error "missing" "" {target "aarch64*-*-*" } } */ +/* { dg-error "missing" "" {target "aarch64*-*-*" } 0 } */ /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "" } } */ /* { dg-options "-O2 -mcpu=+dummy" } */ diff --git a/gcc/testsuite/gcc.target/aarch64/thunderxloadpair.c b/gcc/testsuite/gcc.target/aarch64/thunderxloadpair.c new file mode 100644 index 00000000000..14b1f736093 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/thunderxloadpair.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=thunderx" } */ + +struct ldp +{ + long long c; + int a, b; +}; + + +int f(struct ldp *a) +{ + return a->a + a->b; +} + + +/* We know the alignement of a->a to be 8 byte aligned so it is profitable + to do ldp. */ +/* { dg-final { scan-assembler-times "ldp\tw\[0-9\]+, w\[0-9\]" 1 } } */ + diff --git a/gcc/testsuite/gcc.target/aarch64/thunderxnoloadpair.c b/gcc/testsuite/gcc.target/aarch64/thunderxnoloadpair.c new file mode 100644 index 00000000000..3093ad0e1f2 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/thunderxnoloadpair.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcpu=thunderx" } */ + +struct noldp +{ + int a, b; +}; + + +int f(struct noldp *a) +{ + return a->a + a->b; +} + +/* We know the alignement of a->a to be 4 byte aligned so it is not profitable + to do ldp. */ +/* { dg-final { scan-assembler-not "ldp\tw\[0-9\]+, w\[0-9\]" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c new file mode 100644 index 00000000000..bae00e4ee51 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-pr77476.c @@ -0,0 +1,9 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512bw" } */ +/* { dg-require-effective-target avx512bw } */ + +#include "avx512bw-check.h" +#define PR77476_TEST avx512bw_test + +#include "avx512f-pr77476.c" diff --git a/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c new file mode 100644 index 00000000000..77d024e053e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512dq-pr77476.c @@ -0,0 +1,9 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512dq" } */ +/* { dg-require-effective-target avx512dq } */ + +#include "avx512dq-check.h" +#define PR77476_TEST avx512dq_test + +#include "avx512f-pr77476.c" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-klogic-2.c b/gcc/testsuite/gcc.target/i386/avx512f-klogic-2.c index feff9558a15..ec09e4c6182 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-klogic-2.c +++ b/gcc/testsuite/gcc.target/i386/avx512f-klogic-2.c @@ -51,7 +51,7 @@ avx512f_test (void) dst = _mm512_kunpackb (src1, src2); x = _mm512_mask_add_ps (x, dst, x, x); - dst_ref = ((src2 << 8) | src1) & 0xFFFF; + dst_ref = ((src1 << 8) | src2) & 0xFFFF; if (dst != dst_ref) abort (); diff --git a/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c b/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c new file mode 100644 index 00000000000..f3bd509535a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-pr77476.c @@ -0,0 +1,76 @@ +/* PR target/77476 */ +/* { dg-do run } */ +/* { dg-options "-O2 -mavx512f" } */ +/* { dg-require-effective-target avx512f } */ + +#ifndef PR77476_TEST +#include "avx512f-check.h" +#define PR77476_TEST avx512f_test +#endif + +unsigned short s; +unsigned int i; +unsigned long long l; + +void +f1 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + s = a; +} + +void +f2 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + i = a; +} + +void +f3 (void) +{ + unsigned char a = 0xff; + asm volatile ("" : "+Yk" (a)); + l = a; +} + +void +f4 (void) +{ + unsigned short a = 0xffff; + asm volatile ("" : "+Yk" (a)); + i = a; +} + +void +f5 (void) +{ + unsigned short a = 0xffff; + asm volatile ("" : "+Yk" (a)); + l = a; +} + +#ifdef __AVX512BW__ +void +f6 (void) +{ + unsigned int a = 0xffffffff; + asm volatile ("" : "+Yk" (a)); + l = a; +} +#endif + +static void +PR77476_TEST () +{ + f1 (); if (s != 0xff) __builtin_abort (); s = 0; + f2 (); if (i != 0xff) __builtin_abort (); i = 0; + f3 (); if (l != 0xff) __builtin_abort (); l = 0; + f4 (); if (i != 0xffff) __builtin_abort (); i = 0; + f5 (); if (l != 0xffff) __builtin_abort (); l = 0; +#ifdef __AVX512BW__ + f6 (); if (l != 0xffffffff) __builtin_abort (); l = 0; +#endif +} diff --git a/gcc/testsuite/gcc.target/i386/pr65990.c b/gcc/testsuite/gcc.target/i386/pr65990.c index c0e5bb6fdf7..0ec8fadacf7 100644 --- a/gcc/testsuite/gcc.target/i386/pr65990.c +++ b/gcc/testsuite/gcc.target/i386/pr65990.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ /* { dg-options "-mtune=btver2 -mmemcpy-strategy=rep_8byte:-1:noalign" } -/* { dg-error "stringop strategy name rep_8byte specified for option -mmemcpy_strategy= not supported for 32-bit code" "" { target ia32 } 0 } */ +/* { dg-error "strategy name 'rep_8byte' specified for option '-mmemcpy_strategy=' not supported for 32-bit code" "" { target ia32 } 0 } */ struct U9 { diff --git a/gcc/testsuite/gcc.target/i386/pr68633.c b/gcc/testsuite/gcc.target/i386/pr68633.c index d7f513d276a..f2b594c3bc4 100644 --- a/gcc/testsuite/gcc.target/i386/pr68633.c +++ b/gcc/testsuite/gcc.target/i386/pr68633.c @@ -19,6 +19,6 @@ TEST () __asm__( "kmovw %1, %0" : "=k" (k2) : "r" (2) ); k3 = _mm512_kunpackb (k1, k2); - if (k3 != 0x201) + if (k3 != 0x102) abort (); } diff --git a/gcc/testsuite/gcc.target/i386/pr69255-1.c b/gcc/testsuite/gcc.target/i386/pr69255-1.c new file mode 100644 index 00000000000..7a666d34298 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr69255-1.c @@ -0,0 +1,17 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-msse4 -mno-avx" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "no-avx512vl" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p) +{ + a = __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} + +/* { dg-warning "AVX vector return without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ +/* { dg-warning "AVX vector argument without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr69255-2.c b/gcc/testsuite/gcc.target/i386/pr69255-2.c new file mode 100644 index 00000000000..28eb57bbfcc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr69255-2.c @@ -0,0 +1,17 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-msse4 -mno-avx" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p) +{ + __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} + +/* { dg-warning "AVX vector return without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ +/* { dg-warning "AVX vector argument without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr69255-3.c b/gcc/testsuite/gcc.target/i386/pr69255-3.c new file mode 100644 index 00000000000..41fb4a2cf50 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr69255-3.c @@ -0,0 +1,17 @@ +/* PR target/69255 */ +/* { dg-do compile } */ +/* { dg-options "-msse4 -mno-avx" } */ + +#pragma GCC target "avx512vl" +#pragma GCC target "" +__attribute__ ((__vector_size__ (32))) long long a; +__attribute__ ((__vector_size__ (16))) int b; + +void +foo (const long long *p, __attribute__ ((__vector_size__ (32))) long long *q) +{ + *q = __builtin_ia32_gather3siv4di (a, p, b, 1, 1); /* { dg-error "needs isa option -m32 -mavx512vl" } */ +} + +/* { dg-warning "AVX vector return without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ +/* { dg-warning "AVX vector argument without AVX enabled changes the ABI" "" { target *-*-* } 13 } */ diff --git a/gcc/testsuite/gcc.target/i386/pr77452.c b/gcc/testsuite/gcc.target/i386/pr77452.c new file mode 100644 index 00000000000..89c5329ff89 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr77452.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O -mavx512f -fno-split-wide-types --param max-combine-insns=2" } */ + +typedef unsigned int U __attribute__((vector_size(64))); +typedef unsigned __int128 V __attribute__((vector_size(64))); + +V +foo(V v) +{ + v[0] = 1u << (( ((V)(U){1, 1, v[0]})[0]) & 0xf) + >> ((-~((V)(U){1, 1, v[0]})[0]) & 0xf); + return v; +} diff --git a/gcc/testsuite/gcc.target/i386/pr77526.c b/gcc/testsuite/gcc.target/i386/pr77526.c new file mode 100644 index 00000000000..91b946a3660 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr77526.c @@ -0,0 +1,13 @@ +/* PR target/77526 */ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-Os -fno-forward-propagate -fno-gcse -fno-rerun-cse-after-loop -mstringop-strategy=byte_loop -Wno-psabi" } */ + +typedef char U __attribute__((vector_size(64))); +typedef __int128 V __attribute__((vector_size(64))); + +V +foo (int a, int b, __int128 c, U u) +{ + u = (u >> (u & 7)) | (u << -(u & 7)); + return a + b + c + (V)u; +} diff --git a/gcc/testsuite/gcc.target/i386/pr77594.c b/gcc/testsuite/gcc.target/i386/pr77594.c new file mode 100644 index 00000000000..96c51fd71fa --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr77594.c @@ -0,0 +1,11 @@ +/* PR middle-end/77594 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +int +foo (int a, int *b) +{ + return __builtin_sub_overflow (0, a, b); +} + +/* { dg-final { scan-assembler-times "\tjn?o\t" 1 } } */ diff --git a/gcc/testsuite/gcc.target/i386/spellcheck-options-1.c b/gcc/testsuite/gcc.target/i386/spellcheck-options-1.c new file mode 100644 index 00000000000..275f86c178d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/spellcheck-options-1.c @@ -0,0 +1,7 @@ +/* Verify that we provide a hint if the user misspells an option argument + (PR middle-end/77475). */ + +/* { dg-do compile } */ +/* { dg-options "-march=hasvel" } */ +/* { dg-error "bad value .'hasvel'. for '-march=' switch" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-march=' switch are: \[^\n\r]*; did you mean 'haswell'?" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/spellcheck-options-2.c b/gcc/testsuite/gcc.target/i386/spellcheck-options-2.c new file mode 100644 index 00000000000..848906245af --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/spellcheck-options-2.c @@ -0,0 +1,7 @@ +/* Verify that we provide a hint if the user misspells an option argument + (PR middle-end/77475). */ + +/* { dg-do compile } */ +/* { dg-options "-mtune=hasvel" } */ +/* { dg-error "bad value .'hasvel'. for '-mtune=' switch" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-mtune=' switch are: \[^\n\r]*; did you mean 'haswell'?" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/spellcheck-options-3.c b/gcc/testsuite/gcc.target/i386/spellcheck-options-3.c new file mode 100644 index 00000000000..115cef178bd --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/spellcheck-options-3.c @@ -0,0 +1,7 @@ +/* Verify that we provide a hint if the user misspells an option argument + (PR middle-end/77475). */ + +/* { dg-do compile } */ +/* { dg-options "-mmemcpy-strategy=unroled_looop:8:align" } */ +/* { dg-error "wrong strategy name 'unroled_looop' specified for option '-mmemcpy_strategy='" "" { target *-*-* } 0 } */ +/* { dg-message "valid arguments to '-mmemcpy_strategy=' are: \[^\n\r]*; did you mean 'unrolled_loop'?" "" { target *-*-* } 0 } */ diff --git a/gcc/testsuite/gcc.target/i386/spellcheck-options-4.c b/gcc/testsuite/gcc.target/i386/spellcheck-options-4.c new file mode 100644 index 00000000000..d39bd239f89 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/spellcheck-options-4.c @@ -0,0 +1,7 @@ +/* Verify that we provide a hint if the user misspells an option argument + (PR middle-end/77475). */ + +/* { dg-do compile } */ + +__attribute__((target ("arch=hasvel"))) void foo (void) {} /* { dg-error "bad value .'hasvel'. for 'target..arch=..' attribute" } */ +/* { dg-message "valid arguments to 'target..arch=..' attribute are: \[^\n\r]*; did you mean 'haswell'?" "" { target *-*-* } 6 } */ diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-1.c b/gcc/testsuite/gcc.target/msp430/function-attributes-1.c new file mode 100644 index 00000000000..7a3b7bea885 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-1.c @@ -0,0 +1,9 @@ +void __attribute__((weak, interrupt)) +weak_interrupt (void) { +} + +void __attribute__((interrupt(11))) +interrupt_number (void) { +} + +/* { dg-final { scan-assembler-times "__interrupt_vector_" 1 } } */ diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-2.c b/gcc/testsuite/gcc.target/msp430/function-attributes-2.c new file mode 100644 index 00000000000..fcb2fb2f011 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-2.c @@ -0,0 +1,3 @@ +void __attribute__((weak, interrupt(10))) +weak_interrupt_number (void) { +} /* { dg-error "argument to interrupt attribute is unsupported for weak functions" } */ diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-3.c b/gcc/testsuite/gcc.target/msp430/function-attributes-3.c new file mode 100644 index 00000000000..b0acf4aae52 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-3.c @@ -0,0 +1,3 @@ +void __attribute__((interrupt("nmi"))) __attribute__((weak)) +interrupt_name_weak (void) { +} /* { dg-error "argument to interrupt attribute is unsupported for weak functions" } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr77289.c b/gcc/testsuite/gcc.target/powerpc/pr77289.c new file mode 100644 index 00000000000..f8ebf1f9309 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr77289.c @@ -0,0 +1,31 @@ +/* { dg-do compile { target { powerpc*-*-* } } } */ +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */ +/* { dg-options "-O3 -mcpu=power7 -funroll-loops -ffast-math -mlra -mupdate -fno-auto-inc-dec" } */ + +/* PR 77289: LRA ICEs due to invalid constraint checking. */ + +void dummy0 (float *); +float bar0 (float); +void +foo0 (long a, long b) +{ + float c[0]; + b = 0; + for (; b < a; b++) + c[b] = bar0 (c[b]); + dummy0 (c); +} + +void dummy1 (long *); +long bar1 (long); +void +foo1 (long a, long b) +{ + long array[128]; + long *c = array; + for (b=0; b < a; b++) + c[b] = bar1 (c[b]); + dummy1 (c); +} diff --git a/gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c b/gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c new file mode 100644 index 00000000000..5b999488539 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c @@ -0,0 +1,18 @@ +/* { dg-do compile { target { powerpc64le-*-* } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O3 " } */ +/* { dg-final { scan-assembler "lxvd2x" } } */ +/* { dg-final { scan-assembler "stxvd2x" } } */ +/* { dg-final { scan-assembler-not "xxpermdi" } } */ + +/* Verify that swap optimization works correctly for a truncating splat. */ + +/* Test case to resolve PR77613. */ + +void pr77613 (signed short a, signed short *x, signed short *y) +{ + unsigned long i; + + for (i = 0; i < 1024; i++) + y[i] = a * x[i] + y[i]; +} diff --git a/gcc/testsuite/gfortran.dg/c_assoc_2.f03 b/gcc/testsuite/gfortran.dg/c_assoc_2.f03 index 275e88eadc3..fe6e5a9439a 100644 --- a/gcc/testsuite/gfortran.dg/c_assoc_2.f03 +++ b/gcc/testsuite/gfortran.dg/c_assoc_2.f03 @@ -20,7 +20,7 @@ contains call abort() end if - if(.not. c_associated()) then ! { dg-error "Missing actual argument 'C_PTR_1' in call to 'c_associated'" } + if(.not. c_associated()) then ! { dg-error "Missing actual argument" } call abort() end if diff --git a/gcc/testsuite/gfortran.dg/c_assoc_4.f90 b/gcc/testsuite/gfortran.dg/c_assoc_4.f90 index 5421a363f10..8a7fe736bc5 100644 --- a/gcc/testsuite/gfortran.dg/c_assoc_4.f90 +++ b/gcc/testsuite/gfortran.dg/c_assoc_4.f90 @@ -9,6 +9,6 @@ PROGRAM test TYPE (C_PTR) :: x, y - PRINT *, C_ASSOCIATED([x,y]) ! { dg-error "'C_PTR_1' argument of 'c_associated' intrinsic at .1. must be a scalar" } + PRINT *, C_ASSOCIATED([x,y]) ! { dg-error "'c_ptr_1' argument of 'c_associated' intrinsic at .1. must be a scalar" } END PROGRAM test diff --git a/gcc/testsuite/gfortran.dg/c_by_val_1.f b/gcc/testsuite/gfortran.dg/c_by_val_1.f index af1e25a6b88..3c5c3d7def7 100644 --- a/gcc/testsuite/gfortran.dg/c_by_val_1.f +++ b/gcc/testsuite/gfortran.dg/c_by_val_1.f @@ -9,8 +9,8 @@ C { dg-options "-ff2c -w -O0" } real(8) a8, b8, c8 integer(4) i, j, k integer(8) i8, j8, k8 - complex u, v, w, c_to_c - complex(8) u8, v8, w8, c_to_c8 + complex u, v, w + complex(8) u8, v8, w8 a = 42.0 b = 0.0 @@ -39,13 +39,13 @@ C { dg-options "-ff2c -w -O0" } u = (-1.0, 2.0) v = (1.0, -2.0) w = u - v = c_to_c (%VAL (u), %REF (w), %LOC (w)) + call c_to_c (v, %VAL (u), %REF (w), %LOC (w)) if ((4.0 * u).ne.v) call abort () u8 = (-1.0, 2.0) v8 = (1.0, -2.0) w8 = u8 - v8 = c_to_c8 (%VAL (u8), %REF (w8), %LOC (w8)) + call c_to_c8 (v8, %VAL (u8), %REF (w8), %LOC (w8)) if ((4.0 * u8).ne.v8) call abort () stop diff --git a/gcc/testsuite/gfortran.dg/dec_structure_14.f90 b/gcc/testsuite/gfortran.dg/dec_structure_14.f90 new file mode 100644 index 00000000000..4e271b7390f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_structure_14.f90 @@ -0,0 +1,18 @@ + ! { dg-do "compile" } + ! { dg-options "-fdec-structure" } + ! + ! Test that structures inside a common block do not require the + ! SEQUENCE attribute, as derived types do. + ! + +common var + +structure /s/ + integer i + integer j + real r +end structure + +record /s/ var + +end diff --git a/gcc/testsuite/gfortran.dg/dependency_47.f90 b/gcc/testsuite/gfortran.dg/dependency_47.f90 new file mode 100644 index 00000000000..4888771c183 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dependency_47.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! Make sure there is only one instance of a temporary variable here. +! { dg-options "-fdump-tree-original" } + +SUBROUTINE prtdata(ilen) + INTEGER :: ilen + character(len=ilen), allocatable :: cline(:) + allocate(cline(2)) + cline(1) = 'a' + cline(1)(2:3) = cline(1)(1:2) + cline(2) = cline(1) + print *,c +END SUBROUTINE prtdata +! { dg-final { scan-tree-dump-not "__var_" "original" } } diff --git a/gcc/testsuite/gfortran.dg/dependency_49.f90 b/gcc/testsuite/gfortran.dg/dependency_49.f90 new file mode 100644 index 00000000000..73d517e8f76 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dependency_49.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! PR fortran/71902 - make sure that component references are followed +! for dependency analysis. +program main + type foo + character(len=:), allocatable :: x + end type foo + type(foo) :: a + a%x = 'asdf' + a%x = a%x(2:3) + print *,a%x +end program main +! { dg-final { scan-tree-dump-times "__var_1" 4 "original" } } diff --git a/gcc/testsuite/gfortran.dg/dtio_11.f90 b/gcc/testsuite/gfortran.dg/dtio_11.f90 new file mode 100644 index 00000000000..cf8dd365d3c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dtio_11.f90 @@ -0,0 +1,39 @@ +! { dg-do compile } +! +! Test fixes for PRs77532-4. +! +! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> +! +! PR77532 - used to ICE +module m1 + type t + end type + interface read(unformatted) + end interface +end + +! PR77533 - used to ICE after error +module m2 + type t + type(unknown), pointer :: next ! { dg-error "is a type that has not been declared" } + contains + procedure :: s + generic :: write(formatted) => s + end type +contains + subroutine s(x) + end +end + +! PR77533 comment #1 - gave warning that +module m3 + type t + contains + procedure :: s ! { dg-error "Non-polymorphic passed-object" } + generic :: write(formatted) => s + end type +contains + subroutine s(x) ! { dg-error "must be of type CLASS" } + class(t), intent(in) : x ! { dg-error "Invalid character in name" } + end +end diff --git a/gcc/testsuite/gfortran.dg/fmt_f0_2.f90 b/gcc/testsuite/gfortran.dg/fmt_f0_2.f90 index 6e679fcecb8..4afba91389e 100644 --- a/gcc/testsuite/gfortran.dg/fmt_f0_2.f90 +++ b/gcc/testsuite/gfortran.dg/fmt_f0_2.f90 @@ -1,15 +1,23 @@ ! { dg-do run } ! PR77393 program testbigf0 ! Can enormous numbers be printed with F0.0 format? + use ISO_FORTRAN_ENV implicit none + integer i + integer, parameter :: j(size(real_kinds)+4)=[REAL_KINDS, [4, 4, 4, 4]] character(10000) :: str - write(str, "(f0.0)") -huge(1.0) - if (len(trim(str)).lt.41) error stop "FAILED AT LINE 7" - write(str, "(f0.0)") -huge(1.0_8) - if (len(trim(str)).lt.311) error stop "FAILED AT LINE 9" - write(str, "(f0.0)") -huge(1.0_10) - if (len(trim(str)).lt.4935) error stop "FAILED AT LINE 11" - write(str, "(f0.10)") -huge(1.0_16) - if (len(trim(str)).lt.4945) error stop "FAILED AT LINE 13" + + do i=1,size(real_kinds) + select case (i) + case (1) + write(str, "(f0.0)") -huge(real(1.0,kind=j(1))) + case (2) + write(str, "(f0.0)") -huge(real(1.0,kind=j(2))) + case (3) + write(str, "(f0.0)") -huge(real(1.0,kind=j(3))) + case (4) + write(str, "(f0.10)") -huge(real(1.0,kind=j(4))) + end select + enddo end program testbigf0 diff --git a/gcc/testsuite/gfortran.dg/fmt_f0_3.f90 b/gcc/testsuite/gfortran.dg/fmt_f0_3.f90 new file mode 100644 index 00000000000..905fe73b6f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/fmt_f0_3.f90 @@ -0,0 +1,23 @@ +! { dg-do run } +! PR77393, this segfaulted before +program testbigf0 + use ISO_FORTRAN_ENV + implicit none + integer i + integer, parameter :: j(size(real_kinds)+4)=[REAL_KINDS, [4, 4, 4, 4]] + character(10000) :: str + + do i=1,size(real_kinds) + select case (i) + case (1) + write(str, "(f8.0)") huge(real(1.0,kind=j(1))) + case (2) + write(str, "(f18.0)") huge(real(1.0,kind=j(2))) + case (3) + write(str, "(f20.0)") huge(real(1.0,kind=j(3))) + case (4) + write(str, "(f40.0)") huge(real(1.0,kind=j(4))) + end select + enddo +end program testbigf0 + diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 b/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 new file mode 100644 index 00000000000..a29714bd43c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr72743.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-additional-options "-O2" } + +program p + integer, parameter :: n = 8 + integer :: i, z(n) + z = [(i, i=1,n)] + print *, z +end +subroutine s + integer, parameter :: n = 8 + integer :: i, z(n) + z = [(i, i=1,n)] + print *, z +end diff --git a/gcc/testsuite/gfortran.dg/gomp/pr77500.f90 b/gcc/testsuite/gfortran.dg/gomp/pr77500.f90 new file mode 100644 index 00000000000..1572d5ceb24 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr77500.f90 @@ -0,0 +1,9 @@ +! PR fortran/77500 +! { dg-do compile } + +program pr77500 + real :: x +!$omp atomic write + x = f() +!$omp end atomic +end diff --git a/gcc/testsuite/gfortran.dg/gomp/pr77516.f90 b/gcc/testsuite/gfortran.dg/gomp/pr77516.f90 new file mode 100644 index 00000000000..7852abf8bcf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr77516.f90 @@ -0,0 +1,12 @@ +! PR fortran/77516 +! { dg-do compile } + +program pr77516 + integer :: i, x + x = 0 +!$omp simd safelen(0) reduction(+:x) + do i = 1, 8 + x = x + 1 + end do + print *, x +end diff --git a/gcc/testsuite/gfortran.dg/ieee/pr77507.f90 b/gcc/testsuite/gfortran.dg/ieee/pr77507.f90 new file mode 100644 index 00000000000..a72a0915ca0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ieee/pr77507.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +Program p + Use ieee_arithmetic + Use iso_c_binding + Print *, ieee_value(x=1.0, class=ieee_negative_inf) + Print *, c_associated(c_ptr_1=c_null_ptr) +End Program diff --git a/gcc/testsuite/gfortran.dg/misplaced_implicit_character.f90 b/gcc/testsuite/gfortran.dg/misplaced_implicit_character.f90 new file mode 100644 index 00000000000..8471d419eb0 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/misplaced_implicit_character.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/69963 +subroutine s + real x ! { dg-error "" } + implicit character (a) ! { dg-error "IMPLICIT statement at .1. cannot follow data declaration statement at .2." } + + a1 = 'z' ! { dg-error "Symbol .a1. at .1. has no IMPLICIT type" } +end subroutine s diff --git a/gcc/testsuite/gfortran.dg/pr68078.f90 b/gcc/testsuite/gfortran.dg/pr68078.f90 new file mode 100644 index 00000000000..4923ddd1830 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr68078.f90 @@ -0,0 +1,47 @@ +! { dg-do run } +! { dg-xfail-run-if "malloc issuing error messages" { *-*-darwin* } } +! { dg-additional-sources set_vm_limit.c } + +USE :: ISO_C_BINDING !, only: C_INT +IMPLICIT NONE + +INTERFACE + SUBROUTINE set_vm_limit(n) bind(C) + import + integer(C_INT), value, intent(in) :: n + END SUBROUTINE set_vm_limit +END INTERFACE + +TYPE foo + INTEGER, DIMENSION(10000) :: data = 42 +END TYPE +TYPE(foo), POINTER :: foo_ptr +TYPE(foo), ALLOCATABLE :: foo_obj +TYPE(foo), ALLOCATABLE, DIMENSION(:) :: foo_array + +INTEGER istat + +CALL set_vm_limit(1000000) + +DO + ALLOCATE(foo_ptr, stat = istat) + IF (istat .NE. 0) THEN + PRINT *, "foo_ptr allocation failed" + EXIT + ENDIF +ENDDO + +ALLOCATE(foo_obj, stat = istat) +IF (istat .NE. 0) THEN + PRINT *, "foo_obj allocation failed" +ENDIF + +ALLOCATE(foo_array(5), stat = istat) +IF (istat .NE. 0) THEN + PRINT *, "foo_array allocation failed" +ENDIF + +END +! { dg-output " *foo_ptr allocation failed(\n|\r\n|\r)" } +! { dg-output " *foo_obj allocation failed(\n|\r\n|\r)" } +! { dg-output " *foo_array allocation failed(\n|\r\n|\r)" } diff --git a/gcc/testsuite/gfortran.dg/pr69514_1.f90 b/gcc/testsuite/gfortran.dg/pr69514_1.f90 new file mode 100644 index 00000000000..d72a450dc58 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69514_1.f90 @@ -0,0 +1,5 @@ +! { dg-do run } +program foo + real, parameter :: x(3) = 2.0 * [real :: 1, 2, 3 ] + if (any(x /= [2., 4., 6.])) call abort +end program foo diff --git a/gcc/testsuite/gfortran.dg/pr69514_2.f90 b/gcc/testsuite/gfortran.dg/pr69514_2.f90 new file mode 100644 index 00000000000..0a5e8166a01 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69514_2.f90 @@ -0,0 +1,49 @@ +! { dg-do run } +program p + implicit none + + real , parameter :: arr(3) = [ real :: 2, 2.5, (1.5, 2.5) ] + real , parameter :: ari(3) = [ integer :: 2, 2.5, (1.5, 2.5) ] + real , parameter :: arc(3) = [ complex :: 2, 2.5, (1.5, 2.5) ] + integer, parameter :: air(3) = [ real :: 2, 2.5, (1.5, 2.5) ] + integer, parameter :: aii(3) = [ integer :: 2, 2.5, (1.5, 2.5) ] + integer, parameter :: aic(3) = [ complex :: 2, 2.5, (1.5, 2.5) ] + complex, parameter :: acr(3) = [ real :: 2, 2.5, (1.5, 2.5) ] + complex, parameter :: aci(3) = [ integer :: 2, 2.5, (1.5, 2.5) ] + complex, parameter :: acc(3) = [ complex :: 2, 2.5, (1.5, 2.5) ] + + real , parameter :: mrr(3) = 4.5 * [ real :: 2, 2.5, (3.5, 4.0) ] + real , parameter :: mri(3) = 4.5 * [ integer :: 2, 2.5, (3.5, 4.0) ] + real , parameter :: mrc(3) = 4.5 * [ complex :: 2, 2.5, (3.5, 4.0) ] + integer, parameter :: mir(3) = 4 * [ real :: 2, 2.5, (3.5, 4.0) ] + integer, parameter :: mii(3) = 4 * [ integer :: 2, 2.5, (3.5, 4.0) ] + integer, parameter :: mic(3) = 4 * [ complex :: 2, 2.5, (3.5, 4.0) ] + complex, parameter :: mcr(3) = (4.5, 5.5) * [ real :: 2, 2.5, (3.5, 4.0) ] + complex, parameter :: mci(3) = (4.5, 5.5) * [ integer :: 2, 2.5, (3.5, 4.0) ] + complex, parameter :: mcc(3) = (4.5, 5.5) * [ complex :: 2, 2.5, (3.5, 4.0) ] + + if (any(arr /= [2.00, 2.50, 1.50])) call abort + if (any(ari /= [2.00, 2.00, 1.00])) call abort + if (any(arc /= [2.00, 2.50, 1.50])) call abort + + if (any(air /= [2, 2, 1])) call abort + if (any(aii /= [2, 2, 1])) call abort + if (any(aic /= [2, 2, 1])) call abort + + if (any(acr /= [(2.00, 0.00), (2.50, 0.00), (1.50, 0.00)])) call abort + if (any(aci /= [(2.00, 0.00), (2.00, 0.00), (1.00, 0.00)])) call abort + if (any(acc /= [(2.00, 0.00), (2.50, 0.00), (1.50, 2.50)])) call abort + + if (any(mrr /= [9.00, 11.25, 15.75])) call abort + if (any(mri /= [9.00, 9.00, 13.50])) call abort + if (any(mrc /= [9.00, 11.25, 15.75])) call abort + + if (any(mir /= [8, 10, 14])) call abort + if (any(mii /= [8, 8, 12])) call abort + if (any(mic /= [8, 10, 14])) call abort + + if (any(mcr /= [(9.00, 11.00), (11.25, 13.75), (15.75, 19.25)])) call abort + if (any(mci /= [(9.00, 11.00), ( 9.00, 11.00), (13.50, 16.50)])) call abort + if (any(mcc /= [(9.00, 11.00), (11.25, 13.75), (-6.25, 37.25)])) call abort + +end program p diff --git a/gcc/testsuite/gfortran.dg/pr77391.f90 b/gcc/testsuite/gfortran.dg/pr77391.f90 new file mode 100644 index 00000000000..b3a455aa719 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77391.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +program picky +character(len=:), parameter :: a="whoops" ! { dg-error "POINTER or ALLOCATABLE" } +character(len=:) :: b="whoops" ! { dg-error "POINTER or ALLOCATABLE" } +character(len=:) :: good +pointer good +end program picky diff --git a/gcc/testsuite/gfortran.dg/pr77460.f90 b/gcc/testsuite/gfortran.dg/pr77460.f90 new file mode 100644 index 00000000000..5e28a99c176 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77460.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } + double precision, parameter :: x = huge(1d0) + print*, sum((/x,-x/)) + print*, sum((/x,x,-x,-x/)) ! { dg-error "overflow" } + print*, sum((/x,-x,1d0/)) + print*, sum((/1d0,x,-x/)) +end diff --git a/gcc/testsuite/gfortran.dg/pr77506.f90 b/gcc/testsuite/gfortran.dg/pr77506.f90 new file mode 100644 index 00000000000..70d874e260b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77506.f90 @@ -0,0 +1,4 @@ +! { dg-do compile } +program foo + print *, [character(len=*)::'ab','cd'] ! { dg-error "contain an asterisk" } +end program foo diff --git a/gcc/testsuite/gfortran.dg/pr77612.f90 b/gcc/testsuite/gfortran.dg/pr77612.f90 new file mode 100644 index 00000000000..7bc5a492c78 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77612.f90 @@ -0,0 +1,13 @@ +! { dg-do compile } + +program bad_len + + implicit none + +contains + + subroutine sub + character(len = ICE) :: line ! { dg-error "INTEGER expression expected" } + end subroutine + +end program diff --git a/gcc/testsuite/gfortran.dg/set_vm_limit.c b/gcc/testsuite/gfortran.dg/set_vm_limit.c new file mode 100644 index 00000000000..30c4b43e0ed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/set_vm_limit.c @@ -0,0 +1,22 @@ +/* Called by pr68078. */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> +#include <sys/resource.h> + +void +set_vm_limit (int vm_limit) +{ + struct rlimit rl = { vm_limit, RLIM_INFINITY }; + int r; + + r = setrlimit (RLIMIT_AS, &rl); + if (r) + { + perror ("set_vm_limit"); + exit (1); + } + + return; +} diff --git a/gcc/testsuite/gnat.dg/opt58.adb b/gcc/testsuite/gnat.dg/opt58.adb new file mode 100644 index 00000000000..ac39cc06056 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt58.adb @@ -0,0 +1,19 @@ +-- { dg-do compile }
+-- { dg-options "-O" }
+
+with Unchecked_Conversion;
+with System; use System;
+with Opt58_Pkg; use Opt58_Pkg;
+
+procedure Opt58 is
+
+ function Convert is new Unchecked_Conversion (Integer, Rec);
+
+ Dword : Integer := 0;
+ I : Small_Int := F1 (Convert (Dword));
+
+begin
+ if F2 (Null_Address, I = 0) then
+ null;
+ end if;
+end Opt58;
diff --git a/gcc/testsuite/gnat.dg/opt58_pkg.ads b/gcc/testsuite/gnat.dg/opt58_pkg.ads new file mode 100644 index 00000000000..9cb7f3a2540 --- /dev/null +++ b/gcc/testsuite/gnat.dg/opt58_pkg.ads @@ -0,0 +1,19 @@ +with System; use System;
+
+package Opt58_Pkg is
+
+ pragma Pure (Opt58_Pkg);
+
+ type Small_Int is range 0 .. 255;
+
+ type Rec is record
+ D1, D2, D3, D4 : Small_Int;
+ end record;
+ pragma Pack (Rec);
+ for Rec'Size use 32;
+
+ function F1 (R : Rec) return Small_Int;
+
+ function F2 (A : Address; B : Boolean) return Boolean;
+
+end Opt58_Pkg;
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 0dabea08501..6724a7fd214 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2909,10 +2909,10 @@ proc check_effective_target_vect_simd_clones { } { } else { set et_vect_simd_clones_saved($et_index) 0 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } { - # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and - # avx2 clone. Only the right clone for the specified arch will be - # chosen, but still we need to at least be able to assemble - # avx2. + # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx, avx2 + # and avx512f clone. Only the right clone for the specified arch + # will be chosen, but still we need to at least be able to assemble + # avx512f. if { [check_effective_target_avx512f] } { set et_vect_simd_clones_saved($et_index) 1 } @@ -7699,3 +7699,10 @@ proc check_effective_target_offload_hsa { } { int main () {return 0;} } "-foffload=hsa" ] } + +# Return 1 if the target support -fprofile-update=atomic +proc check_effective_target_profile_update_atomic {} { + return [check_no_compiler_messages profile_update_atomic assembly { + int main (void) { return 0; } + } "-fprofile-update=atomic -fprofile-generate"] +} diff --git a/gcc/toplev.c b/gcc/toplev.c index 26079047219..66099ec7d23 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -76,6 +76,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-chkp.h" #include "omp-low.h" #include "hsa.h" +#include "edit-context.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -1219,7 +1220,13 @@ process_options (void) no_backend = lang_hooks.post_options (&main_input_filename); /* Some machines may reject certain combinations of options. */ + location_t saved_location = input_location; + input_location = UNKNOWN_LOCATION; targetm.target_option.override (); + input_location = saved_location; + + if (flag_diagnostics_generate_patch) + global_dc->edit_context_ptr = new edit_context (); /* Avoid any informative notes in the second run of -fcompare-debug. */ if (flag_compare_debug) @@ -2147,6 +2154,16 @@ toplev::main (int argc, char **argv) emit some diagnostics here. */ invoke_plugin_callbacks (PLUGIN_FINISH, NULL); + if (flag_diagnostics_generate_patch) + { + gcc_assert (global_dc->edit_context_ptr); + + pretty_printer (pp); + pp_show_color (&pp) = pp_show_color (global_dc->printer); + global_dc->edit_context_ptr->print_diff (&pp, true); + pp_flush (&pp); + } + diagnostic_finish (global_dc); finalize_plugins (); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 57c84108a5c..badbd96951c 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7581,11 +7581,13 @@ dump_function_to_file (tree fndecl, FILE *file, int flags) any_var = true; } + + tree name; + if (gimple_in_ssa_p (cfun)) - for (ix = 1; ix < num_ssa_names; ++ix) + FOR_EACH_SSA_NAME (ix, name, cfun) { - tree name = ssa_name (ix); - if (name && !SSA_NAME_VAR (name)) + if (!SSA_NAME_VAR (name)) { fprintf (file, " "); print_generic_expr (file, TREE_TYPE (name), flags); diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 79f07b029d1..e7e47b1bc52 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -490,7 +490,6 @@ tree_fold_binomial (tree type, tree n, unsigned int k) { bool overflow; unsigned int i; - tree res; /* Handle the most frequent cases. */ if (k == 0) @@ -498,18 +497,20 @@ tree_fold_binomial (tree type, tree n, unsigned int k) if (k == 1) return fold_convert (type, n); + widest_int num = wi::to_widest (n); + /* Check that k <= n. */ - if (wi::ltu_p (n, k)) + if (wi::ltu_p (num, k)) return NULL_TREE; /* Denominator = 2. */ - wide_int denom = wi::two (TYPE_PRECISION (TREE_TYPE (n))); + widest_int denom = 2; /* Index = Numerator-1. */ - wide_int idx = wi::sub (n, 1); + widest_int idx = num - 1; /* Numerator = Numerator*Index = n*(n-1). */ - wide_int num = wi::smul (n, idx, &overflow); + num = wi::smul (num, idx, &overflow); if (overflow) return NULL_TREE; @@ -528,9 +529,10 @@ tree_fold_binomial (tree type, tree n, unsigned int k) } /* Result = Numerator / Denominator. */ - wide_int di_res = wi::udiv_trunc (num, denom); - res = wide_int_to_tree (type, di_res); - return int_fits_type_p (res, type) ? res : NULL_TREE; + num = wi::udiv_trunc (num, denom); + if (! wi::fits_to_tree_p (num, type)) + return NULL_TREE; + return wide_int_to_tree (type, num); } /* Helper function. Use the Newton's interpolating formula for diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 58da248040f..8152da3f180 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2686,13 +2686,13 @@ analyze_subscript_affine_affine (tree chrec_a, if (niter > 0) { - HOST_WIDE_INT tau2 = MIN (FLOOR_DIV (niter - i0, i1), - FLOOR_DIV (niter - j0, j1)); + HOST_WIDE_INT tau2 = MIN (FLOOR_DIV (niter_a - i0, i1), + FLOOR_DIV (niter_b - j0, j1)); HOST_WIDE_INT last_conflict = tau2 - (x1 - i0)/i1; /* If the overlap occurs outside of the bounds of the loop, there is no dependence. */ - if (x1 >= niter || y1 >= niter) + if (x1 >= niter_a || y1 >= niter_b) { *overlaps_a = conflict_fn_no_dependence (); *overlaps_b = conflict_fn_no_dependence (); diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index ceafa68b9ea..a4ff60876c3 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -2341,7 +2341,6 @@ pass_build_ssa::execute (function *fun) { bitmap_head *dfs; basic_block bb; - unsigned i; /* Initialize operand data structures. */ init_ssa_operands (fun); @@ -2385,13 +2384,14 @@ pass_build_ssa::execute (function *fun) /* Try to get rid of all gimplifier generated temporaries by making its SSA names anonymous. This way we can garbage collect them all after removing unused locals which we do in our TODO. */ - for (i = 1; i < num_ssa_names; ++i) + unsigned i; + tree name; + + FOR_EACH_SSA_NAME (i, name, cfun) { - tree decl, name = ssa_name (i); - if (!name - || SSA_NAME_IS_DEFAULT_DEF (name)) + if (SSA_NAME_IS_DEFAULT_DEF (name)) continue; - decl = SSA_NAME_VAR (name); + tree decl = SSA_NAME_VAR (name); if (decl && TREE_CODE (decl) == VAR_DECL && !VAR_DECL_IS_VIRTUAL_OPERAND (decl) @@ -3283,12 +3283,12 @@ update_ssa (unsigned update_flags) placement heuristics. */ prepare_block_for_update (start_bb, insert_phi_p); + tree name; + if (flag_checking) - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (!name - || virtual_operand_p (name)) + if (virtual_operand_p (name)) continue; /* For all but virtual operands, which do not have SSA names diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index c08845184bb..1317ad7ee9a 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -51,8 +51,8 @@ static const unsigned HOST_WIDE_INT unknown[4] = { }; static tree compute_object_offset (const_tree, const_tree); -static unsigned HOST_WIDE_INT addr_object_size (struct object_size_info *, - const_tree, int); +static bool addr_object_size (struct object_size_info *, + const_tree, int, unsigned HOST_WIDE_INT *); static unsigned HOST_WIDE_INT alloc_object_size (const gcall *, int); static tree pass_through_call (const gcall *); static void collect_object_sizes_for (struct object_size_info *, tree); @@ -163,14 +163,18 @@ compute_object_offset (const_tree expr, const_tree var) OBJECT_SIZE_TYPE is the second argument from __builtin_object_size. If unknown, return unknown[object_size_type]. */ -static unsigned HOST_WIDE_INT +static bool addr_object_size (struct object_size_info *osi, const_tree ptr, - int object_size_type) + int object_size_type, unsigned HOST_WIDE_INT *psize) { tree pt_var, pt_var_size = NULL_TREE, var_size, bytes; gcc_assert (TREE_CODE (ptr) == ADDR_EXPR); + /* Set to unknown and overwrite just before returning if the size + could be determined. */ + *psize = unknown[object_size_type]; + pt_var = TREE_OPERAND (ptr, 0); while (handled_component_p (pt_var)) pt_var = TREE_OPERAND (pt_var, 0); @@ -183,8 +187,8 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, if (!osi || (object_size_type & 1) != 0 || TREE_CODE (TREE_OPERAND (pt_var, 0)) != SSA_NAME) { - sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0), - object_size_type & ~1); + compute_builtin_object_size (TREE_OPERAND (pt_var, 0), + object_size_type & ~1, &sz); } else { @@ -224,7 +228,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, < offset_limit) pt_var_size = TYPE_SIZE_UNIT (TREE_TYPE (pt_var)); else - return unknown[object_size_type]; + return false; if (pt_var != TREE_OPERAND (ptr, 0)) { @@ -339,7 +343,7 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, if (var != pt_var) var_size = TYPE_SIZE_UNIT (TREE_TYPE (var)); else if (!pt_var_size) - return unknown[object_size_type]; + return false; else var_size = pt_var_size; bytes = compute_object_offset (TREE_OPERAND (ptr, 0), var); @@ -369,14 +373,17 @@ addr_object_size (struct object_size_info *osi, const_tree ptr, } } else if (!pt_var_size) - return unknown[object_size_type]; + return false; else bytes = pt_var_size; if (tree_fits_uhwi_p (bytes)) - return tree_to_uhwi (bytes); + { + *psize = tree_to_uhwi (bytes); + return true; + } - return unknown[object_size_type]; + return false; } @@ -484,142 +491,177 @@ pass_through_call (const gcall *call) } -/* Compute __builtin_object_size value for PTR. OBJECT_SIZE_TYPE is the - second argument from __builtin_object_size. */ +/* Compute __builtin_object_size value for PTR and set *PSIZE to + the resulting value. OBJECT_SIZE_TYPE is the second argument + to __builtin_object_size. Return true on success and false + when the object size could not be determined. */ -unsigned HOST_WIDE_INT -compute_builtin_object_size (tree ptr, int object_size_type) +bool +compute_builtin_object_size (tree ptr, int object_size_type, + unsigned HOST_WIDE_INT *psize) { gcc_assert (object_size_type >= 0 && object_size_type <= 3); + /* Set to unknown and overwrite just before returning if the size + could be determined. */ + *psize = unknown[object_size_type]; + if (! offset_limit) init_offset_limit (); if (TREE_CODE (ptr) == ADDR_EXPR) - return addr_object_size (NULL, ptr, object_size_type); + return addr_object_size (NULL, ptr, object_size_type, psize); + + if (TREE_CODE (ptr) != SSA_NAME + || !POINTER_TYPE_P (TREE_TYPE (ptr))) + return false; - if (TREE_CODE (ptr) == SSA_NAME - && POINTER_TYPE_P (TREE_TYPE (ptr)) - && computed[object_size_type] != NULL) + if (computed[object_size_type] == NULL) { - if (!bitmap_bit_p (computed[object_size_type], SSA_NAME_VERSION (ptr))) + if (optimize || object_size_type & 1) + return false; + + /* When not optimizing, rather than failing, make a small effort + to determine the object size without the full benefit of + the (costly) computation below. */ + gimple *def = SSA_NAME_DEF_STMT (ptr); + if (gimple_code (def) == GIMPLE_ASSIGN) { - struct object_size_info osi; - bitmap_iterator bi; - unsigned int i; - - if (num_ssa_names > object_sizes[object_size_type].length ()) - object_sizes[object_size_type].safe_grow (num_ssa_names); - if (dump_file) + tree_code code = gimple_assign_rhs_code (def); + if (code == POINTER_PLUS_EXPR) { - fprintf (dump_file, "Computing %s %sobject size for ", - (object_size_type & 2) ? "minimum" : "maximum", - (object_size_type & 1) ? "sub" : ""); - print_generic_expr (dump_file, ptr, dump_flags); - fprintf (dump_file, ":\n"); - } + tree offset = gimple_assign_rhs2 (def); + ptr = gimple_assign_rhs1 (def); - osi.visited = BITMAP_ALLOC (NULL); - osi.reexamine = BITMAP_ALLOC (NULL); - osi.object_size_type = object_size_type; - osi.depths = NULL; - osi.stack = NULL; - osi.tos = NULL; - - /* First pass: walk UD chains, compute object sizes that - can be computed. osi.reexamine bitmap at the end will - contain what variables were found in dependency cycles - and therefore need to be reexamined. */ - osi.pass = 0; - osi.changed = false; - collect_object_sizes_for (&osi, ptr); - - /* Second pass: keep recomputing object sizes of variables - that need reexamination, until no object sizes are - increased or all object sizes are computed. */ - if (! bitmap_empty_p (osi.reexamine)) - { - bitmap reexamine = BITMAP_ALLOC (NULL); - - /* If looking for minimum instead of maximum object size, - detect cases where a pointer is increased in a loop. - Although even without this detection pass 2 would eventually - terminate, it could take a long time. If a pointer is - increasing this way, we need to assume 0 object size. - E.g. p = &buf[0]; while (cond) p = p + 4; */ - if (object_size_type & 2) + if (cst_and_fits_in_hwi (offset) + && compute_builtin_object_size (ptr, object_size_type, psize)) { - osi.depths = XCNEWVEC (unsigned int, num_ssa_names); - osi.stack = XNEWVEC (unsigned int, num_ssa_names); - osi.tos = osi.stack; - osi.pass = 1; - /* collect_object_sizes_for is changing - osi.reexamine bitmap, so iterate over a copy. */ - bitmap_copy (reexamine, osi.reexamine); - EXECUTE_IF_SET_IN_BITMAP (reexamine, 0, i, bi) - if (bitmap_bit_p (osi.reexamine, i)) - check_for_plus_in_loops (&osi, ssa_name (i)); - - free (osi.depths); - osi.depths = NULL; - free (osi.stack); - osi.stack = NULL; - osi.tos = NULL; + /* Return zero when the offset is out of bounds. */ + unsigned HOST_WIDE_INT off = tree_to_shwi (offset); + *psize = off < *psize ? *psize - off : 0; + return true; } + } + } + return false; + } - do - { - osi.pass = 2; - osi.changed = false; - /* collect_object_sizes_for is changing - osi.reexamine bitmap, so iterate over a copy. */ - bitmap_copy (reexamine, osi.reexamine); - EXECUTE_IF_SET_IN_BITMAP (reexamine, 0, i, bi) - if (bitmap_bit_p (osi.reexamine, i)) - { - collect_object_sizes_for (&osi, ssa_name (i)); - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Reexamining "); - print_generic_expr (dump_file, ssa_name (i), - dump_flags); - fprintf (dump_file, "\n"); - } - } - } - while (osi.changed); + if (!bitmap_bit_p (computed[object_size_type], SSA_NAME_VERSION (ptr))) + { + struct object_size_info osi; + bitmap_iterator bi; + unsigned int i; + + if (num_ssa_names > object_sizes[object_size_type].length ()) + object_sizes[object_size_type].safe_grow (num_ssa_names); + if (dump_file) + { + fprintf (dump_file, "Computing %s %sobject size for ", + (object_size_type & 2) ? "minimum" : "maximum", + (object_size_type & 1) ? "sub" : ""); + print_generic_expr (dump_file, ptr, dump_flags); + fprintf (dump_file, ":\n"); + } - BITMAP_FREE (reexamine); + osi.visited = BITMAP_ALLOC (NULL); + osi.reexamine = BITMAP_ALLOC (NULL); + osi.object_size_type = object_size_type; + osi.depths = NULL; + osi.stack = NULL; + osi.tos = NULL; + + /* First pass: walk UD chains, compute object sizes that + can be computed. osi.reexamine bitmap at the end will + contain what variables were found in dependency cycles + and therefore need to be reexamined. */ + osi.pass = 0; + osi.changed = false; + collect_object_sizes_for (&osi, ptr); + + /* Second pass: keep recomputing object sizes of variables + that need reexamination, until no object sizes are + increased or all object sizes are computed. */ + if (! bitmap_empty_p (osi.reexamine)) + { + bitmap reexamine = BITMAP_ALLOC (NULL); + + /* If looking for minimum instead of maximum object size, + detect cases where a pointer is increased in a loop. + Although even without this detection pass 2 would eventually + terminate, it could take a long time. If a pointer is + increasing this way, we need to assume 0 object size. + E.g. p = &buf[0]; while (cond) p = p + 4; */ + if (object_size_type & 2) + { + osi.depths = XCNEWVEC (unsigned int, num_ssa_names); + osi.stack = XNEWVEC (unsigned int, num_ssa_names); + osi.tos = osi.stack; + osi.pass = 1; + /* collect_object_sizes_for is changing + osi.reexamine bitmap, so iterate over a copy. */ + bitmap_copy (reexamine, osi.reexamine); + EXECUTE_IF_SET_IN_BITMAP (reexamine, 0, i, bi) + if (bitmap_bit_p (osi.reexamine, i)) + check_for_plus_in_loops (&osi, ssa_name (i)); + + free (osi.depths); + osi.depths = NULL; + free (osi.stack); + osi.stack = NULL; + osi.tos = NULL; } - EXECUTE_IF_SET_IN_BITMAP (osi.reexamine, 0, i, bi) - bitmap_set_bit (computed[object_size_type], i); - /* Debugging dumps. */ - if (dump_file) + do { - EXECUTE_IF_SET_IN_BITMAP (osi.visited, 0, i, bi) - if (object_sizes[object_size_type][i] - != unknown[object_size_type]) + osi.pass = 2; + osi.changed = false; + /* collect_object_sizes_for is changing + osi.reexamine bitmap, so iterate over a copy. */ + bitmap_copy (reexamine, osi.reexamine); + EXECUTE_IF_SET_IN_BITMAP (reexamine, 0, i, bi) + if (bitmap_bit_p (osi.reexamine, i)) { - print_generic_expr (dump_file, ssa_name (i), - dump_flags); - fprintf (dump_file, - ": %s %sobject size " - HOST_WIDE_INT_PRINT_UNSIGNED "\n", - (object_size_type & 2) ? "minimum" : "maximum", - (object_size_type & 1) ? "sub" : "", - object_sizes[object_size_type][i]); + collect_object_sizes_for (&osi, ssa_name (i)); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Reexamining "); + print_generic_expr (dump_file, ssa_name (i), + dump_flags); + fprintf (dump_file, "\n"); + } } } + while (osi.changed); - BITMAP_FREE (osi.reexamine); - BITMAP_FREE (osi.visited); + BITMAP_FREE (reexamine); } + EXECUTE_IF_SET_IN_BITMAP (osi.reexamine, 0, i, bi) + bitmap_set_bit (computed[object_size_type], i); - return object_sizes[object_size_type][SSA_NAME_VERSION (ptr)]; + /* Debugging dumps. */ + if (dump_file) + { + EXECUTE_IF_SET_IN_BITMAP (osi.visited, 0, i, bi) + if (object_sizes[object_size_type][i] + != unknown[object_size_type]) + { + print_generic_expr (dump_file, ssa_name (i), + dump_flags); + fprintf (dump_file, + ": %s %sobject size " + HOST_WIDE_INT_PRINT_UNSIGNED "\n", + (object_size_type & 2) ? "minimum" : "maximum", + (object_size_type & 1) ? "sub" : "", + object_sizes[object_size_type][i]); + } + } + + BITMAP_FREE (osi.reexamine); + BITMAP_FREE (osi.visited); } - return unknown[object_size_type]; + *psize = object_sizes[object_size_type][SSA_NAME_VERSION (ptr)]; + return *psize != unknown[object_size_type]; } /* Compute object_sizes for PTR, defined to VALUE, which is not an SSA_NAME. */ @@ -643,7 +685,7 @@ expr_object_size (struct object_size_info *osi, tree ptr, tree value) || !POINTER_TYPE_P (TREE_TYPE (value))); if (TREE_CODE (value) == ADDR_EXPR) - bytes = addr_object_size (osi, value, object_size_type); + addr_object_size (osi, value, object_size_type, &bytes); else bytes = unknown[object_size_type]; @@ -809,7 +851,7 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt) unsigned HOST_WIDE_INT off = tree_to_uhwi (op1); /* op0 will be ADDR_EXPR here. */ - bytes = addr_object_size (osi, op0, object_size_type); + addr_object_size (osi, op0, object_size_type, &bytes); if (bytes == unknown[object_size_type]) ; else if (off > offset_limit) @@ -1282,10 +1324,9 @@ pass_object_sizes::execute (function *fun) && lhs) { tree type = TREE_TYPE (lhs); - unsigned HOST_WIDE_INT bytes - = compute_builtin_object_size (ptr, object_size_type); - if (bytes != (unsigned HOST_WIDE_INT) (object_size_type == 1 - ? -1 : 0) + unsigned HOST_WIDE_INT bytes; + if (compute_builtin_object_size (ptr, object_size_type, + &bytes) && wi::fits_to_tree_p (bytes, type)) { tree tem = make_ssa_name (type); diff --git a/gcc/tree-object-size.h b/gcc/tree-object-size.h index 836f6d3f64e..38c3e073327 100644 --- a/gcc/tree-object-size.h +++ b/gcc/tree-object-size.h @@ -21,6 +21,6 @@ along with GCC; see the file COPYING3. If not see #define GCC_TREE_OBJECT_SIZE_H extern void init_object_sizes (void); -extern unsigned HOST_WIDE_INT compute_builtin_object_size (tree, int); +extern bool compute_builtin_object_size (tree, int, unsigned HOST_WIDE_INT *); #endif // GCC_TREE_OBJECT_SIZE_H diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index c0059de89ff..cc87b184d67 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -399,6 +399,7 @@ extern gimple_opt_pass *make_pass_cd_dce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_call_cdce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_merge_phi (gcc::context *ctxt); extern gimple_opt_pass *make_pass_thread_jumps (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_early_thread_jumps (gcc::context *ctxt); extern gimple_opt_pass *make_pass_split_crit_edges (gcc::context *ctxt); extern gimple_opt_pass *make_pass_laddress (gcc::context *ctxt); extern gimple_opt_pass *make_pass_pre (gcc::context *ctxt); diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 734ecda7c56..0915fd4243e 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -1353,7 +1353,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, int flags, ? "unsigned long long" : "signed long long")); else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE - && exact_log2 (TYPE_PRECISION (node)) != -1) + && pow2p_hwi (TYPE_PRECISION (node))) { pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int")); pp_decimal_int (pp, TYPE_PRECISION (node)); diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 622869ebb27..69b48e59be4 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -528,6 +528,20 @@ gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base) gsi_insert_before (&gsi, call, GSI_NEW_STMT); } +#ifndef HAVE_sync_compare_and_swapsi +#define HAVE_sync_compare_and_swapsi 0 +#endif +#ifndef HAVE_atomic_compare_and_swapsi +#define HAVE_atomic_compare_and_swapsi 0 +#endif + +#ifndef HAVE_sync_compare_and_swapdi +#define HAVE_sync_compare_and_swapdi 0 +#endif +#ifndef HAVE_atomic_compare_and_swapdi +#define HAVE_atomic_compare_and_swapdi 0 +#endif + /* Profile all functions in the callgraph. */ static unsigned int @@ -535,6 +549,27 @@ tree_profiling (void) { struct cgraph_node *node; + /* Verify whether we can utilize atomic update operations. */ + if (flag_profile_update == PROFILE_UPDATE_ATOMIC) + { + bool can_support = false; + unsigned HOST_WIDE_INT gcov_type_size + = tree_to_uhwi (TYPE_SIZE_UNIT (get_gcov_type ())); + if (gcov_type_size == 4) + can_support + = HAVE_sync_compare_and_swapsi || HAVE_atomic_compare_and_swapsi; + else if (gcov_type_size == 8) + can_support + = HAVE_sync_compare_and_swapdi || HAVE_atomic_compare_and_swapdi; + + if (!can_support) + { + warning (0, "target does not support atomic profile update, " + "single mode is selected"); + flag_profile_update = PROFILE_UPDATE_SINGLE; + } + } + /* This is a small-ipa pass that gets called only once, from cgraphunit.c:ipa_passes(). */ gcc_assert (symtab->state == IPA_SSA); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 3c7e4c0c9cc..4a2ff0d174c 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1680,7 +1680,7 @@ build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, misalign = (misalign + offset) & (align - 1); if (misalign != 0) - align = (misalign & -misalign); + align = least_bit_hwi (misalign); if (align != TYPE_ALIGN (exp_type)) exp_type = build_aligned_type (exp_type, align); diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 8051a669b37..30de4612598 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -450,6 +450,7 @@ void dump_alias_info (FILE *file) { unsigned i; + tree ptr; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); tree var; @@ -471,13 +472,11 @@ dump_alias_info (FILE *file) fprintf (file, "\n\nFlow-insensitive points-to information\n\n"); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, ptr, cfun) { - tree ptr = ssa_name (i); struct ptr_info_def *pi; - if (ptr == NULL_TREE - || !POINTER_TYPE_P (TREE_TYPE (ptr)) + if (!POINTER_TYPE_P (TREE_TYPE (ptr)) || SSA_NAME_IN_FREE_LIST (ptr)) continue; diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 987130403ce..b6ccb59d241 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -898,24 +898,23 @@ ccp_finalize (bool nonzero_p) { bool something_changed; unsigned i; + tree name; do_dbg_cnt (); /* Derive alignment and misalignment information from partially constant pointers in the lattice or nonzero bits from partially constant integers. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); ccp_prop_value_t *val; unsigned int tem, align; - if (!name - || (!POINTER_TYPE_P (TREE_TYPE (name)) - && (!INTEGRAL_TYPE_P (TREE_TYPE (name)) - /* Don't record nonzero bits before IPA to avoid - using too much memory. */ - || !nonzero_p))) + if (!POINTER_TYPE_P (TREE_TYPE (name)) + && (!INTEGRAL_TYPE_P (TREE_TYPE (name)) + /* Don't record nonzero bits before IPA to avoid + using too much memory. */ + || !nonzero_p)) continue; val = get_value (name); @@ -929,7 +928,7 @@ ccp_finalize (bool nonzero_p) /* Trailing mask bits specify the alignment, trailing value bits the misalignment. */ tem = val->mask.to_uhwi (); - align = (tem & -tem); + align = least_bit_hwi (tem); if (align > 1) set_ptr_info_alignment (get_ptr_info (name), align, (TREE_INT_CST_LOW (val->value) diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 34c3fa16ccf..01f6c5f8239 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -955,12 +955,11 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) if (bb == entry) { unsigned i; - for (i = 1; i < num_ssa_names; i++) - { - tree var = ssa_name (i); + tree var; - if (!var - || !SSA_NAME_IS_DEFAULT_DEF (var) + FOR_EACH_SSA_NAME (i, var, cfun) + { + if (!SSA_NAME_IS_DEFAULT_DEF (var) || !SSA_NAME_VAR (var) || VAR_P (SSA_NAME_VAR (var))) continue; @@ -1261,10 +1260,9 @@ create_outofssa_var_map (coalesce_list *cl, bitmap used_in_copy) /* Now process result decls and live on entry variables for entry into the coalesce list. */ first = NULL_TREE; - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, var, cfun) { - var = ssa_name (i); - if (var != NULL_TREE && !virtual_operand_p (var)) + if (!virtual_operand_p (var)) { coalesce_with_default (var, cl, used_in_copy); @@ -1806,6 +1804,7 @@ coalesce_ssa_name (void) bitmap used_in_copies = BITMAP_ALLOC (NULL); var_map map; unsigned int i; + tree a; cl = create_coalesce_list (); map = create_outofssa_var_map (cl, used_in_copies); @@ -1817,12 +1816,9 @@ coalesce_ssa_name (void) { hash_table<ssa_name_var_hash> ssa_name_hash (10); - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, a, cfun) { - tree a = ssa_name (i); - - if (a - && SSA_NAME_VAR (a) + if (SSA_NAME_VAR (a) && !DECL_IGNORED_P (SSA_NAME_VAR (a)) && (!has_zero_uses (a) || !SSA_NAME_IS_DEFAULT_DEF (a) || !VAR_P (SSA_NAME_VAR (a)))) diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 3d1792646b6..fcf4fa9464a 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -503,14 +503,13 @@ static bool fini_copy_prop (void) { unsigned i; + tree var; /* Set the final copy-of value for each variable by traversing the copy-of chains. */ - for (i = 1; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, var, cfun) { - tree var = ssa_name (i); - if (!var - || !copy_of[i].value + if (!copy_of[i].value || copy_of[i].value == var) continue; diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 8bf5b3c9ffe..b007388f3ea 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1923,12 +1923,11 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si, { tree val = NULL; - update_stmt_if_modified (stmt); - if (gimple_code (stmt) == GIMPLE_COND) val = fold_binary_loc (gimple_location (stmt), - gimple_cond_code (stmt), boolean_type_node, - gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); + gimple_cond_code (stmt), boolean_type_node, + gimple_cond_lhs (stmt), + gimple_cond_rhs (stmt)); else if (gswitch *swtch_stmt = dyn_cast <gswitch *> (stmt)) val = gimple_switch_index (swtch_stmt); @@ -1946,6 +1945,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si, gimple_cond_make_true (as_a <gcond *> (stmt)); else gcc_unreachable (); + + gimple_set_modified (stmt, true); } /* Further simplifications may be possible. */ @@ -1953,6 +1954,8 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si, } } + update_stmt_if_modified (stmt); + /* If we simplified a statement in such a way as to be shown that it cannot trap, update the eh information and the cfg to match. */ if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt)) diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 62ba71bd18a..6886790a4c5 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5168,10 +5168,11 @@ cand_value_at (struct loop *loop, struct iv_cand *cand, gimple *at, tree niter, aff_tree step, delta, nit; struct iv *iv = cand->iv; tree type = TREE_TYPE (iv->base); - tree steptype = type; + tree steptype; if (POINTER_TYPE_P (type)) steptype = sizetype; - steptype = unsigned_type_for (type); + else + steptype = unsigned_type_for (type); tree_to_aff_combination (iv->step, TREE_TYPE (iv->step), &step); aff_combination_convert (&step, steptype); diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index b93bcf348d1..0cea1a8472d 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -2647,7 +2647,7 @@ bswap_replace (gimple *cur_stmt, gimple *src_stmt, tree fndecl, unsigned HOST_WIDE_INT l = (load_offset * BITS_PER_UNIT) & (align - 1); if (l) - align = l & -l; + align = least_bit_hwi (l); } } diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index eccea2f62b9..a5c354699a0 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1247,11 +1247,8 @@ dump_immediate_uses (FILE *file) unsigned int x; fprintf (file, "Immediate_uses: \n\n"); - for (x = 1; x < num_ssa_names; x++) + FOR_EACH_SSA_NAME (x, var, cfun) { - var = ssa_name (x); - if (!var) - continue; dump_immediate_uses_for (file, var); } } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index fdb1c2c3965..0c6f82093c4 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2879,7 +2879,24 @@ create_expression_by_pieces (basic_block block, pre_expr expr, gimple_seq_discard (forced_stmts); return folded; } - + /* Likewise if we simplified to sth not queued for insertion. */ + bool found = false; + gsi = gsi_last (forced_stmts); + for (; !gsi_end_p (gsi); gsi_prev (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + tree forcedname = gimple_get_lhs (stmt); + if (forcedname == folded) + { + found = true; + break; + } + } + if (! found) + { + gimple_seq_discard (forced_stmts); + return folded; + } gcc_assert (TREE_CODE (folded) == SSA_NAME); /* If we have any intermediate expressions to the value sets, add them @@ -3670,15 +3687,14 @@ compute_avail (void) basic_block *worklist; size_t sp = 0; unsigned i; + tree name; /* We pretend that default definitions are defined in the entry block. This includes function arguments and the static chain decl. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); pre_expr e; - if (!name - || !SSA_NAME_IS_DEFAULT_DEF (name) + if (!SSA_NAME_IS_DEFAULT_DEF (name) || has_zero_uses (name) || virtual_operand_p (name)) continue; diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 21b3d566052..e120b4f72dc 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -4290,7 +4290,6 @@ free_vn_table (vn_tables_t table) static void init_scc_vn (void) { - size_t i; int j; int *rpo_numbers_temp; @@ -4339,12 +4338,11 @@ init_scc_vn (void) /* Create the VN_INFO structures, and initialize value numbers to TOP or VARYING for parameters. */ - for (i = 1; i < num_ssa_names; i++) - { - tree name = ssa_name (i); - if (!name) - continue; + size_t i; + tree name; + FOR_EACH_SSA_NAME (i, name, cfun) + { VN_INFO_GET (name)->valnum = VN_TOP; VN_INFO (name)->needs_insertion = false; VN_INFO (name)->expr = NULL; @@ -4402,11 +4400,12 @@ init_scc_vn (void) void scc_vn_restore_ssa_info (void) { - for (unsigned i = 0; i < num_ssa_names; i++) + unsigned i; + tree name; + + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (name - && has_VN_INFO (name)) + if (has_VN_INFO (name)) { if (VN_INFO (name)->needs_insertion) ; @@ -4428,6 +4427,7 @@ void free_scc_vn (void) { size_t i; + tree name; delete constant_to_value_id; constant_to_value_id = NULL; @@ -4436,11 +4436,9 @@ free_scc_vn (void) shared_lookup_references.release (); XDELETEVEC (rpo_numbers); - for (i = 0; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (name - && has_VN_INFO (name) + if (has_VN_INFO (name) && VN_INFO (name)->needs_insertion) release_ssa_name (name); } @@ -4797,13 +4795,11 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) /* Initialize the value ids and prune out remaining VN_TOPs from dead code. */ - for (i = 1; i < num_ssa_names; ++i) + tree name; + + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - vn_ssa_aux_t info; - if (!name) - continue; - info = VN_INFO (name); + vn_ssa_aux_t info = VN_INFO (name); if (!info->visited) info->valnum = name; if (info->valnum == name @@ -4814,13 +4810,9 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) } /* Propagate. */ - for (i = 1; i < num_ssa_names; ++i) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - vn_ssa_aux_t info; - if (!name) - continue; - info = VN_INFO (name); + vn_ssa_aux_t info = VN_INFO (name); if (TREE_CODE (info->valnum) == SSA_NAME && info->valnum != name && info->value_id != VN_INFO (info->valnum)->value_id) @@ -4832,11 +4824,9 @@ run_scc_vn (vn_lookup_kind default_vn_walk_kind_) if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "Value numbers:\n"); - for (i = 0; i < num_ssa_names; i++) + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (name - && VN_INFO (name)->visited + if (VN_INFO (name)->visited && SSA_VAL (name) != name) { print_generic_expr (dump_file, name, 0); diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 9d7b4df4b1e..339812e91c0 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -1983,7 +1983,7 @@ handle_builtin_memcmp (gimple_stmt_iterator *gsi) if (tree_fits_uhwi_p (len) && (leni = tree_to_uhwi (len)) <= GET_MODE_SIZE (word_mode) - && exact_log2 (leni) != -1) + && pow2p_hwi (leni)) { leni *= CHAR_TYPE_SIZE; unsigned align1 = get_pointer_alignment (arg1); diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index fd96c3ab797..cbf509befe0 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -7028,7 +7028,6 @@ static void compute_points_to_sets (void) { basic_block bb; - unsigned i; varinfo_t vi; timevar_push (TV_TREE_PTA); @@ -7077,11 +7076,12 @@ compute_points_to_sets (void) cfun->gimple_df->escaped.escaped = 0; /* Compute the points-to sets for pointer SSA_NAMEs. */ - for (i = 0; i < num_ssa_names; ++i) + unsigned i; + tree ptr; + + FOR_EACH_SSA_NAME (i, ptr, cfun) { - tree ptr = ssa_name (i); - if (ptr - && POINTER_TYPE_P (TREE_TYPE (ptr))) + if (POINTER_TYPE_P (TREE_TYPE (ptr))) find_what_p_points_to (cfun->decl, ptr); } diff --git a/gcc/tree-ssa-ter.c b/gcc/tree-ssa-ter.c index 2a772b253e1..c7d8b7eb204 100644 --- a/gcc/tree-ssa-ter.c +++ b/gcc/tree-ssa-ter.c @@ -185,8 +185,6 @@ extern void debug_ter (FILE *, temp_expr_table *); static temp_expr_table * new_temp_expr_table (var_map map) { - unsigned x; - temp_expr_table *t = XNEW (struct temp_expr_table); t->map = map; @@ -201,12 +199,13 @@ new_temp_expr_table (var_map map) t->replaceable_expressions = NULL; t->num_in_part = XCNEWVEC (int, num_var_partitions (map)); - for (x = 1; x < num_ssa_names; x++) + + unsigned x; + tree name; + + FOR_EACH_SSA_NAME (x, name, cfun) { int p; - tree name = ssa_name (x); - if (!name) - continue; p = var_to_partition (map, name); if (p != NO_PARTITION) t->num_in_part[p]++; diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 506078f2358..6b522adcefb 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -61,12 +61,14 @@ get_gimple_control_stmt (basic_block bb) /* Return true if the CFG contains at least one path from START_BB to END_BB. When a path is found, record in PATH the blocks from END_BB to START_BB. VISITED_BBS is used to make sure we don't fall into an infinite loop. Bound - the recursion to basic blocks belonging to LOOP. */ + the recursion to basic blocks belonging to LOOP. + SPEED_P indicate that we could increase code size to improve the code path */ static bool fsm_find_thread_path (basic_block start_bb, basic_block end_bb, vec<basic_block, va_gc> *&path, - hash_set<basic_block> *visited_bbs, loop_p loop) + hash_set<basic_block> *visited_bbs, loop_p loop, + bool speed_p) { if (loop != start_bb->loop_father) return false; @@ -82,7 +84,8 @@ fsm_find_thread_path (basic_block start_bb, basic_block end_bb, edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, start_bb->succs) - if (fsm_find_thread_path (e->dest, end_bb, path, visited_bbs, loop)) + if (fsm_find_thread_path (e->dest, end_bb, path, visited_bbs, loop, + speed_p)) { vec_safe_push (path, start_bb); return true; @@ -101,11 +104,13 @@ fsm_find_thread_path (basic_block start_bb, basic_block end_bb, value on PATH. ARG is the value of that SSA_NAME. BBI will be appended to PATH when we have a profitable jump threading - path. Callers are responsible for removing BBI from PATH in that case. */ + path. Callers are responsible for removing BBI from PATH in that case. + + SPEED_P indicate that we could increase code size to improve the code path */ static edge profitable_jump_thread_path (vec<basic_block, va_gc> *&path, - basic_block bbi, tree name, tree arg) + basic_block bbi, tree name, tree arg, bool speed_p) { /* Note BBI is not in the path yet, hence the +1 in the test below to make sure BBI is accounted for in the path length test. */ @@ -307,7 +312,7 @@ profitable_jump_thread_path (vec<basic_block, va_gc> *&path, return NULL; } - if (optimize_edge_for_speed_p (taken_edge)) + if (speed_p && optimize_edge_for_speed_p (taken_edge)) { if (n_insns >= PARAM_VALUE (PARAM_MAX_FSM_THREAD_PATH_INSNS)) { @@ -422,13 +427,15 @@ convert_and_register_jump_thread_path (vec<basic_block, va_gc> *path, /* We trace the value of the SSA_NAME NAME back through any phi nodes looking for places where it gets a constant value and save the path. Stop after - having recorded MAX_PATHS jump threading paths. */ + having recorded MAX_PATHS jump threading paths. + + SPEED_P indicate that we could increase code size to improve the code path */ static void fsm_find_control_statement_thread_paths (tree name, hash_set<basic_block> *visited_bbs, vec<basic_block, va_gc> *&path, - bool seen_loop_phi) + bool seen_loop_phi, bool speed_p) { /* If NAME appears in an abnormal PHI, then don't try to trace its value back through PHI nodes. */ @@ -496,7 +503,7 @@ fsm_find_control_statement_thread_paths (tree name, hash_set<basic_block> *visited_bbs = new hash_set<basic_block>; if (fsm_find_thread_path (var_bb, e->src, next_path, visited_bbs, - e->src->loop_father)) + e->src->loop_father, speed_p)) ++e_count; delete visited_bbs; @@ -562,7 +569,7 @@ fsm_find_control_statement_thread_paths (tree name, /* Recursively follow SSA_NAMEs looking for a constant definition. */ fsm_find_control_statement_thread_paths (arg, visited_bbs, path, - seen_loop_phi); + seen_loop_phi, speed_p); path->pop (); continue; @@ -573,7 +580,8 @@ fsm_find_control_statement_thread_paths (tree name, /* If this is a profitable jump thread path, then convert it into the canonical form and register it. */ - edge taken_edge = profitable_jump_thread_path (path, bbi, name, arg); + edge taken_edge = profitable_jump_thread_path (path, bbi, name, arg, + speed_p); if (taken_edge) { if (bb_loop_depth (taken_edge->src) @@ -589,7 +597,7 @@ fsm_find_control_statement_thread_paths (tree name, if (TREE_CODE (arg) == SSA_NAME) fsm_find_control_statement_thread_paths (arg, visited_bbs, - path, seen_loop_phi); + path, seen_loop_phi, speed_p); else { @@ -599,7 +607,7 @@ fsm_find_control_statement_thread_paths (tree name, path->pop (); edge taken_edge = profitable_jump_thread_path (path, var_bb, - name, arg); + name, arg, speed_p); if (taken_edge) { if (bb_loop_depth (taken_edge->src) @@ -623,10 +631,11 @@ fsm_find_control_statement_thread_paths (tree name, is a constant. Record such paths for jump threading. It is assumed that BB ends with a control statement and that by - finding a path where NAME is a constant, we can thread the path. */ + finding a path where NAME is a constant, we can thread the path. + SPEED_P indicate that we could increase code size to improve the code path */ void -find_jump_threads_backwards (basic_block bb) +find_jump_threads_backwards (basic_block bb, bool speed_p) { gimple *stmt = get_gimple_control_stmt (bb); if (!stmt) @@ -656,7 +665,8 @@ find_jump_threads_backwards (basic_block bb) hash_set<basic_block> *visited_bbs = new hash_set<basic_block>; max_threaded_paths = PARAM_VALUE (PARAM_MAX_FSM_THREAD_PATHS); - fsm_find_control_statement_thread_paths (name, visited_bbs, bb_path, false); + fsm_find_control_statement_thread_paths (name, visited_bbs, bb_path, false, + speed_p); delete visited_bbs; vec_free (bb_path); @@ -706,7 +716,7 @@ pass_thread_jumps::execute (function *fun) FOR_EACH_BB_FN (bb, fun) { if (EDGE_COUNT (bb->succs) > 1) - find_jump_threads_backwards (bb); + find_jump_threads_backwards (bb, true); } bool changed = thread_through_all_blocks (true); @@ -721,3 +731,59 @@ make_pass_thread_jumps (gcc::context *ctxt) { return new pass_thread_jumps (ctxt); } + +namespace { + +const pass_data pass_data_early_thread_jumps = +{ + GIMPLE_PASS, + "ethread", + OPTGROUP_NONE, + TV_TREE_SSA_THREAD_JUMPS, + ( PROP_cfg | PROP_ssa ), + 0, + 0, + 0, + ( TODO_cleanup_cfg | TODO_update_ssa ), +}; + +class pass_early_thread_jumps : public gimple_opt_pass +{ +public: + pass_early_thread_jumps (gcc::context *ctxt) + : gimple_opt_pass (pass_data_early_thread_jumps, ctxt) + {} + + opt_pass * clone (void) { return new pass_early_thread_jumps (m_ctxt); } + virtual bool gate (function *); + virtual unsigned int execute (function *); +}; + +bool +pass_early_thread_jumps::gate (function *fun ATTRIBUTE_UNUSED) +{ + return true; +} + + +unsigned int +pass_early_thread_jumps::execute (function *fun) +{ + /* Try to thread each block with more than one successor. */ + basic_block bb; + FOR_EACH_BB_FN (bb, fun) + { + if (EDGE_COUNT (bb->succs) > 1) + find_jump_threads_backwards (bb, false); + } + thread_through_all_blocks (true); + return 0; +} + +} + +gimple_opt_pass * +make_pass_early_thread_jumps (gcc::context *ctxt) +{ + return new pass_early_thread_jumps (ctxt); +} diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index aae383d5108..d442a5f89e1 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -1005,7 +1005,6 @@ error: DEBUG_FUNCTION void verify_ssa (bool check_modified_stmt, bool check_ssa_operands) { - size_t i; basic_block bb; basic_block *definition_block = XCNEWVEC (basic_block, num_ssa_names); ssa_op_iter iter; @@ -1018,24 +1017,23 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands) timevar_push (TV_TREE_SSA_VERIFY); /* Keep track of SSA names present in the IL. */ - for (i = 1; i < num_ssa_names; i++) + size_t i; + tree name; + + FOR_EACH_SSA_NAME (i, name, cfun) { - tree name = ssa_name (i); - if (name) - { - gimple *stmt; - TREE_VISITED (name) = 0; + gimple *stmt; + TREE_VISITED (name) = 0; - verify_ssa_name (name, virtual_operand_p (name)); + verify_ssa_name (name, virtual_operand_p (name)); - stmt = SSA_NAME_DEF_STMT (name); - if (!gimple_nop_p (stmt)) - { - basic_block bb = gimple_bb (stmt); - if (verify_def (bb, definition_block, - name, stmt, virtual_operand_p (name))) - goto err; - } + stmt = SSA_NAME_DEF_STMT (name); + if (!gimple_nop_p (stmt)) + { + basic_block bb = gimple_bb (stmt); + if (verify_def (bb, definition_block, + name, stmt, virtual_operand_p (name))) + goto err; } } diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index 8e66ce6f3ce..4496e1d044c 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -62,6 +62,10 @@ struct GTY ((variable_size)) range_info_def { #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names)) #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)]) +#define FOR_EACH_SSA_NAME(I, VAR, FN) \ + for (I = 1; SSANAMES (FN)->iterate (I, &VAR); ++I) \ + if (VAR) + /* Sets the value range to SSA. */ extern void set_range_info (tree, enum value_range_type, const wide_int_ref &, const wide_int_ref &); diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index e908c865fbd..03c4a66103e 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -2241,7 +2241,7 @@ vect_analyze_group_access_1 (struct data_reference *dr) if (DR_IS_READ (dr) && (dr_step % type_size) == 0 && groupsize > 0 - && exact_log2 (groupsize) != -1) + && pow2p_hwi (groupsize)) { GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = stmt; GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize; @@ -4736,7 +4736,7 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count) else { /* If length is not equal to 3 then only power of 2 is supported. */ - gcc_assert (exact_log2 (count) != -1); + gcc_assert (pow2p_hwi (count)); for (i = 0; i < nelt / 2; i++) { @@ -4914,7 +4914,7 @@ vect_permute_store_chain (vec<tree> dr_chain, else { /* If length is not equal to 3 then only power of 2 is supported. */ - gcc_assert (exact_log2 (length) != -1); + gcc_assert (pow2p_hwi (length)); for (i = 0, n = nelt / 2; i < n; i++) { @@ -5309,7 +5309,7 @@ vect_grouped_load_supported (tree vectype, bool single_element_p, else { /* If length is not equal to 3 then only power of 2 is supported. */ - gcc_assert (exact_log2 (count) != -1); + gcc_assert (pow2p_hwi (count)); for (i = 0; i < nelt; i++) sel[i] = i * 2; if (can_vec_perm_p (mode, false, sel)) @@ -5483,7 +5483,7 @@ vect_permute_load_chain (vec<tree> dr_chain, else { /* If length is not equal to 3 then only power of 2 is supported. */ - gcc_assert (exact_log2 (length) != -1); + gcc_assert (pow2p_hwi (length)); for (i = 0; i < nelt; ++i) sel[i] = i * 2; @@ -5632,7 +5632,7 @@ vect_shift_permute_load_chain (vec<tree> dr_chain, memcpy (result_chain->address (), dr_chain.address (), length * sizeof (tree)); - if (exact_log2 (length) != -1 && LOOP_VINFO_VECT_FACTOR (loop_vinfo) > 4) + if (pow2p_hwi (length) && LOOP_VINFO_VECT_FACTOR (loop_vinfo) > 4) { unsigned int j, log_length = exact_log2 (length); for (i = 0; i < nelt / 2; ++i) @@ -5880,7 +5880,7 @@ vect_transform_grouped_load (gimple *stmt, vec<tree> dr_chain, int size, get chain for loads group using vect_shift_permute_load_chain. */ mode = TYPE_MODE (STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt))); if (targetm.sched.reassociation_width (VEC_PERM_EXPR, mode) > 1 - || exact_log2 (size) != -1 + || pow2p_hwi (size) || !vect_shift_permute_load_chain (dr_chain, size, stmt, gsi, &result_chain)) vect_permute_load_chain (dr_chain, size, stmt, gsi, &result_chain); diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c index 9f0ec656bad..5d4273fcd0e 100644 --- a/gcc/tree-vect-generic.c +++ b/gcc/tree-vect-generic.c @@ -494,7 +494,7 @@ expand_vector_divmod (gimple_stmt_iterator *gsi, tree type, tree op0, || (!has_vector_shift && pre_shift != -1)) { if (has_vector_shift) - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); else if (pre_shift == -1) { unsigned int j; diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index fa06505d1f2..58f3456fe40 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -5438,7 +5438,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, tree def0, def1, tem, op1 = NULL_TREE; bool first_p = true; tree cr_index_scalar_type = NULL_TREE, cr_index_vector_type = NULL_TREE; - tree cond_reduc_val = NULL_TREE, const_cond_cmp = NULL_TREE; + tree cond_reduc_val = NULL_TREE; /* In case of reduction chain we switch to the first stmt in the chain, but we don't update STMT_INFO, since only the last stmt is marked as reduction @@ -5645,7 +5645,19 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, = INTEGER_INDUC_COND_REDUCTION; } - if (cond_reduc_dt == vect_constant_def) + /* Loop peeling modifies initial value of reduction PHI, which + makes the reduction stmt to be transformed different to the + original stmt analyzed. We need to record reduction code for + CONST_COND_REDUCTION type reduction at analyzing stage, thus + it can be used directly at transform stage. */ + if (STMT_VINFO_VEC_CONST_COND_REDUC_CODE (stmt_info) == MAX_EXPR + || STMT_VINFO_VEC_CONST_COND_REDUC_CODE (stmt_info) == MIN_EXPR) + { + /* Also set the reduction type to CONST_COND_REDUCTION. */ + gcc_assert (cond_reduc_dt == vect_constant_def); + STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = CONST_COND_REDUCTION; + } + else if (cond_reduc_dt == vect_constant_def) { enum vect_def_type cond_initial_dt; gimple *def_stmt = SSA_NAME_DEF_STMT (ops[reduc_index]); @@ -5667,7 +5679,9 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, dump_printf_loc (MSG_NOTE, vect_location, "condition expression based on " "compile time constant.\n"); - const_cond_cmp = e; + /* Record reduction code at analysis stage. */ + STMT_VINFO_VEC_CONST_COND_REDUC_CODE (stmt_info) + = integer_onep (e) ? MAX_EXPR : MIN_EXPR; STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = CONST_COND_REDUCTION; } @@ -5821,10 +5835,8 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi, we want to base our reduction around. */ if (STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) == CONST_COND_REDUCTION) { - gcc_assert (const_cond_cmp != NULL_TREE); - gcc_assert (integer_onep (const_cond_cmp) - || integer_zerop (const_cond_cmp)); - orig_code = integer_onep (const_cond_cmp) ? MAX_EXPR : MIN_EXPR; + orig_code = STMT_VINFO_VEC_CONST_COND_REDUC_CODE (stmt_info); + gcc_assert (orig_code == MAX_EXPR || orig_code == MIN_EXPR); } else if (STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) == INTEGER_INDUC_COND_REDUCTION) diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 7e6e45d1d54..3dfbc7bb63d 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -2736,7 +2736,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts, for even divisors, using an initial right shift. */ if (mh != 0 && (d & 1) == 0) { - pre_shift = floor_log2 (d & -d); + pre_shift = ctz_or_zero (d); mh = choose_multiplier (d >> pre_shift, prec, prec - pre_shift, &ml, &post_shift, &dummy_int); gcc_assert (!mh); diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index ce5536c6927..a83071c1a70 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -2340,7 +2340,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, misalign); tree ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), - misalign ? misalign & -misalign : align); + misalign ? least_bit_hwi (misalign) : align); new_stmt = gimple_build_call_internal (IFN_MASK_STORE, 4, dataref_ptr, ptr, vec_mask, vec_rhs); @@ -2390,7 +2390,7 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi, set_ptr_info_alignment (get_ptr_info (dataref_ptr), align, misalign); tree ptr = build_int_cst (TREE_TYPE (gimple_call_arg (stmt, 1)), - misalign ? misalign & -misalign : align); + misalign ? least_bit_hwi (misalign) : align); new_stmt = gimple_build_call_internal (IFN_MASK_LOAD, 3, dataref_ptr, ptr, vec_mask); @@ -8563,6 +8563,7 @@ new_stmt_vec_info (gimple *stmt, vec_info *vinfo) STMT_VINFO_PATTERN_DEF_SEQ (res) = NULL; STMT_VINFO_DATA_REF (res) = NULL; STMT_VINFO_VEC_REDUCTION_TYPE (res) = TREE_CODE_REDUCTION; + STMT_VINFO_VEC_CONST_COND_REDUC_CODE (res) = ERROR_MARK; STMT_VINFO_DR_BASE_ADDRESS (res) = NULL; STMT_VINFO_DR_OFFSET (res) = NULL; diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 29ef676cbf4..240af069a51 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -657,6 +657,9 @@ typedef struct _stmt_vec_info { /* For reduction loops, this is the type of reduction. */ enum vect_reduction_type v_reduc_type; + /* For CONST_COND_REDUCTION, record the reduc code. */ + enum tree_code const_cond_reduc_code; + /* The number of scalar stmt references from active SLP instances. */ unsigned int num_slp_uses; } *stmt_vec_info; @@ -711,6 +714,7 @@ STMT_VINFO_BB_VINFO (stmt_vec_info stmt_vinfo) #define STMT_VINFO_MEMORY_ACCESS_TYPE(S) (S)->memory_access_type #define STMT_VINFO_SIMD_LANE_ACCESS_P(S) (S)->simd_lane_access_p #define STMT_VINFO_VEC_REDUCTION_TYPE(S) (S)->v_reduc_type +#define STMT_VINFO_VEC_CONST_COND_REDUC_CODE(S) (S)->const_cond_reduc_code #define STMT_VINFO_DR_BASE_ADDRESS(S) (S)->dr_base_address #define STMT_VINFO_DR_INIT(S) (S)->dr_init diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 45882c438ba..e7067ab8e6e 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -744,23 +744,29 @@ update_value_range (const_tree var, value_range *new_vr) value_range_type rtype = get_range_info (var, &min, &max); if (rtype == VR_RANGE || rtype == VR_ANTI_RANGE) { - value_range nr; - nr.type = rtype; + tree nr_min, nr_max; /* Range info on SSA names doesn't carry overflow information so make sure to preserve the overflow bit on the lattice. */ - if (new_vr->type == VR_RANGE - && is_negative_overflow_infinity (new_vr->min) - && wi::eq_p (new_vr->min, min)) - nr.min = new_vr->min; + if (rtype == VR_RANGE + && needs_overflow_infinity (TREE_TYPE (var)) + && (new_vr->type == VR_VARYING + || (new_vr->type == VR_RANGE + && is_negative_overflow_infinity (new_vr->min))) + && wi::eq_p (vrp_val_min (TREE_TYPE (var)), min)) + nr_min = negative_overflow_infinity (TREE_TYPE (var)); else - nr.min = wide_int_to_tree (TREE_TYPE (var), min); - if (new_vr->type == VR_RANGE - && is_positive_overflow_infinity (new_vr->max) - && wi::eq_p (new_vr->max, max)) - nr.max = new_vr->max; + nr_min = wide_int_to_tree (TREE_TYPE (var), min); + if (rtype == VR_RANGE + && needs_overflow_infinity (TREE_TYPE (var)) + && (new_vr->type == VR_VARYING + || (new_vr->type == VR_RANGE + && is_positive_overflow_infinity (new_vr->max))) + && wi::eq_p (vrp_val_max (TREE_TYPE (var)), max)) + nr_max = positive_overflow_infinity (TREE_TYPE (var)); else - nr.max = wide_int_to_tree (TREE_TYPE (var), max); - nr.equiv = NULL; + nr_max = wide_int_to_tree (TREE_TYPE (var), max); + value_range nr = VR_INITIALIZER; + set_and_canonicalize_value_range (&nr, rtype, nr_min, nr_max, NULL); vrp_intersect_ranges (new_vr, &nr); } } diff --git a/gcc/tsan.c b/gcc/tsan.c index aa95f4ee69e..aba21f81bd6 100644 --- a/gcc/tsan.c +++ b/gcc/tsan.c @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. If not see #include "tsan.h" #include "asan.h" #include "builtins.h" +#include "target.h" /* Number of instrumented memory accesses in the current function. */ @@ -174,7 +175,7 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) if ((align - 1) & bitpos) { align = (align - 1) & bitpos; - align = align & -align; + align = least_bit_hwi (align); } expr = build_fold_addr_expr (unshare_expr (base)); expr = build2 (MEM_REF, char_type_node, expr, @@ -240,7 +241,8 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write) enum tsan_atomic_action { check_last, add_seq_cst, add_acquire, weak_cas, strong_cas, - bool_cas, val_cas, lock_release, fetch_op, fetch_op_seq_cst + bool_cas, val_cas, lock_release, fetch_op, fetch_op_seq_cst, + bool_clear, bool_test_and_set }; /* Table how to map sync/atomic builtins to their corresponding @@ -274,6 +276,10 @@ static const struct tsan_map_atomic TRANSFORM (fcode, tsan_fcode, fetch_op, code) #define FETCH_OPS(fcode, tsan_fcode, code) \ TRANSFORM (fcode, tsan_fcode, fetch_op_seq_cst, code) +#define BOOL_CLEAR(fcode, tsan_fcode) \ + TRANSFORM (fcode, tsan_fcode, bool_clear, ERROR_MARK) +#define BOOL_TEST_AND_SET(fcode, tsan_fcode) \ + TRANSFORM (fcode, tsan_fcode, bool_test_and_set, ERROR_MARK) CHECK_LAST (ATOMIC_LOAD_1, TSAN_ATOMIC8_LOAD), CHECK_LAST (ATOMIC_LOAD_2, TSAN_ATOMIC16_LOAD), @@ -463,7 +469,11 @@ static const struct tsan_map_atomic LOCK_RELEASE (SYNC_LOCK_RELEASE_2, TSAN_ATOMIC16_STORE), LOCK_RELEASE (SYNC_LOCK_RELEASE_4, TSAN_ATOMIC32_STORE), LOCK_RELEASE (SYNC_LOCK_RELEASE_8, TSAN_ATOMIC64_STORE), - LOCK_RELEASE (SYNC_LOCK_RELEASE_16, TSAN_ATOMIC128_STORE) + LOCK_RELEASE (SYNC_LOCK_RELEASE_16, TSAN_ATOMIC128_STORE), + + BOOL_CLEAR (ATOMIC_CLEAR, TSAN_ATOMIC8_STORE), + + BOOL_TEST_AND_SET (ATOMIC_TEST_AND_SET, TSAN_ATOMIC8_EXCHANGE) }; /* Instrument an atomic builtin. */ @@ -615,6 +625,57 @@ instrument_builtin_call (gimple_stmt_iterator *gsi) build_int_cst (NULL_TREE, MEMMODEL_RELEASE)); return; + case bool_clear: + case bool_test_and_set: + if (BOOL_TYPE_SIZE != 8) + { + decl = NULL_TREE; + for (j = 1; j < 5; j++) + if (BOOL_TYPE_SIZE == (8 << j)) + { + enum built_in_function tsan_fcode + = (enum built_in_function) + (tsan_atomic_table[i].tsan_fcode + j); + decl = builtin_decl_implicit (tsan_fcode); + break; + } + if (decl == NULL_TREE) + return; + } + last_arg = gimple_call_arg (stmt, num - 1); + if (!tree_fits_uhwi_p (last_arg) + || memmodel_base (tree_to_uhwi (last_arg)) >= MEMMODEL_LAST) + return; + t = TYPE_ARG_TYPES (TREE_TYPE (decl)); + t = TREE_VALUE (TREE_CHAIN (t)); + if (tsan_atomic_table[i].action == bool_clear) + { + update_gimple_call (gsi, decl, 3, gimple_call_arg (stmt, 0), + build_int_cst (t, 0), last_arg); + return; + } + t = build_int_cst (t, targetm.atomic_test_and_set_trueval); + update_gimple_call (gsi, decl, 3, gimple_call_arg (stmt, 0), + t, last_arg); + stmt = gsi_stmt (*gsi); + lhs = gimple_call_lhs (stmt); + if (lhs == NULL_TREE) + return; + if (targetm.atomic_test_and_set_trueval != 1 + || !useless_type_conversion_p (TREE_TYPE (lhs), + TREE_TYPE (t))) + { + tree new_lhs = make_ssa_name (TREE_TYPE (t)); + gimple_call_set_lhs (stmt, new_lhs); + if (targetm.atomic_test_and_set_trueval != 1) + g = gimple_build_assign (lhs, NE_EXPR, new_lhs, + build_int_cst (TREE_TYPE (t), 0)); + else + g = gimple_build_assign (lhs, NOP_EXPR, new_lhs); + gsi_insert_after (gsi, g, GSI_NEW_STMT); + update_stmt (stmt); + } + return; default: continue; } diff --git a/gcc/typed-splay-tree.c b/gcc/typed-splay-tree.c new file mode 100644 index 00000000000..33992c1f8c0 --- /dev/null +++ b/gcc/typed-splay-tree.c @@ -0,0 +1,79 @@ +/* Selftests for typed-splay-tree.h. + Copyright (C) 2016 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "typed-splay-tree.h" +#include "selftest.h" + +#if CHECKING_P + +namespace selftest { + +/* Callback for use by test_str_to_int. */ + +static int +append_cb (const char *, int value, void *user_data) +{ + auto_vec <int> *vec = (auto_vec <int> *)user_data; + vec->safe_push (value); + return 0; +} + +/* Test of typed_splay_tree <const char *, int>. */ + +static void +test_str_to_int () +{ + typed_splay_tree <const char *, int> t (strcmp, NULL, NULL); + + t.insert ("a", 1); + t.insert ("b", 2); + t.insert ("c", 3); + + ASSERT_EQ (1, t.lookup ("a")); + ASSERT_EQ (2, t.lookup ("b")); + ASSERT_EQ (3, t.lookup ("c")); + + ASSERT_EQ (2, t.predecessor ("c")); + ASSERT_EQ (3, t.successor ("b")); + ASSERT_EQ (1, t.min ()); + ASSERT_EQ (3, t.max ()); + + /* Test foreach by appending to a vec, and verifying the vec. */ + auto_vec <int> v; + t.foreach (append_cb, &v); + ASSERT_EQ (3, v.length ()); + ASSERT_EQ (1, v[0]); + ASSERT_EQ (2, v[1]); + ASSERT_EQ (3, v[2]); +} + +/* Run all of the selftests within this file. */ + +void +typed_splay_tree_c_tests () +{ + test_str_to_int (); +} + +} // namespace selftest + +#endif /* #if CHECKING_P */ diff --git a/gcc/typed-splay-tree.h b/gcc/typed-splay-tree.h index 9dd96d61029..7b8afef2b1d 100644 --- a/gcc/typed-splay-tree.h +++ b/gcc/typed-splay-tree.h @@ -33,6 +33,7 @@ class typed_splay_tree typedef int (*compare_fn) (key_type, key_type); typedef void (*delete_key_fn) (key_type); typedef void (*delete_value_fn) (value_type); + typedef int (*foreach_fn) (key_type, value_type, void *); typed_splay_tree (compare_fn, delete_key_fn, @@ -43,8 +44,23 @@ class typed_splay_tree value_type predecessor (key_type k); value_type successor (key_type k); void insert (key_type k, value_type v); + value_type max (); + value_type min (); + int foreach (foreach_fn, void *); private: + /* Helper type for typed_splay_tree::foreach. */ + struct closure + { + closure (foreach_fn outer_cb, void *outer_user_data) + : m_outer_cb (outer_cb), m_outer_user_data (outer_user_data) {} + + foreach_fn m_outer_cb; + void *m_outer_user_data; + }; + + static int inner_foreach_fn (splay_tree_node node, void *user_data); + static value_type node_to_value (splay_tree_node node); private: @@ -120,6 +136,52 @@ typed_splay_tree<KEY_TYPE, VALUE_TYPE>::insert (key_type key, (splay_tree_value)value); } +/* Get the value with maximal key. */ + +template <typename KEY_TYPE, typename VALUE_TYPE> +inline VALUE_TYPE +typed_splay_tree<KEY_TYPE, VALUE_TYPE>::max () +{ + return node_to_value (splay_tree_max (m_inner)); +} + +/* Get the value with minimal key. */ + +template <typename KEY_TYPE, typename VALUE_TYPE> +inline VALUE_TYPE +typed_splay_tree<KEY_TYPE, VALUE_TYPE>::min () +{ + return node_to_value (splay_tree_min (m_inner)); +} + +/* Call OUTER_CB, passing it the OUTER_USER_DATA, for every node, + following an in-order traversal. If OUTER_CB ever returns a non-zero + value, the iteration ceases immediately, and the value is returned. + Otherwise, this function returns 0. */ + +template <typename KEY_TYPE, typename VALUE_TYPE> +inline int +typed_splay_tree<KEY_TYPE, VALUE_TYPE>::foreach (foreach_fn outer_cb, + void *outer_user_data) +{ + closure c (outer_cb, outer_user_data); + + return splay_tree_foreach (m_inner, inner_foreach_fn, &c); +} + +/* Helper function for typed_splay_tree::foreach. */ + +template <typename KEY_TYPE, typename VALUE_TYPE> +int +typed_splay_tree<KEY_TYPE, VALUE_TYPE>::inner_foreach_fn (splay_tree_node node, + void *user_data) +{ + closure *c = (closure *)user_data; + + return c->m_outer_cb ((KEY_TYPE)node->key, (VALUE_TYPE)node->value, + c->m_outer_user_data); +} + /* Internal function for converting from splay_tree_node to VALUE_TYPE. */ template <typename KEY_TYPE, typename VALUE_TYPE> diff --git a/gcc/ubsan.c b/gcc/ubsan.c index a118af297f8..d3bd8e3393d 100644 --- a/gcc/ubsan.c +++ b/gcc/ubsan.c @@ -1469,7 +1469,7 @@ ubsan_use_new_style_p (location_t loc) expanded_location xloc = expand_location (loc); if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0 - || xloc.file == '\0' || xloc.file[0] == '\xff' + || xloc.file[0] == '\0' || xloc.file[0] == '\xff' || xloc.file[1] == '\xff') return false; @@ -1826,8 +1826,8 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs) if (decl_p) base_addr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (base)), base); - unsigned HOST_WIDE_INT size = compute_builtin_object_size (base_addr, 0); - if (size != HOST_WIDE_INT_M1U) + unsigned HOST_WIDE_INT size; + if (compute_builtin_object_size (base_addr, 0, &size)) sizet = build_int_cst (sizetype, size); else if (optimize) { diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index fdad87459fb..07b3e079aaa 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -1983,7 +1983,7 @@ static bool negative_power_of_two_p (HOST_WIDE_INT i) { unsigned HOST_WIDE_INT x = -(unsigned HOST_WIDE_INT)i; - return x == (x & -x); + return pow2_or_zerop (x); } /* Strip constant offsets and alignments off of LOC. Return the base diff --git a/gcc/varasm.c b/gcc/varasm.c index 00a9b30e73c..ba866ce8044 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2632,7 +2632,7 @@ assemble_trampoline_template (void) static inline unsigned min_align (unsigned int a, unsigned int b) { - return (a | b) & -(a | b); + return least_bit_hwi (a | b); } /* Return the assembler directive for creating a given kind of integer diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index acc07047f67..24059bb140d 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,7 @@ +2016-09-11 Carlos Liam <carlos@aarzee.me> + + * all: Remove meaningless trailing whitespace. + 2016-05-18 Uros Bizjak <ubizjak@gmail.com> PR target/71161 diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am index a7df0259098..61aec4474a7 100644 --- a/libbacktrace/Makefile.am +++ b/libbacktrace/Makefile.am @@ -6,12 +6,12 @@ # met: # (1) Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer. # (2) Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the -# distribution. +# distribution. # (3) The name of the author may not be used to # endorse or promote products derived from this software without diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 586b6a6eaa1..de74b5d095f 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -16,19 +16,19 @@ @SET_MAKE@ # Makefile.am -- Backtrace Makefile. -# Copyright (C) 2012-2015 Free Software Foundation, Inc. +# Copyright (C) 2012-2016 Free Software Foundation, Inc. # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # (1) Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer. # (2) Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the -# distribution. +# distribution. # (3) The name of the author may not be used to # endorse or promote products derived from this software without diff --git a/libbacktrace/alloc.c b/libbacktrace/alloc.c index a9f07a013f8..3333624a209 100644 --- a/libbacktrace/alloc.c +++ b/libbacktrace/alloc.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/atomic.c b/libbacktrace/atomic.c index cb0ad0298e6..4f31ff36f81 100644 --- a/libbacktrace/atomic.c +++ b/libbacktrace/atomic.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/backtrace-supported.h.in b/libbacktrace/backtrace-supported.h.in index ab34199fcd3..c2d03d241ad 100644 --- a/libbacktrace/backtrace-supported.h.in +++ b/libbacktrace/backtrace-supported.h.in @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/backtrace.c b/libbacktrace/backtrace.c index b89bf554ac5..7372a27f15f 100644 --- a/libbacktrace/backtrace.c +++ b/libbacktrace/backtrace.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/backtrace.h b/libbacktrace/backtrace.h index d209219d9a4..0e6e29f39c4 100644 --- a/libbacktrace/backtrace.h +++ b/libbacktrace/backtrace.h @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/btest.c b/libbacktrace/btest.c index 0506d2b1121..8c69b1b87f2 100644 --- a/libbacktrace/btest.c +++ b/libbacktrace/btest.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. @@ -460,7 +460,7 @@ f23 (int f1line, int f2line) (unsigned int) bdata.index, j + 1); bdata.failed = 1; } - } + } check ("test3", 0, all, f3line, "f23", &bdata.failed); check ("test3", 1, all, f2line, "f22", &bdata.failed); diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 71e85187ef5..2b774b05899 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -6,13 +6,13 @@ # met: # (1) Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer. # (2) Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the -# distribution. - +# distribution. + # (3) The name of the author may not be used to # endorse or promote products derived from this software without # specific prior written permission. diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index 55b8d7dc2a5..37682c0038e 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. @@ -1246,7 +1246,7 @@ add_unit_ranges (struct backtrace_state *state, uintptr_t base_address, static int find_address_ranges (struct backtrace_state *state, uintptr_t base_address, - struct dwarf_buf *unit_buf, + struct dwarf_buf *unit_buf, const unsigned char *dwarf_str, size_t dwarf_str_size, const unsigned char *dwarf_ranges, size_t dwarf_ranges_size, @@ -1605,7 +1605,7 @@ read_line_header (struct backtrace_state *state, struct unit *u, if (!advance (line_buf, hdrlen)) return 0; - + hdr->min_insn_len = read_byte (&hdr_buf); if (hdr->version < 4) hdr->max_ops_per_insn = 1; @@ -1614,7 +1614,7 @@ read_line_header (struct backtrace_state *state, struct unit *u, /* We don't care about default_is_stmt. */ read_byte (&hdr_buf); - + hdr->line_base = read_sbyte (&hdr_buf); hdr->line_range = read_byte (&hdr_buf); diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c index 81ba3440ab7..e8774138226 100644 --- a/libbacktrace/elf.c +++ b/libbacktrace/elf.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/fileline.c b/libbacktrace/fileline.c index 27ebbedc21c..503bbc6bc54 100644 --- a/libbacktrace/fileline.c +++ b/libbacktrace/fileline.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h index 73728da3f56..aab4e2a007a 100644 --- a/libbacktrace/internal.h +++ b/libbacktrace/internal.h @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/mmap.c b/libbacktrace/mmap.c index 138ef70711a..e30d1c1a3d7 100644 --- a/libbacktrace/mmap.c +++ b/libbacktrace/mmap.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/mmapio.c b/libbacktrace/mmapio.c index dfdaf6fa52e..8a9ba8e7bce 100644 --- a/libbacktrace/mmapio.c +++ b/libbacktrace/mmapio.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/nounwind.c b/libbacktrace/nounwind.c index 448a2049f1d..0deaeef0a8e 100644 --- a/libbacktrace/nounwind.c +++ b/libbacktrace/nounwind.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/posix.c b/libbacktrace/posix.c index 09f5e95a6e4..be7357e6be6 100644 --- a/libbacktrace/posix.c +++ b/libbacktrace/posix.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/print.c b/libbacktrace/print.c index 74c8fcbee5a..73b8abc1933 100644 --- a/libbacktrace/print.c +++ b/libbacktrace/print.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/read.c b/libbacktrace/read.c index 7f0317c3a8c..33b68f8434c 100644 --- a/libbacktrace/read.c +++ b/libbacktrace/read.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/simple.c b/libbacktrace/simple.c index 018773a7e5d..493fd6de780 100644 --- a/libbacktrace/simple.c +++ b/libbacktrace/simple.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/sort.c b/libbacktrace/sort.c index 68a7df65a47..f352fca5ef6 100644 --- a/libbacktrace/sort.c +++ b/libbacktrace/sort.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/state.c b/libbacktrace/state.c index 93420d9c61b..361a3963cea 100644 --- a/libbacktrace/state.c +++ b/libbacktrace/state.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/stest.c b/libbacktrace/stest.c index 55ec31d10bc..7a0b06d3e0b 100644 --- a/libbacktrace/stest.c +++ b/libbacktrace/stest.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libbacktrace/unknown.c b/libbacktrace/unknown.c index 8d06c31549f..8afe65b3f1d 100644 --- a/libbacktrace/unknown.c +++ b/libbacktrace/unknown.c @@ -7,13 +7,13 @@ modification, are permitted provided that the following conditions are met: (1) Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the - distribution. - + distribution. + (3) The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 69abc6802bf..b2b36037463 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,36 @@ +2016-09-15 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (class rich_location): Note that newlines + aren't supported in fix-it text. + * line-map.c (rich_location::add_fixit_insert_before): Reject + attempts to add fix-its containing newlines. + (rich_location::add_fixit_replace): Likewise. + +2016-09-13 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (class rich_location): Add description of + fix-it hints to leading comment. + (rich_location::add_fixit_insert): Rename both overloaded methods + to.. + (rich_location::add_fixit_insert_before): ...this, updating their + comments. + (rich_location::add_fixit_insert_after): Two new overloaded + methods. + (rich_location::stop_supporting_fixits): New method. + * line-map.c (rich_location::add_fixit_insert): Rename both + overloaded methods to.. + (rich_location::add_fixit_insert_before): ...this, updating their + comments. + (rich_location::add_fixit_insert_after): Two new methods. + (rich_location::reject_impossible_fixit): Split out + failure-handling into... + (rich_location::stop_supporting_fixits): New method. + +2016-09-02 David Malcolm <dmalcolm@redhat.com> + + * include/line-map.h (rich_location::seen_impossible_fixit_p): New + accessor. + 2016-08-31 David Malcolm <dmalcolm@redhat.com> * include/line-map.h (class fixit_remove): Remove stray decl. diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index bef77957ffe..747609d4393 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1484,7 +1484,86 @@ class fixit_hint; - range 0 is at the "%s" with start = caret = "%" and finish at the "s". - range 1 has start/finish covering the "101" and is not flagged for - caret printing; it is perhaps at the start of "101". */ + caret printing; it is perhaps at the start of "101". + + + Fix-it hints + ------------ + + Rich locations can also contain "fix-it hints", giving suggestions + for the user on how to edit their code to fix a problem. These + can be expressed as insertions, replacements, and removals of text. + The edits by default are relative to the zeroth range within the + rich_location, but optionally they can be expressed relative to + other locations (using various overloaded methods of the form + rich_location::add_fixit_*). + + For example: + + Example F: fix-it hint: insert_before + ************************************* + ptr = arr[0]; + ^~~~~~ + & + This rich location has a single range (range 0) covering "arr[0]", + with the caret at the start. The rich location has a single + insertion fix-it hint, inserted before range 0, added via + richloc.add_fixit_insert_before ("&"); + + Example G: multiple fix-it hints: insert_before and insert_after + **************************************************************** + #define FN(ARG0, ARG1, ARG2) fn(ARG0, ARG1, ARG2) + ^~~~ ^~~~ ^~~~ + ( ) ( ) ( ) + This rich location has three ranges, covering "arg0", "arg1", + and "arg2", all with caret-printing enabled. + The rich location has 6 insertion fix-it hints: each arg + has a pair of insertion fix-it hints, suggesting wrapping + them with parentheses: one a '(' inserted before, + the other a ')' inserted after, added via + richloc.add_fixit_insert_before (LOC, "("); + and + richloc.add_fixit_insert_after (LOC, ")"); + + Example H: fix-it hint: removal + ******************************* + struct s {int i};; + ^ + - + This rich location has a single range at the stray trailing + semicolon, along with a single removal fix-it hint, covering + the same range, added via: + richloc.add_fixit_remove (); + + Example I: fix-it hint: replace + ******************************* + c = s.colour; + ^~~~~~ + color + This rich location has a single range (range 0) covering "colour", + and a single "replace" fix-it hint, covering the same range, + added via + richloc.add_fixit_replace ("color"); + + Adding a fix-it hint can fail: for example, attempts to insert content + at the transition between two line maps may fail due to there being no + source_location (aka location_t) value to express the new location. + + Attempts to add a fix-it hint within a macro expansion will fail. + + We do not yet support newlines in fix-it text; attempts to do so will fail. + + The rich_location API handles these failures gracefully, so that + diagnostics can attempt to add fix-it hints without each needing + extensive checking. + + Fix-it hints within a rich_location are "atomic": if any hints can't + be applied, none of them will be (tracked by the m_seen_impossible_fixit + flag), and no fix-its hints will be displayed for that rich_location. + This implies that diagnostic messages need to be worded in such a way + that they make sense whether or not the fix-it hints are displayed, + or that richloc.seen_impossible_fixit_p () should be checked before + issuing the diagnostics. */ class rich_location { @@ -1522,14 +1601,25 @@ class rich_location /* Methods for adding insertion fix-it hints. */ - /* Suggest inserting NEW_CONTENT at the primary range's caret. */ + /* Suggest inserting NEW_CONTENT immediately before the primary + range's start. */ void - add_fixit_insert (const char *new_content); + add_fixit_insert_before (const char *new_content); - /* Suggest inserting NEW_CONTENT at WHERE. */ + /* Suggest inserting NEW_CONTENT immediately before the start of WHERE. */ void - add_fixit_insert (source_location where, - const char *new_content); + add_fixit_insert_before (source_location where, + const char *new_content); + + /* Suggest inserting NEW_CONTENT immediately after the end of the primary + range. */ + void + add_fixit_insert_after (const char *new_content); + + /* Suggest inserting NEW_CONTENT immediately after the end of WHERE. */ + void + add_fixit_insert_after (source_location where, + const char *new_content); /* Methods for adding removal fix-it hints. */ @@ -1567,9 +1657,11 @@ class rich_location unsigned int get_num_fixit_hints () const { return m_fixit_hints.count (); } fixit_hint *get_fixit_hint (int idx) const { return m_fixit_hints[idx]; } fixit_hint *get_last_fixit_hint () const; + bool seen_impossible_fixit_p () const { return m_seen_impossible_fixit; } private: bool reject_impossible_fixit (source_location where); + void stop_supporting_fixits (); void add_fixit (fixit_hint *hint); public: diff --git a/libcpp/line-map.c b/libcpp/line-map.c index f69c60c7837..07e3acb78a5 100644 --- a/libcpp/line-map.c +++ b/libcpp/line-map.c @@ -2109,26 +2109,67 @@ rich_location::set_range (line_maps * /*set*/, unsigned int idx, /* Methods for adding insertion fix-it hints. */ /* Add a fixit-hint, suggesting insertion of NEW_CONTENT - at the primary range's caret location. */ + immediately before the primary range's start location. */ void -rich_location::add_fixit_insert (const char *new_content) +rich_location::add_fixit_insert_before (const char *new_content) { - add_fixit_insert (get_loc (), new_content); + add_fixit_insert_before (get_loc (), new_content); } /* Add a fixit-hint, suggesting insertion of NEW_CONTENT - at WHERE. */ + immediately before the start of WHERE. */ void -rich_location::add_fixit_insert (source_location where, - const char *new_content) +rich_location::add_fixit_insert_before (source_location where, + const char *new_content) { - where = get_pure_location (m_line_table, where); + source_location start = get_range_from_loc (m_line_table, where).m_start; - if (reject_impossible_fixit (where)) + if (reject_impossible_fixit (start)) return; - add_fixit (new fixit_insert (where, new_content)); + /* We do not yet support newlines within fix-it hints. */ + if (strchr (new_content, '\n')) + { + stop_supporting_fixits (); + return; + } + add_fixit (new fixit_insert (start, new_content)); +} + +/* Add a fixit-hint, suggesting insertion of NEW_CONTENT + immediately after the primary range's end-point. */ + +void +rich_location::add_fixit_insert_after (const char *new_content) +{ + add_fixit_insert_after (get_loc (), new_content); +} + +/* Add a fixit-hint, suggesting insertion of NEW_CONTENT + immediately after the end-point of WHERE. */ + +void +rich_location::add_fixit_insert_after (source_location where, + const char *new_content) +{ + source_location finish = get_range_from_loc (m_line_table, where).m_finish; + + if (reject_impossible_fixit (finish)) + return; + + source_location next_loc + = linemap_position_for_loc_and_offset (m_line_table, finish, 1); + + /* linemap_position_for_loc_and_offset can fail, if so, it returns + its input value. */ + if (next_loc == finish) + { + stop_supporting_fixits (); + return; + } + + add_fixit (new fixit_insert (next_loc, new_content)); } /* Methods for adding removal fix-it hints. */ @@ -2236,6 +2277,13 @@ rich_location::add_fixit_replace (source_range src_range, if (reject_impossible_fixit (src_range.m_finish)) return; + /* We do not yet support newlines within fix-it hints. */ + if (strchr (new_content, '\n')) + { + stop_supporting_fixits (); + return; + } + /* Consolidate neighboring fixits. */ fixit_hint *prev = get_last_fixit_hint (); if (prev) @@ -2278,14 +2326,22 @@ rich_location::reject_impossible_fixit (source_location where) /* Otherwise we have an attempt to add a fix-it with an "awkward" location: either one that we can't obtain column information for (within an ordinary map), or one within a macro expansion. */ + stop_supporting_fixits (); + return true; +} + +/* Mark this rich_location as not supporting fixits, purging any that were + already added. */ + +void +rich_location::stop_supporting_fixits () +{ m_seen_impossible_fixit = true; /* Purge the rich_location of any fix-its that were already added. */ for (unsigned int i = 0; i < m_fixit_hints.count (); i++) delete get_fixit_hint (i); m_fixit_hints.truncate (0); - - return true; } /* Add HINT to the fix-it hints in this rich_location. */ diff --git a/libffi/ChangeLog b/libffi/ChangeLog index 8245f5b39f8..4b16fb0b31f 100644 --- a/libffi/ChangeLog +++ b/libffi/ChangeLog @@ -1,3 +1,22 @@ +2016-09-04 John David Anglin <danglin@gcc.gnu.org> + + * src/pa/ffi.c (ffi_struct_type): Put type declaration on separate line. + (ffi_prep_args_pa32): Likewise. + (ffi_size_stack_pa32): Likewise. + (ffi_prep_cif_machdep): Likewise. + (ffi_call): Likewise. Rename to ffi_call_int. Add closure argument + and update call to ffi_call_pa32. + (ffi_call, ffi_call_go, ffi_prep_go_closure): New. + (ffi_closure_inner_pa32): Update to handle go closures. + * src/pa/ffitarget.h (FFI_GO_CLOSURES): Define. + * src/pa/hpux32.S (ffi_call_pa32): Pass go closure argument in static + chain register (%ret1). + (ffi_closure_pa32): Set closure type argument to zero. + (ffi_go_closure_pa32): New function. Add unwind data for it. + * src/pa/linux.S: Likewise. Use cfi directives for unwind data. + * testsuite/libffi.go/static-chain.h (STATIC_CHAIN_REG): Define for + hppa. + 2016-05-23 Thomas Schwinge <thomas@codesourcery.com> PR libffi/65567 diff --git a/libffi/src/pa/ffi.c b/libffi/src/pa/ffi.c index 4ce2bc6f0e4..0da81849dee 100644 --- a/libffi/src/pa/ffi.c +++ b/libffi/src/pa/ffi.c @@ -1,5 +1,6 @@ /* ----------------------------------------------------------------------- - ffi.c - (c) 2011 Anthony Green + ffi.c - (c) 2016 John David Anglin + (c) 2011 Anthony Green (c) 2008 Red Hat, Inc. (c) 2006 Free Software Foundation, Inc. (c) 2003-2004 Randolph Chung <tausq@debian.org> @@ -51,7 +52,8 @@ #define debug(lvl, x...) do { if (lvl <= DEBUG_LEVEL) { printf(x); } } while (0) -static inline int ffi_struct_type(ffi_type *t) +static inline int +ffi_struct_type (ffi_type *t) { size_t sz = t->size; @@ -139,7 +141,8 @@ static inline int ffi_struct_type(ffi_type *t) NOTE: We load floating point args in this function... that means we assume gcc will not mess with fp regs in here. */ -void ffi_prep_args_pa32(UINT32 *stack, extended_cif *ecif, unsigned bytes) +void +ffi_prep_args_pa32 (UINT32 *stack, extended_cif *ecif, unsigned bytes) { register unsigned int i; register ffi_type **p_arg; @@ -275,7 +278,8 @@ void ffi_prep_args_pa32(UINT32 *stack, extended_cif *ecif, unsigned bytes) return; } -static void ffi_size_stack_pa32(ffi_cif *cif) +static void +ffi_size_stack_pa32 (ffi_cif *cif) { ffi_type **ptr; int i; @@ -316,7 +320,8 @@ static void ffi_size_stack_pa32(ffi_cif *cif) } /* Perform machine dependent cif processing. */ -ffi_status ffi_prep_cif_machdep(ffi_cif *cif) +ffi_status +ffi_prep_cif_machdep (ffi_cif *cif) { /* Set the return type flag */ switch (cif->rtype->type) @@ -369,11 +374,13 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) return FFI_OK; } -extern void ffi_call_pa32(void (*)(UINT32 *, extended_cif *, unsigned), - extended_cif *, unsigned, unsigned, unsigned *, - void (*fn)(void)); +extern void ffi_call_pa32 (void (*)(UINT32 *, extended_cif *, unsigned), + extended_cif *, unsigned, unsigned, unsigned *, + void (*fn)(void), void *closure); -void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +static void +ffi_call_int (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, + void *closure) { extended_cif ecif; @@ -401,8 +408,8 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) { case FFI_PA32: debug(3, "Calling ffi_call_pa32: ecif=%p, bytes=%u, flags=%u, rvalue=%p, fn=%p\n", &ecif, cif->bytes, cif->flags, ecif.rvalue, (void *)fn); - ffi_call_pa32(ffi_prep_args_pa32, &ecif, cif->bytes, - cif->flags, ecif.rvalue, fn); + ffi_call_pa32 (ffi_prep_args_pa32, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn, closure); break; default: @@ -411,14 +418,30 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) } } +void +ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue) +{ + ffi_call_int (cif, fn, rvalue, avalue, NULL); +} + +void +ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue, + void *closure) +{ + ffi_call_int (cif, fn, rvalue, avalue, closure); +} + #if FFI_CLOSURES /* This is more-or-less an inverse of ffi_call -- we have arguments on the stack, and we need to fill them into a cif structure and invoke the user function. This really ought to be in asm to make sure the compiler doesn't do things we don't expect. */ -ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) +ffi_status +ffi_closure_inner_pa32 (void *closure, UINT32 *stack, int closure_type) { ffi_cif *cif; + void (*fun)(ffi_cif *,void *,void **,void *); + void *user_data; void **avalue; void *rvalue; UINT32 ret[2]; /* function can return up to 64-bits in registers */ @@ -428,7 +451,19 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) unsigned int slot = FIRST_ARG_SLOT; register UINT32 r28 asm("r28"); - cif = closure->cif; + /* A non-zero closure type indicates a go closure. */ + if (closure_type) + { + cif = ((ffi_go_closure *)closure)->cif; + fun = ((ffi_go_closure *)closure)->fun; + user_data = closure; + } + else + { + cif = ((ffi_closure *)closure)->cif; + fun = ((ffi_closure *)closure)->fun; + user_data = ((ffi_closure *)closure)->user_data; + } /* If returning via structure, callee will write to our pointer. */ if (cif->flags == FFI_TYPE_STRUCT) @@ -436,7 +471,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) else rvalue = &ret[0]; - avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG); + avalue = (void **) alloca (cif->nargs * FFI_SIZEOF_ARG); avn = cif->nargs; p_arg = cif->arg_types; @@ -529,7 +564,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) } /* Invoke the closure. */ - (closure->fun) (cif, rvalue, avalue, closure->user_data); + fun (cif, rvalue, avalue, user_data); debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0], ret[1]); @@ -621,6 +656,7 @@ ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack) cif specifies the argument and result types for fun. The cif must already be prep'ed. */ +extern void ffi_go_closure_pa32(void); extern void ffi_closure_pa32(void); ffi_status @@ -716,4 +752,21 @@ ffi_prep_closure_loc (ffi_closure* closure, return FFI_OK; } + +#ifdef FFI_GO_CLOSURES +ffi_status +ffi_prep_go_closure (ffi_go_closure *closure, + ffi_cif *cif, + void (*fun)(ffi_cif *, void *, void **, void *)) +{ + if (cif->abi != FFI_PA32) + return FFI_BAD_ABI; + + closure->tramp = &ffi_go_closure_pa32; + closure->cif = cif; + closure->fun = fun; + + return FFI_OK; +} +#endif /* FFI_GO_CLOSURES */ #endif diff --git a/libffi/src/pa/ffitarget.h b/libffi/src/pa/ffitarget.h index fff4c6b382e..024ac81a807 100644 --- a/libffi/src/pa/ffitarget.h +++ b/libffi/src/pa/ffitarget.h @@ -1,5 +1,6 @@ /* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012 Anthony Green + ffitarget.h - Copyright (c) 2016 John David Anglin + Copyright (c) 2012 Anthony Green Copyright (c) 1996-2003 Red Hat, Inc. Target configuration macros for hppa. @@ -67,6 +68,7 @@ typedef enum ffi_abi { /* ---- Definitions for closures ----------------------------------------- */ #define FFI_CLOSURES 1 +#define FFI_GO_CLOSURES 1 #define FFI_NATIVE_RAW_API 0 #ifdef PA_LINUX diff --git a/libffi/src/pa/hpux32.S b/libffi/src/pa/hpux32.S index 40528bad751..4a47da3791a 100644 --- a/libffi/src/pa/hpux32.S +++ b/libffi/src/pa/hpux32.S @@ -1,6 +1,7 @@ /* ----------------------------------------------------------------------- hpux32.S - Copyright (c) 2006 Free Software Foundation, Inc. (c) 2008 Red Hat, Inc. + (c) 2016 John David Anglin based on src/pa/linux.S HP-UX PA Foreign Function Interface @@ -41,7 +42,8 @@ unsigned bytes, unsigned flags, unsigned *rvalue, - void (*fn)(void)); + void (*fn)(void), + ffi_go_closure *closure); */ .export ffi_call_pa32,ENTRY,PRIV_LEV=3 @@ -104,6 +106,7 @@ L$CFI13 we need to give it a place to put the result. */ ldw -52(%r3), %ret0 ; %ret0 <- rvalue ldw -56(%r3), %r22 ; %r22 <- function to call + ldw -60(%r3), %ret1 ; %ret1 <- closure bl $$dyncall, %r31 ; Call the user function copy %r31, %rp @@ -285,7 +288,9 @@ L$CFI22 stw %arg2, -44(%r3) stw %arg3, -48(%r3) + /* Closure type 0. */ copy %r21, %arg0 + copy %r0, %arg2 bl ffi_closure_inner_pa32, %r2 copy %r3, %arg1 ldwm -64(%sp), %r3 @@ -297,6 +302,47 @@ L$CFI22 .procend L$FE2: + /* void ffi_go_closure_pa32(void); + Called with closure argument in %ret1 */ + + .SPACE $TEXT$ + .SUBSPA $CODE$ + .export ffi_go_closure_pa32,ENTRY,PRIV_LEV=3,RTNVAL=GR + .import ffi_closure_inner_pa32,CODE + .align 4 +L$FB3 +ffi_go_closure_pa32 + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .entry + + stw %rp, -20(%sp) + copy %r3, %r1 +L$CFI31 + copy %sp, %r3 +L$CFI32 + stwm %r1, 64(%sp) + + /* Put arguments onto the stack and call ffi_closure_inner. */ + stw %arg0, -36(%r3) + stw %arg1, -40(%r3) + stw %arg2, -44(%r3) + stw %arg3, -48(%r3) + + /* Closure type 1. */ + copy %ret1, %arg0 + ldi 1, %arg2 + bl ffi_closure_inner_pa32, %r2 + copy %r3, %arg1 + ldwm -64(%sp), %r3 + ldw -20(%sp), %rp + ldw -36(%sp), %ret0 + bv %r0(%rp) + ldw -40(%sp), %ret1 + .exit + .procend +L$FE3: + .SPACE $PRIVATE$ .SUBSPA $DATA$ @@ -366,3 +412,25 @@ L$ASFDE2: .align 4 L$EFDE2: + +L$SFDE3: + .word L$EFDE3-L$ASFDE3 ;# FDE Length +L$ASFDE3: + .word L$ASFDE3-L$frame1 ;# FDE CIE offset + .word L$FB3 ;# FDE initial location + .word L$FE3-L$FB3 ;# FDE address range + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI31-L$FB3 + .byte 0x83 ;# DW_CFA_offset, column 0x3 + .uleb128 0x0 + .byte 0x11 ;# DW_CFA_offset_extended_sf + .uleb128 0x2 + .sleb128 -5 + + .byte 0x4 ;# DW_CFA_advance_loc4 + .word L$CFI32-L$CFI31 + .byte 0xd ;# DW_CFA_def_cfa_register = r3 + .uleb128 0x3 + + .align 4 +L$EFDE3: diff --git a/libffi/src/pa/linux.S b/libffi/src/pa/linux.S index f11ae768074..602690432c0 100644 --- a/libffi/src/pa/linux.S +++ b/libffi/src/pa/linux.S @@ -1,6 +1,7 @@ /* ----------------------------------------------------------------------- linux.S - (c) 2003-2004 Randolph Chung <tausq@debian.org> (c) 2008 Red Hat, Inc. + (c) 2016 John David Anglin HPPA Foreign Function Interface @@ -37,24 +38,26 @@ unsigned bytes, unsigned flags, unsigned *rvalue, - void (*fn)(void)); + void (*fn)(void), + ffi_go_closure *closure); */ .export ffi_call_pa32,code .import ffi_prep_args_pa32,code .type ffi_call_pa32, @function -.LFB1: + .cfi_startproc ffi_call_pa32: .proc .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4 .entry stw %rp, -20(%sp) copy %r3, %r1 -.LCFI11: + .cfi_offset 2, -20 + .cfi_register 3, 1 copy %sp, %r3 -.LCFI12: + .cfi_def_cfa_register 3 /* Setup the stack for calling prep_args... We want the stack to look like this: @@ -70,8 +73,8 @@ ffi_call_pa32: */ stwm %r1, 64(%sp) + .cfi_offset 3, 0 stw %r4, 12(%r3) -.LCFI13: copy %sp, %r4 addl %arg2, %r4, %arg0 /* arg stack */ @@ -98,6 +101,7 @@ ffi_call_pa32: we need to give it a place to put the result. */ ldw -52(%r3), %ret0 /* %ret0 <- rvalue */ ldw -56(%r3), %r22 /* %r22 <- function to call */ + ldw -60(%r3), %ret1 /* %ret1 <- closure */ bl $$dyncall, %r31 /* Call the user function */ copy %r31, %rp @@ -249,27 +253,27 @@ ffi_call_pa32: nop .exit .procend -.LFE1: + .cfi_endproc /* void ffi_closure_pa32(void); - Called with closure argument in %r21 */ + Called with ffi_closure argument in %r21. */ .export ffi_closure_pa32,code .import ffi_closure_inner_pa32,code - .type ffi_closure_pa32, @function -.LFB2: + .cfi_startproc ffi_closure_pa32: .proc .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 .entry stw %rp, -20(%sp) -.LCFI20: copy %r3, %r1 -.LCFI21: + .cfi_offset 2, -20 + .cfi_register 3, 1 copy %sp, %r3 -.LCFI22: + .cfi_def_cfa_register 3 stwm %r1, 64(%sp) + .cfi_offset 3, 0 /* Put arguments onto the stack and call ffi_closure_inner. */ stw %arg0, -36(%r3) @@ -277,7 +281,9 @@ ffi_closure_pa32: stw %arg2, -44(%r3) stw %arg3, -48(%r3) + /* Closure type 0. */ copy %r21, %arg0 + copy %r0, %arg2 bl ffi_closure_inner_pa32, %r2 copy %r3, %arg1 @@ -289,69 +295,46 @@ ffi_closure_pa32: .exit .procend -.LFE2: - - .section ".eh_frame",EH_FRAME_FLAGS,@progbits -.Lframe1: - .word .LECIE1-.LSCIE1 ;# Length of Common Information Entry -.LSCIE1: - .word 0x0 ;# CIE Identifier Tag - .byte 0x1 ;# CIE Version - .ascii "\0" ;# CIE Augmentation - .uleb128 0x1 ;# CIE Code Alignment Factor - .sleb128 4 ;# CIE Data Alignment Factor - .byte 0x2 ;# CIE RA Column - .byte 0xc ;# DW_CFA_def_cfa - .uleb128 0x1e - .uleb128 0x0 - .align 4 -.LECIE1: -.LSFDE1: - .word .LEFDE1-.LASFDE1 ;# FDE Length -.LASFDE1: - .word .LASFDE1-.Lframe1 ;# FDE CIE offset - .word .LFB1 ;# FDE initial location - .word .LFE1-.LFB1 ;# FDE address range - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI11-.LFB1 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20] - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI12-.LCFI11 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI13-.LCFI12 - .byte 0x84 ;# DW_CFA_offset, column 0x4 - .uleb128 0x3 + .cfi_endproc - .align 4 -.LEFDE1: - -.LSFDE2: - .word .LEFDE2-.LASFDE2 ;# FDE Length -.LASFDE2: - .word .LASFDE2-.Lframe1 ;# FDE CIE offset - .word .LFB2 ;# FDE initial location - .word .LFE2-.LFB2 ;# FDE address range - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI21-.LFB2 - .byte 0x83 ;# DW_CFA_offset, column 0x3 - .uleb128 0x0 - .byte 0x11 ;# DW_CFA_offset_extended_sf - .uleb128 0x2 - .sleb128 -5 - - .byte 0x4 ;# DW_CFA_advance_loc4 - .word .LCFI22-.LCFI21 - .byte 0xd ;# DW_CFA_def_cfa_register = r3 - .uleb128 0x3 + /* void ffi_go_closure_pa32(void); + Called with ffi_go_closure argument in %ret1. */ + .export ffi_go_closure_pa32,code + .import ffi_closure_inner_pa32,code + .type ffi_go_closure_pa32, @function + .cfi_startproc +ffi_go_closure_pa32: + .proc + .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3 + .entry - .align 4 -.LEFDE2: + stw %rp, -20(%sp) + copy %r3, %r1 + .cfi_offset 2, -20 + .cfi_register 3, 1 + copy %sp, %r3 + .cfi_def_cfa_register 3 + stwm %r1, 64(%sp) + .cfi_offset 3, 0 + + /* Put arguments onto the stack and call ffi_closure_inner. */ + stw %arg0, -36(%r3) + stw %arg1, -40(%r3) + stw %arg2, -44(%r3) + stw %arg3, -48(%r3) + + /* Closure type 1. */ + copy %ret1, %arg0 + ldi 1, %arg2 + bl ffi_closure_inner_pa32, %r2 + copy %r3, %arg1 + + ldwm -64(%sp), %r3 + ldw -20(%sp), %rp + ldw -36(%sp), %ret0 + bv %r0(%r2) + ldw -40(%sp), %ret1 + + .exit + .procend + .cfi_endproc diff --git a/libffi/testsuite/libffi.go/static-chain.h b/libffi/testsuite/libffi.go/static-chain.h index 3675b40a54c..e120eea5e75 100644 --- a/libffi/testsuite/libffi.go/static-chain.h +++ b/libffi/testsuite/libffi.go/static-chain.h @@ -4,6 +4,12 @@ # define STATIC_CHAIN_REG "$1" #elif defined(__arm__) # define STATIC_CHAIN_REG "ip" +#elif defined(__hppa__) +# if defined(__LP64) +# define define STATIC_CHAIN_REG "%r31" +# else +# define define STATIC_CHAIN_REG "%r29" /* %ret1 */ +# endif #elif defined(__sparc__) # if defined(__arch64__) || defined(__sparcv9) # define STATIC_CHAIN_REG "g5" diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index d5ecf7776a7..b5c7ea4a9af 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,37 @@ +2016-09-16 Jakub Jelinek <jakub@redhat.com> + + PR libgcc/71744 + * unwind-dw2-fde.c (ATOMIC_FDE_FAST_PATH): Define if __register_frame* + is not the primary registry and atomics are available. + (any_objects_registered): New variable. + (__register_frame_info_bases, __register_frame_info_table_bases): + Atomically store 1 to any_objects_registered after registering first + unwind info. + (_Unwind_Find_FDE): Return early if any_objects_registered is 0. + +2016-09-09 James Greenhalgh <james.greenhalgh@arm.com> + + PR target/63250 + * Makefile.in (lib2funcs): Build _mulhc3 and _divhc3. + * libgcc2.h (LIBGCC_HAS_HF_MODE): Conditionally define. + (HFtype): Likewise. + (HCtype): Likewise. + (__divhc3): Likewise. + (__mulhc3): Likewise. + * libgcc2.c: Support _mulhc3 and _divhc3. + +2016-09-07 Joseph Myers <joseph@codesourcery.com> + + PR libgcc/77519 + * libgcc2.c (NOTRUNC): Invert settings. + +2016-09-06 Martin Liska <mliska@suse.cz> + + PR gcov-profile/77378 + PR gcov-profile/77466 + * libgcov-profiler.c: Use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_{4,8} to + conditionaly enable/disable *_atomic functions. + 2016-08-26 Joseph Myers <joseph@codesourcery.com> * config.host (i[34567]86-*-* | x86_64-*-*): Enable TFmode soft-fp diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in index ba37c657baf..53e3ea20b12 100644 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in @@ -414,8 +414,9 @@ lib2funcs = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \ _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \ _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \ - _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 \ - _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2 _clrsbdi2 + _mulhc3 _mulsc3 _muldc3 _mulxc3 _multc3 _divhc3 _divsc3 \ + _divdc3 _divxc3 _divtc3 _bswapsi2 _bswapdi2 _clrsbsi2 \ + _clrsbdi2 # The floating-point conversion routines that involve a single-word integer. # XX stands for the integer mode. diff --git a/libgcc/libgcc2.c b/libgcc/libgcc2.c index 0a716bf7b8f..9fb150b2dd5 100644 --- a/libgcc/libgcc2.c +++ b/libgcc/libgcc2.c @@ -1852,7 +1852,8 @@ NAME (TYPE x, int m) #endif -#if ((defined(L_mulsc3) || defined(L_divsc3)) && LIBGCC2_HAS_SF_MODE) \ +#if((defined(L_mulhc3) || defined(L_divhc3)) && LIBGCC2_HAS_HF_MODE) \ + || ((defined(L_mulsc3) || defined(L_divsc3)) && LIBGCC2_HAS_SF_MODE) \ || ((defined(L_muldc3) || defined(L_divdc3)) && LIBGCC2_HAS_DF_MODE) \ || ((defined(L_mulxc3) || defined(L_divxc3)) && LIBGCC2_HAS_XF_MODE) \ || ((defined(L_multc3) || defined(L_divtc3)) && LIBGCC2_HAS_TF_MODE) @@ -1861,30 +1862,36 @@ NAME (TYPE x, int m) #undef double #undef long -#if defined(L_mulsc3) || defined(L_divsc3) +#if defined(L_mulhc3) || defined(L_divhc3) +# define MTYPE HFtype +# define CTYPE HCtype +# define MODE hc +# define CEXT __LIBGCC_HF_FUNC_EXT__ +# define NOTRUNC (!__LIBGCC_HF_EXCESS_PRECISION__) +#elif defined(L_mulsc3) || defined(L_divsc3) # define MTYPE SFtype # define CTYPE SCtype # define MODE sc # define CEXT __LIBGCC_SF_FUNC_EXT__ -# define NOTRUNC __LIBGCC_SF_EXCESS_PRECISION__ +# define NOTRUNC (!__LIBGCC_SF_EXCESS_PRECISION__) #elif defined(L_muldc3) || defined(L_divdc3) # define MTYPE DFtype # define CTYPE DCtype # define MODE dc # define CEXT __LIBGCC_DF_FUNC_EXT__ -# define NOTRUNC __LIBGCC_DF_EXCESS_PRECISION__ +# define NOTRUNC (!__LIBGCC_DF_EXCESS_PRECISION__) #elif defined(L_mulxc3) || defined(L_divxc3) # define MTYPE XFtype # define CTYPE XCtype # define MODE xc # define CEXT __LIBGCC_XF_FUNC_EXT__ -# define NOTRUNC __LIBGCC_XF_EXCESS_PRECISION__ +# define NOTRUNC (!__LIBGCC_XF_EXCESS_PRECISION__) #elif defined(L_multc3) || defined(L_divtc3) # define MTYPE TFtype # define CTYPE TCtype # define MODE tc # define CEXT __LIBGCC_TF_FUNC_EXT__ -# define NOTRUNC __LIBGCC_TF_EXCESS_PRECISION__ +# define NOTRUNC (!__LIBGCC_TF_EXCESS_PRECISION__) #else # error #endif @@ -1922,7 +1929,7 @@ extern void *compile_type_assert[sizeof(INFINITY) == sizeof(MTYPE) ? 1 : -1]; # define TRUNC(x) __asm__ ("" : "=m"(x) : "m"(x)) #endif -#if defined(L_mulsc3) || defined(L_muldc3) \ +#if defined(L_mulhc3) || defined(L_mulsc3) || defined(L_muldc3) \ || defined(L_mulxc3) || defined(L_multc3) CTYPE @@ -1992,7 +1999,7 @@ CONCAT3(__mul,MODE,3) (MTYPE a, MTYPE b, MTYPE c, MTYPE d) } #endif /* complex multiply */ -#if defined(L_divsc3) || defined(L_divdc3) \ +#if defined(L_divhc3) || defined(L_divsc3) || defined(L_divdc3) \ || defined(L_divxc3) || defined(L_divtc3) CTYPE diff --git a/libgcc/libgcc2.h b/libgcc/libgcc2.h index 72bb873ac33..c46fb77a6ec 100644 --- a/libgcc/libgcc2.h +++ b/libgcc/libgcc2.h @@ -34,6 +34,12 @@ extern void __clear_cache (char *, char *); extern void __eprintf (const char *, const char *, unsigned int, const char *) __attribute__ ((__noreturn__)); +#ifdef __LIBGCC_HAS_HF_MODE__ +#define LIBGCC2_HAS_HF_MODE 1 +#else +#define LIBGCC2_HAS_HF_MODE 0 +#endif + #ifdef __LIBGCC_HAS_SF_MODE__ #define LIBGCC2_HAS_SF_MODE 1 #else @@ -133,6 +139,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI))); #endif #endif +#if LIBGCC2_HAS_HF_MODE +typedef float HFtype __attribute__ ((mode (HF))); +typedef _Complex float HCtype __attribute__ ((mode (HC))); +#endif #if LIBGCC2_HAS_SF_MODE typedef float SFtype __attribute__ ((mode (SF))); typedef _Complex float SCtype __attribute__ ((mode (SC))); @@ -424,6 +434,10 @@ extern SItype __negvsi2 (SItype); #endif /* COMPAT_SIMODE_TRAPPING_ARITHMETIC */ #undef int +#if LIBGCC2_HAS_HF_MODE +extern HCtype __divhc3 (HFtype, HFtype, HFtype, HFtype); +extern HCtype __mulhc3 (HFtype, HFtype, HFtype, HFtype); +#endif #if LIBGCC2_HAS_SF_MODE extern DWtype __fixsfdi (SFtype); extern SFtype __floatdisf (DWtype); diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c index 70a821dc625..d9217b9885b 100644 --- a/libgcc/libgcov-profiler.c +++ b/libgcc/libgcov-profiler.c @@ -26,6 +26,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "libgcov.h" #if !defined(inhibit_libc) +/* Detect whether target can support atomic update of profilers. */ +#if __SIZEOF_LONG_LONG__ == 4 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +#define GCOV_SUPPORTS_ATOMIC 1 +#else +#if __SIZEOF_LONG_LONG__ == 8 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 +#define GCOV_SUPPORTS_ATOMIC 1 +#else +#define GCOV_SUPPORTS_ATOMIC 0 +#endif +#endif + #ifdef L_gcov_interval_profiler /* If VALUE is in interval <START, START + STEPS - 1>, then increases the corresponding counter in COUNTERS. If the VALUE is above or below @@ -46,7 +57,7 @@ __gcov_interval_profiler (gcov_type *counters, gcov_type value, } #endif -#ifdef L_gcov_interval_profiler_atomic +#if defined(L_gcov_interval_profiler_atomic) && GCOV_SUPPORTS_ATOMIC /* If VALUE is in interval <START, START + STEPS - 1>, then increases the corresponding counter in COUNTERS. If the VALUE is above or below the interval, COUNTERS[STEPS] or COUNTERS[STEPS + 1] is increased @@ -80,7 +91,7 @@ __gcov_pow2_profiler (gcov_type *counters, gcov_type value) } #endif -#ifdef L_gcov_pow2_profiler_atomic +#if defined(L_gcov_pow2_profiler_atomic) && GCOV_SUPPORTS_ATOMIC /* If VALUE is a power of two, COUNTERS[1] is incremented. Otherwise COUNTERS[0] is incremented. Function is thread-safe. */ @@ -134,7 +145,7 @@ __gcov_one_value_profiler (gcov_type *counters, gcov_type value) } #endif -#ifdef L_gcov_one_value_profiler_atomic +#if defined(L_gcov_one_value_profiler_atomic) && GCOV_SUPPORTS_ATOMIC /* Update one value profilers (COUNTERS) for a given VALUE. @@ -342,6 +353,7 @@ __gcov_time_profiler (gcov_type* counters) counters[0] = ++function_counter; } +#if GCOV_SUPPORTS_ATOMIC /* Sets corresponding COUNTERS if there is no value. Function is thread-safe. */ @@ -352,6 +364,7 @@ __gcov_time_profiler_atomic (gcov_type* counters) counters[0] = __atomic_add_fetch (&function_counter, 1, MEMMODEL_RELAXED); } #endif +#endif #ifdef L_gcov_average_profiler @@ -366,7 +379,7 @@ __gcov_average_profiler (gcov_type *counters, gcov_type value) } #endif -#ifdef L_gcov_average_profiler_atomic +#if defined(L_gcov_average_profiler_atomic) && GCOV_SUPPORTS_ATOMIC /* Increase corresponding COUNTER by VALUE. FIXME: Perhaps we want to saturate up. Function is thread-safe. */ @@ -388,7 +401,7 @@ __gcov_ior_profiler (gcov_type *counters, gcov_type value) } #endif -#ifdef L_gcov_ior_profiler_atomic +#if defined(L_gcov_ior_profiler_atomic) && GCOV_SUPPORTS_ATOMIC /* Bitwise-OR VALUE into COUNTER. Function is thread-safe. */ void diff --git a/libgcc/unwind-dw2-fde.c b/libgcc/unwind-dw2-fde.c index 5b16a1f87e2..be82f65b916 100644 --- a/libgcc/unwind-dw2-fde.c +++ b/libgcc/unwind-dw2-fde.c @@ -35,6 +35,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include "unwind-pe.h" #include "unwind-dw2-fde.h" #include "gthr.h" +#else +#if (defined(__GTHREAD_MUTEX_INIT) || defined(__GTHREAD_MUTEX_INIT_FUNCTION)) \ + && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) +#define ATOMIC_FDE_FAST_PATH 1 +#endif #endif /* The unseen_objects list contains objects that have been registered @@ -43,6 +48,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see by decreasing value of pc_begin. */ static struct object *unseen_objects; static struct object *seen_objects; +#ifdef ATOMIC_FDE_FAST_PATH +static int any_objects_registered; +#endif #ifdef __GTHREAD_MUTEX_INIT static __gthread_mutex_t object_mutex = __GTHREAD_MUTEX_INIT; @@ -96,6 +104,16 @@ __register_frame_info_bases (const void *begin, struct object *ob, ob->next = unseen_objects; unseen_objects = ob; +#ifdef ATOMIC_FDE_FAST_PATH + /* Set flag that at least one library has registered FDEs. + Use relaxed MO here, it is up to the app to ensure that the library + loading/initialization happens-before using that library in other + threads (in particular unwinding with that library's functions + appearing in the backtraces). Calling that library's functions + without waiting for the library to initialize would be racy. */ + if (!any_objects_registered) + __atomic_store_n (&any_objects_registered, 1, __ATOMIC_RELAXED); +#endif __gthread_mutex_unlock (&object_mutex); } @@ -140,6 +158,16 @@ __register_frame_info_table_bases (void *begin, struct object *ob, ob->next = unseen_objects; unseen_objects = ob; +#ifdef ATOMIC_FDE_FAST_PATH + /* Set flag that at least one library has registered FDEs. + Use relaxed MO here, it is up to the app to ensure that the library + loading/initialization happens-before using that library in other + threads (in particular unwinding with that library's functions + appearing in the backtraces). Calling that library's functions + without waiting for the library to initialize would be racy. */ + if (!any_objects_registered) + __atomic_store_n (&any_objects_registered, 1, __ATOMIC_RELAXED); +#endif __gthread_mutex_unlock (&object_mutex); } @@ -1001,6 +1029,19 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases) struct object *ob; const fde *f = NULL; +#ifdef ATOMIC_FDE_FAST_PATH + /* For targets where unwind info is usually not registered through these + APIs anymore, avoid taking a global lock. + Use relaxed MO here, it is up to the app to ensure that the library + loading/initialization happens-before using that library in other + threads (in particular unwinding with that library's functions + appearing in the backtraces). Calling that library's functions + without waiting for the library to initialize would be racy. */ + if (__builtin_expect (!__atomic_load_n (&any_objects_registered, + __ATOMIC_RELAXED), 1)) + return NULL; +#endif + init_object_mutex_once (); __gthread_mutex_lock (&object_mutex); diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 256805a3db6..6454eaeb826 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,16 @@ +2016-09-09 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/77507 + * ieee/ieee_arithmetic.F90 (IEEE_VALUE_4,IEEE_VALUE_8,IEEE_VALULE_10, + IEEE_VALUE_16): Use correct keyword. + +2016-09-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR libgfortran/77393 + * io/write_float.def (build_float_string): Recognize when the + result will not fit in the user provided, star fill, and exit + early. + 2016-08-31 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/77393 diff --git a/libgfortran/ieee/ieee_arithmetic.F90 b/libgfortran/ieee/ieee_arithmetic.F90 index 16e79eceb9a..4007a33358e 100644 --- a/libgfortran/ieee/ieee_arithmetic.F90 +++ b/libgfortran/ieee/ieee_arithmetic.F90 @@ -857,12 +857,12 @@ contains ! IEEE_VALUE - elemental real(kind=4) function IEEE_VALUE_4(X, C) result(res) - implicit none + elemental real(kind=4) function IEEE_VALUE_4(X, CLASS) result(res) + real(kind=4), intent(in) :: X - type(IEEE_CLASS_TYPE), intent(in) :: C + type(IEEE_CLASS_TYPE), intent(in) :: CLASS - select case (C%hidden) + select case (CLASS%hidden) case (1) ! IEEE_SIGNALING_NAN res = -1 res = sqrt(res) @@ -895,12 +895,12 @@ contains end select end function - elemental real(kind=8) function IEEE_VALUE_8(X, C) result(res) - implicit none + elemental real(kind=8) function IEEE_VALUE_8(X, CLASS) result(res) + real(kind=8), intent(in) :: X - type(IEEE_CLASS_TYPE), intent(in) :: C + type(IEEE_CLASS_TYPE), intent(in) :: CLASS - select case (C%hidden) + select case (CLASS%hidden) case (1) ! IEEE_SIGNALING_NAN res = -1 res = sqrt(res) @@ -934,12 +934,12 @@ contains end function #ifdef HAVE_GFC_REAL_10 - elemental real(kind=10) function IEEE_VALUE_10(X, C) result(res) - implicit none + elemental real(kind=10) function IEEE_VALUE_10(X, CLASS) result(res) + real(kind=10), intent(in) :: X - type(IEEE_CLASS_TYPE), intent(in) :: C + type(IEEE_CLASS_TYPE), intent(in) :: CLASS - select case (C%hidden) + select case (CLASS%hidden) case (1) ! IEEE_SIGNALING_NAN res = -1 res = sqrt(res) @@ -971,15 +971,16 @@ contains res = 0 end select end function + #endif #ifdef HAVE_GFC_REAL_16 - elemental real(kind=16) function IEEE_VALUE_16(X, C) result(res) - implicit none + elemental real(kind=16) function IEEE_VALUE_16(X, CLASS) result(res) + real(kind=16), intent(in) :: X - type(IEEE_CLASS_TYPE), intent(in) :: C + type(IEEE_CLASS_TYPE), intent(in) :: CLASS - select case (C%hidden) + select case (CLASS%hidden) case (1) ! IEEE_SIGNALING_NAN res = -1 res = sqrt(res) diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 04223c043a3..504482fa170 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -174,6 +174,13 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer, { case FMT_F: nbefore = ndigits - precision; + if ((w > 0) && (nbefore > (int) size)) + { + *len = w; + star_fill (result, w); + result[w] = '\0'; + return; + } /* Make sure the decimal point is a '.'; depending on the locale, this might not be the case otherwise. */ digits[nbefore] = '.'; diff --git a/libgo/MERGE b/libgo/MERGE index dc6e3799770..160cfe323cb 100644 --- a/libgo/MERGE +++ b/libgo/MERGE @@ -1,4 +1,4 @@ -8707f31c0abc6b607014e843b7cc188b3019daa9 +f75aafdf56dd90eab75cfeac8cf69358f73ba171 The first line of this file holds the git revision number of the last merge done from the master library sources. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index 0a54a8972c5..4ac6a4a7bd5 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -586,12 +586,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c version.go: s-version; @true s-version: Makefile rm -f version.go.tmp - echo "package runtime" > version.go.tmp - echo 'const defaultGoroot = "$(prefix)"' >> version.go.tmp - echo 'const theVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp - echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp - echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp - echo 'const theGccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp + echo "package sys" > version.go.tmp + echo 'const DefaultGoroot = "$(prefix)"' >> version.go.tmp + echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp + echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp + echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp + echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp + echo >> version.go.tmp + echo "type ArchFamilyType int" >> version.go.tmp + echo >> version.go.tmp + echo "const (" >> version.go.tmp + echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp + for a in $(ALLGOARCHFAMILY); do \ + echo " $${a}" >> version.go.tmp; \ + done + echo ")" >> version.go.tmp + echo >> version.go.tmp + for a in $(ALLGOARCH); do \ + f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \ + n="$${f}`echo $${a} | sed -e 's/.//'`"; \ + if test "$${a}" = "$(GOARCH)"; then \ + echo "const Goarch$${n} = 1" >> version.go.tmp; \ + else \ + echo "const Goarch$${n} = 0" >> version.go.tmp; \ + fi; \ + done + echo >> version.go.tmp + echo "const (" >> version.go.tmp + echo " ArchFamily = $(GOARCH_FAMILY)" >> version.go.tmp + echo " BigEndian = $(GOARCH_BIGENDIAN)" >> version.go.tmp + echo " CacheLineSize = $(GOARCH_CACHELINESIZE)" >> version.go.tmp + echo " PhysPageSize = $(GOARCH_PHYSPAGESIZE)" >> version.go.tmp + echo " PCQuantum = $(GOARCH_PCQUANTUM)" >> version.go.tmp + echo " Int64Align = $(GOARCH_INT64ALIGN)" >> version.go.tmp + echo " HugePageSize = $(GOARCH_HUGEPAGESIZE)" >> version.go.tmp + echo " MinFrameSize = $(GOARCH_MINFRAMESIZE)" >> version.go.tmp + echo ")" >> version.go.tmp + echo >> version.go.tmp + for a in $(ALLGOOS); do \ + f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \ + n="$${f}`echo $${a} | sed -e 's/.//'`"; \ + if test "$${a}" = "$(GOOS)"; then \ + echo "const Goos$${n} = 1" >> version.go.tmp; \ + else \ + echo "const Goos$${n} = 0" >> version.go.tmp; \ + fi; \ + done + echo >> version.go.tmp + echo "type Uintreg uintptr" >> version.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ @@ -843,6 +885,9 @@ libgo_go_objs = \ net/rpc/jsonrpc.lo \ runtime/debug.lo \ runtime/pprof.lo \ + runtime/internal/atomic.lo \ + runtime/internal/atomic_c.lo \ + runtime/internal/sys.lo \ sync/atomic.lo \ sync/atomic_c.lo \ text/scanner.lo \ @@ -1222,7 +1267,7 @@ regexp/check: $(CHECK_DEPS) @$(CHECK) .PHONY: regexp/check -extra_go_files_runtime = runtime_sysinfo.go version.go +extra_go_files_runtime = runtime_sysinfo.go @go_include@ runtime-go.lo.dep runtime-go.lo.dep: $(srcdir)/go/runtime/*.go $(extra_go_files_runtime) @@ -2365,6 +2410,30 @@ runtime/pprof/check: $(CHECK_DEPS) # Also use -fno-inline to get better results from the memory profiler. runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline +@go_include@ runtime/internal/atomic.lo.dep +runtime/internal/atomic.lo.dep: $(srcdir)/go/runtime/internal/atomic/*.go + $(BUILDDEPS) +runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime +runtime/internal/atomic.lo: + $(BUILDPACKAGE) +runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc runtime/internal/atomic.lo + $(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c +runtime/internal/atomic/check: $(CHECK_DEPS) + @$(CHECK) +.PHONY: runtime/internal/atomic/check + +extra_go_files_runtime_internal_sys = version.go + +@go_include@ runtime/internal/sys.lo.dep +runtime/internal/sys.lo.dep: $(srcdir)/go/runtime/internal/sys/*.go + $(BUILDDEPS) +runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime +runtime/internal/sys.lo: + $(BUILDPACKAGE) +runtime/internal/sys/check: $(CHECK_DEPS) + @$(CHECK) +.PHONY: runtime/internal/sys/check + @go_include@ sync/atomic.lo.dep sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go $(BUILDDEPS) @@ -2800,6 +2869,10 @@ runtime/debug.gox: runtime/debug.lo $(BUILDGOX) runtime/pprof.gox: runtime/pprof.lo $(BUILDGOX) +runtime/internal/atomic.gox: runtime/internal/atomic.lo + $(BUILDGOX) +runtime/internal/sys.gox: runtime/internal/sys.lo + $(BUILDGOX) sync/atomic.gox: sync/atomic.lo $(BUILDGOX) @@ -2954,6 +3027,8 @@ TEST_PACKAGES = \ path/filepath/check \ regexp/syntax/check \ runtime/pprof/check \ + runtime/internal/atomic/check \ + runtime/internal/sys/check \ sync/atomic/check \ text/scanner/check \ text/tabwriter/check \ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index d9c510028b6..2daa83ee443 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -212,10 +212,11 @@ am__DEPENDENCIES_1 = bufio.lo bytes.lo bytes/index.lo context.lo \ old/regexp.lo old/template.lo os/exec.lo os/signal.lo \ os/user.lo path/filepath.lo regexp/syntax.lo \ net/rpc/jsonrpc.lo runtime/debug.lo runtime/pprof.lo \ - sync/atomic.lo sync/atomic_c.lo text/scanner.lo \ - text/tabwriter.lo text/template.lo text/template/parse.lo \ - testing/iotest.lo testing/quick.lo unicode/utf16.lo \ - unicode/utf8.lo + runtime/internal/atomic.lo runtime/internal/atomic_c.lo \ + runtime/internal/sys.lo sync/atomic.lo sync/atomic_c.lo \ + text/scanner.lo text/tabwriter.lo text/template.lo \ + text/template/parse.lo testing/iotest.lo testing/quick.lo \ + unicode/utf16.lo unicode/utf8.lo am__DEPENDENCIES_2 = am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) \ ../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_2) \ @@ -340,6 +341,9 @@ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = testsuite ACLOCAL = @ACLOCAL@ +ALLGOARCH = @ALLGOARCH@ +ALLGOARCHFAMILY = @ALLGOARCHFAMILY@ +ALLGOOS = @ALLGOOS@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ @@ -364,6 +368,14 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOARCH = @GOARCH@ +GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@ +GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@ +GOARCH_FAMILY = @GOARCH_FAMILY@ +GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@ +GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@ +GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@ +GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@ +GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@ GOC = @GOC@ GOCFLAGS = $(CFLAGS) GOOS = @GOOS@ @@ -1096,6 +1108,9 @@ libgo_go_objs = \ net/rpc/jsonrpc.lo \ runtime/debug.lo \ runtime/pprof.lo \ + runtime/internal/atomic.lo \ + runtime/internal/atomic_c.lo \ + runtime/internal/sys.lo \ sync/atomic.lo \ sync/atomic_c.lo \ text/scanner.lo \ @@ -1235,7 +1250,7 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ @HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = @HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag @LIBGO_IS_SOLARIS_FALSE@matchargs_os = -extra_go_files_runtime = runtime_sysinfo.go version.go +extra_go_files_runtime = runtime_sysinfo.go runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime @LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \ @LIBGO_IS_BSD_TRUE@ golang_org/x/net/route/route.lo @@ -1247,6 +1262,9 @@ runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime # otherwise we can't get the line numbers. # Also use -fno-inline to get better results from the memory profiler. runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline +runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime +extra_go_files_runtime_internal_sys = version.go +runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime # How to build a .gox file from a .lo file. BUILDGOX = \ @@ -1384,6 +1402,8 @@ TEST_PACKAGES = \ path/filepath/check \ regexp/syntax/check \ runtime/pprof/check \ + runtime/internal/atomic/check \ + runtime/internal/sys/check \ sync/atomic/check \ text/scanner/check \ text/tabwriter/check \ @@ -3562,12 +3582,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c version.go: s-version; @true s-version: Makefile rm -f version.go.tmp - echo "package runtime" > version.go.tmp - echo 'const defaultGoroot = "$(prefix)"' >> version.go.tmp - echo 'const theVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp - echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp - echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp - echo 'const theGccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp + echo "package sys" > version.go.tmp + echo 'const DefaultGoroot = "$(prefix)"' >> version.go.tmp + echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp + echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp + echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp + echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp + echo >> version.go.tmp + echo "type ArchFamilyType int" >> version.go.tmp + echo >> version.go.tmp + echo "const (" >> version.go.tmp + echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp + for a in $(ALLGOARCHFAMILY); do \ + echo " $${a}" >> version.go.tmp; \ + done + echo ")" >> version.go.tmp + echo >> version.go.tmp + for a in $(ALLGOARCH); do \ + f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \ + n="$${f}`echo $${a} | sed -e 's/.//'`"; \ + if test "$${a}" = "$(GOARCH)"; then \ + echo "const Goarch$${n} = 1" >> version.go.tmp; \ + else \ + echo "const Goarch$${n} = 0" >> version.go.tmp; \ + fi; \ + done + echo >> version.go.tmp + echo "const (" >> version.go.tmp + echo " ArchFamily = $(GOARCH_FAMILY)" >> version.go.tmp + echo " BigEndian = $(GOARCH_BIGENDIAN)" >> version.go.tmp + echo " CacheLineSize = $(GOARCH_CACHELINESIZE)" >> version.go.tmp + echo " PhysPageSize = $(GOARCH_PHYSPAGESIZE)" >> version.go.tmp + echo " PCQuantum = $(GOARCH_PCQUANTUM)" >> version.go.tmp + echo " Int64Align = $(GOARCH_INT64ALIGN)" >> version.go.tmp + echo " HugePageSize = $(GOARCH_HUGEPAGESIZE)" >> version.go.tmp + echo " MinFrameSize = $(GOARCH_MINFRAMESIZE)" >> version.go.tmp + echo ")" >> version.go.tmp + echo >> version.go.tmp + for a in $(ALLGOOS); do \ + f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \ + n="$${f}`echo $${a} | sed -e 's/.//'`"; \ + if test "$${a}" = "$(GOOS)"; then \ + echo "const Goos$${n} = 1" >> version.go.tmp; \ + else \ + echo "const Goos$${n} = 0" >> version.go.tmp; \ + fi; \ + done + echo >> version.go.tmp + echo "type Uintreg uintptr" >> version.go.tmp $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ @@ -4987,6 +5049,26 @@ runtime/pprof/check: $(CHECK_DEPS) @$(CHECK) .PHONY: runtime/pprof/check +@go_include@ runtime/internal/atomic.lo.dep +runtime/internal/atomic.lo.dep: $(srcdir)/go/runtime/internal/atomic/*.go + $(BUILDDEPS) +runtime/internal/atomic.lo: + $(BUILDPACKAGE) +runtime/internal/atomic_c.lo: go/runtime/internal/atomic/atomic.c runtime.inc runtime/internal/atomic.lo + $(LTCOMPILE) -c -o $@ $(srcdir)/go/runtime/internal/atomic/atomic.c +runtime/internal/atomic/check: $(CHECK_DEPS) + @$(CHECK) +.PHONY: runtime/internal/atomic/check + +@go_include@ runtime/internal/sys.lo.dep +runtime/internal/sys.lo.dep: $(srcdir)/go/runtime/internal/sys/*.go + $(BUILDDEPS) +runtime/internal/sys.lo: + $(BUILDPACKAGE) +runtime/internal/sys/check: $(CHECK_DEPS) + @$(CHECK) +.PHONY: runtime/internal/sys/check + @go_include@ sync/atomic.lo.dep sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go $(BUILDDEPS) @@ -5415,6 +5497,10 @@ runtime/debug.gox: runtime/debug.lo $(BUILDGOX) runtime/pprof.gox: runtime/pprof.lo $(BUILDGOX) +runtime/internal/atomic.gox: runtime/internal/atomic.lo + $(BUILDGOX) +runtime/internal/sys.gox: runtime/internal/sys.lo + $(BUILDGOX) sync/atomic.gox: sync/atomic.lo $(BUILDGOX) diff --git a/libgo/VERSION b/libgo/VERSION index a323ae8190f..ee106b3bb2d 100644 --- a/libgo/VERSION +++ b/libgo/VERSION @@ -1 +1 @@ -go1.7rc3 +go1.7.1 diff --git a/libgo/configure b/libgo/configure index 756f62e137c..137e7a66c86 100755 --- a/libgo/configure +++ b/libgo/configure @@ -629,48 +629,19 @@ GO_SYSCALL_OS_ARCH_FILE GO_SYSCALL_OS_FILE GO_LIBCALL_OS_ARCH_FILE GO_LIBCALL_OS_FILE +ALLGOARCHFAMILY +ALLGOARCH +GOARCH_MINFRAMESIZE +GOARCH_HUGEPAGESIZE +GOARCH_INT64ALIGN +GOARCH_PCQUANTUM +GOARCH_PHYSPAGESIZE +GOARCH_CACHELINESIZE +GOARCH_BIGENDIAN +GOARCH_FAMILY GOARCH -LIBGO_IS_X86_64_FALSE -LIBGO_IS_X86_64_TRUE -LIBGO_IS_SPARC64_FALSE -LIBGO_IS_SPARC64_TRUE -LIBGO_IS_SPARC_FALSE -LIBGO_IS_SPARC_TRUE -LIBGO_IS_S390X_FALSE -LIBGO_IS_S390X_TRUE -LIBGO_IS_S390_FALSE -LIBGO_IS_S390_TRUE -LIBGO_IS_PPC64LE_FALSE -LIBGO_IS_PPC64LE_TRUE -LIBGO_IS_PPC64_FALSE -LIBGO_IS_PPC64_TRUE -LIBGO_IS_PPC_FALSE -LIBGO_IS_PPC_TRUE -LIBGO_IS_MIPS64_FALSE -LIBGO_IS_MIPS64_TRUE -LIBGO_IS_MIPSO64_FALSE -LIBGO_IS_MIPSO64_TRUE -LIBGO_IS_MIPSN64_FALSE -LIBGO_IS_MIPSN64_TRUE -LIBGO_IS_MIPSN32_FALSE -LIBGO_IS_MIPSN32_TRUE -LIBGO_IS_MIPSO32_FALSE -LIBGO_IS_MIPSO32_TRUE -LIBGO_IS_MIPS_FALSE -LIBGO_IS_MIPS_TRUE -LIBGO_IS_M68K_FALSE -LIBGO_IS_M68K_TRUE -LIBGO_IS_IA64_FALSE -LIBGO_IS_IA64_TRUE -LIBGO_IS_ARM64_FALSE -LIBGO_IS_ARM64_TRUE -LIBGO_IS_ARM_FALSE -LIBGO_IS_ARM_TRUE -LIBGO_IS_ALPHA_FALSE -LIBGO_IS_ALPHA_TRUE -LIBGO_IS_386_FALSE -LIBGO_IS_386_TRUE USE_DEJAGNU +ALLGOOS GOOS LIBGO_IS_BSD_FALSE LIBGO_IS_BSD_TRUE @@ -11130,7 +11101,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11133 "configure" +#line 11104 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11236,7 +11207,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11239 "configure" +#line 11210 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13522,6 +13493,11 @@ fi go_include="-include" +# All known GOOS values. This is the union of all operating systems +# supported by the gofrontend and all operating systems supported by +# the gc toolchain. +ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows" + is_darwin=no is_freebsd=no is_irix=no @@ -13625,6 +13601,7 @@ fi + USE_DEJAGNU=no case ${host} in *-*-rtems*) USE_DEJAGNU=yes ;; @@ -13633,34 +13610,46 @@ case ${host} in esac -is_386=no -is_alpha=no -is_arm=no -is_arm64=no -is_ia64=no -is_m68k=no -mips_abi=unknown -is_ppc=no -is_ppc64=no -is_ppc64le=no -is_s390=no -is_s390x=no -is_sparc=no -is_sparc64=no -is_x86_64=no +# All known GOARCH values. This is the union of all architectures +# supported by the gofrontend and all architectures supported by the +# gc toolchain. +# N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). +ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mipso32 mipsn32 mipso64 mipsn64 mips mipsle mips64 mips64le mips64p32 mips64pe32le ppc ppc64 ppc64le s390 s390x sparc sparc64" + +# All known GOARCH_FAMILY values. +ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 S390 S390X SPARC SPARC64" + GOARCH=unknown +GOARCH_FAMILY=unknown +GOARCH_BIGENDIAN=0 +GOARCH_CACHELINESIZE=64 +GOARCH_PHYSPAGESIZE=4096 +GOARCH_PCQUANTUM=1 +GOARCH_INT64ALIGN=8 +GOARCH_HUGEPAGESIZE=0 +GOARCH_MINFRAMESIZE=0 case ${host} in alpha*-*-*) - is_alpha=yes GOARCH=alpha + GOARCH_FAMILY=ALPHA + GOARCH_PHYSPAGESIZE=8192 + GOARCH_PCQUANTUM=4 ;; aarch64-*-*) - is_arm64=yes GOARCH=arm64 + GOARCH_FAMILY=ARM64 + GOARCH_CACHELINESIZE=32 + GOARCH_PHYSPAGESIZE=65536 + GOARCH_PCQUANTUM=4 + GOARCH_MINFRAMESIZE=8 ;; arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*) - is_arm=yes GOARCH=arm + GOARCH_FAMILY=ARM + GOARCH_CACHELINESIZE=32 + GOARCH_PCQUANTUM=4 + GOARCH_INT64ALIGN=4 + GOARCH_MINFRAMESIZE=4 ;; i[34567]86-*-* | x86_64-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13671,24 +13660,32 @@ case ${host} in #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - is_386=yes + GOARCH=386 +GOARCH_FAMILY=I386 +GOARCH_INT64ALIGN=4 +GOARCH_HUGEPAGESIZE="1 << 21" + else - is_x86_64=yes + GOARCH=amd64 +GOARCH_FAMILY=AMD64 +GOARCH_HUGEPAGESIZE="1 << 21" + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$is_386" = "yes"; then - GOARCH=386 - else - GOARCH=amd64 - fi ;; ia64-*-*) - is_ia64=yes GOARCH=ia64 + GOARCH_FAMILY=IA64 + GOARCH_CACHELINESIZE=16384 + GOARCH_PHYSPAGESIZE=8192 ;; m68k*-*-*) - is_m68k=yes GOARCH=m68k + GOARCH_FAMILY=M68K + GOARCH_BIGENDIAN=1 + GOARCH_CACHELINESIZE=16 + GOARCH_PCQUANTUM=4 + GOARCH_INT64ALIGN=4 ;; mips*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13747,6 +13744,27 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext "n64") GOARCH=mipsn64 ;; "o64") GOARCH=mipso64 ;; esac + case "$mips_abi" in + "o32" | "n32") + GOARCH_FAMILY=MIPS + GOARCH_INT64ALIGN=4 + GOARCH_MINFRAMESIZE=4 + ;; + "n64" | "o64") + GOARCH_FAMILY=MIPS64 + GOARCH_MINFRAMESIZE=8 + ;; + esac + case "${host}" in + mips*el) + ;; + *) + GOARCH_BIGENDIAN=1 + ;; + esac + GOARCH_CACHELINESIZE=32 + GOARCH_PHYSPAGESIZE=16384 + GOARCH_PCQUANTUM=4 ;; rs6000*-*-* | powerpc*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13757,9 +13775,15 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - is_ppc=yes + GOARCH=ppc +GOARCH_FAMILY=PPC +GOARCH_BIGENDIAN=1 +GOARCH_INT64ALIGN=4 + else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + +GOARCH_FAMILY=PPC64 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) @@ -13767,20 +13791,19 @@ else #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - is_ppc64le=yes + GOARCH=ppc64le + else - is_ppc64=yes + GOARCH=ppc64 +GOARCH_BIGENDIAN=1 + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$is_ppc" = "yes"; then - GOARCH=ppc - elif test "$is_ppc64" = "yes"; then - GOARCH=ppc64 - else - GOARCH=ppc64le - fi + GOARCH_PHYSPAGESIZE=65536 + GOARCH_PCQUANTUM=4 + GOARCH_MINFRAMESIZE=32 ;; s390*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13791,16 +13814,21 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - is_s390=yes + GOARCH=s390 +GOARCH_FAMILY=S390 +GOARCH_INT64ALIGN=4 +GOARCH_MINFRAMESIZE=4 + else - is_s390x=yes + GOARCH=s390x +GOARCH_FAMILY=S390X +GOARCH_MINFRAMESIZE=8 + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$is_s390" = "yes"; then - GOARCH=s390 - else - GOARCH=s390x - fi + GOARCH_BIGENDIAN=1 + GOARCH_CACHELINESIZE=256 + GOARCH_PCQUANTUM=2 ;; sparc*-*-*) cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -13811,177 +13839,30 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - is_sparc=yes + GOARCH=sparc +GOARCH_FAMILY=SPARC +GOARCH_INT64ALIGN=4 + else - is_sparc64=yes + GOARCH=sparc64 +GOARCH_FAMILY=SPARC64 + fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - if test "$is_sparc" = "yes"; then - GOARCH=sparc - else - GOARCH=sparc64 - fi + GOARCH_BIGENDIAN=1 + GOARCH_PHYSPAGESIZE=8192 + GOARCH_PCQUANTUM=4 ;; esac - if test $is_386 = yes; then - LIBGO_IS_386_TRUE= - LIBGO_IS_386_FALSE='#' -else - LIBGO_IS_386_TRUE='#' - LIBGO_IS_386_FALSE= -fi - - if test $is_alpha = yes; then - LIBGO_IS_ALPHA_TRUE= - LIBGO_IS_ALPHA_FALSE='#' -else - LIBGO_IS_ALPHA_TRUE='#' - LIBGO_IS_ALPHA_FALSE= -fi - - if test $is_arm = yes; then - LIBGO_IS_ARM_TRUE= - LIBGO_IS_ARM_FALSE='#' -else - LIBGO_IS_ARM_TRUE='#' - LIBGO_IS_ARM_FALSE= -fi - - if test $is_arm64 = yes; then - LIBGO_IS_ARM64_TRUE= - LIBGO_IS_ARM64_FALSE='#' -else - LIBGO_IS_ARM64_TRUE='#' - LIBGO_IS_ARM64_FALSE= -fi - - if test $is_ia64 = yes; then - LIBGO_IS_IA64_TRUE= - LIBGO_IS_IA64_FALSE='#' -else - LIBGO_IS_IA64_TRUE='#' - LIBGO_IS_IA64_FALSE= -fi - - if test $is_m68k = yes; then - LIBGO_IS_M68K_TRUE= - LIBGO_IS_M68K_FALSE='#' -else - LIBGO_IS_M68K_TRUE='#' - LIBGO_IS_M68K_FALSE= -fi - - if test $mips_abi != unknown; then - LIBGO_IS_MIPS_TRUE= - LIBGO_IS_MIPS_FALSE='#' -else - LIBGO_IS_MIPS_TRUE='#' - LIBGO_IS_MIPS_FALSE= -fi - - if test $mips_abi = o32; then - LIBGO_IS_MIPSO32_TRUE= - LIBGO_IS_MIPSO32_FALSE='#' -else - LIBGO_IS_MIPSO32_TRUE='#' - LIBGO_IS_MIPSO32_FALSE= -fi - - if test $mips_abi = n32; then - LIBGO_IS_MIPSN32_TRUE= - LIBGO_IS_MIPSN32_FALSE='#' -else - LIBGO_IS_MIPSN32_TRUE='#' - LIBGO_IS_MIPSN32_FALSE= -fi - - if test $mips_abi = n64; then - LIBGO_IS_MIPSN64_TRUE= - LIBGO_IS_MIPSN64_FALSE='#' -else - LIBGO_IS_MIPSN64_TRUE='#' - LIBGO_IS_MIPSN64_FALSE= -fi - if test $mips_abi = o64; then - LIBGO_IS_MIPSO64_TRUE= - LIBGO_IS_MIPSO64_FALSE='#' -else - LIBGO_IS_MIPSO64_TRUE='#' - LIBGO_IS_MIPSO64_FALSE= -fi - if test $mips_abi = n64 -o $mips_abi = o64; then - LIBGO_IS_MIPS64_TRUE= - LIBGO_IS_MIPS64_FALSE='#' -else - LIBGO_IS_MIPS64_TRUE='#' - LIBGO_IS_MIPS64_FALSE= -fi - if test $is_ppc = yes; then - LIBGO_IS_PPC_TRUE= - LIBGO_IS_PPC_FALSE='#' -else - LIBGO_IS_PPC_TRUE='#' - LIBGO_IS_PPC_FALSE= -fi - if test $is_ppc64 = yes; then - LIBGO_IS_PPC64_TRUE= - LIBGO_IS_PPC64_FALSE='#' -else - LIBGO_IS_PPC64_TRUE='#' - LIBGO_IS_PPC64_FALSE= -fi - if test $is_ppc64le = yes; then - LIBGO_IS_PPC64LE_TRUE= - LIBGO_IS_PPC64LE_FALSE='#' -else - LIBGO_IS_PPC64LE_TRUE='#' - LIBGO_IS_PPC64LE_FALSE= -fi - if test $is_s390 = yes; then - LIBGO_IS_S390_TRUE= - LIBGO_IS_S390_FALSE='#' -else - LIBGO_IS_S390_TRUE='#' - LIBGO_IS_S390_FALSE= -fi - if test $is_s390x = yes; then - LIBGO_IS_S390X_TRUE= - LIBGO_IS_S390X_FALSE='#' -else - LIBGO_IS_S390X_TRUE='#' - LIBGO_IS_S390X_FALSE= -fi - if test $is_sparc = yes; then - LIBGO_IS_SPARC_TRUE= - LIBGO_IS_SPARC_FALSE='#' -else - LIBGO_IS_SPARC_TRUE='#' - LIBGO_IS_SPARC_FALSE= -fi - if test $is_sparc64 = yes; then - LIBGO_IS_SPARC64_TRUE= - LIBGO_IS_SPARC64_FALSE='#' -else - LIBGO_IS_SPARC64_TRUE='#' - LIBGO_IS_SPARC64_FALSE= -fi - - if test $is_x86_64 = yes; then - LIBGO_IS_X86_64_TRUE= - LIBGO_IS_X86_64_FALSE='#' -else - LIBGO_IS_X86_64_TRUE='#' - LIBGO_IS_X86_64_FALSE= -fi @@ -15798,86 +15679,6 @@ if test -z "${LIBGO_IS_BSD_TRUE}" && test -z "${LIBGO_IS_BSD_FALSE}"; then as_fn_error "conditional \"LIBGO_IS_BSD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${LIBGO_IS_386_TRUE}" && test -z "${LIBGO_IS_386_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_386\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_ALPHA_TRUE}" && test -z "${LIBGO_IS_ALPHA_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_ALPHA\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_ARM_TRUE}" && test -z "${LIBGO_IS_ARM_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_ARM\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_ARM64_TRUE}" && test -z "${LIBGO_IS_ARM64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_ARM64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_IA64_TRUE}" && test -z "${LIBGO_IS_IA64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_IA64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_M68K_TRUE}" && test -z "${LIBGO_IS_M68K_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_M68K\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPS_TRUE}" && test -z "${LIBGO_IS_MIPS_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPSO32_TRUE}" && test -z "${LIBGO_IS_MIPSO32_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPSO32\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPSN32_TRUE}" && test -z "${LIBGO_IS_MIPSN32_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPSN32\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPSN64_TRUE}" && test -z "${LIBGO_IS_MIPSN64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPSN64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPSO64_TRUE}" && test -z "${LIBGO_IS_MIPSO64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPSO64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_MIPS64_TRUE}" && test -z "${LIBGO_IS_MIPS64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_MIPS64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_PPC_TRUE}" && test -z "${LIBGO_IS_PPC_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_PPC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_PPC64_TRUE}" && test -z "${LIBGO_IS_PPC64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_PPC64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_PPC64LE_TRUE}" && test -z "${LIBGO_IS_PPC64LE_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_PPC64LE\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_S390_TRUE}" && test -z "${LIBGO_IS_S390_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_S390\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_S390X_TRUE}" && test -z "${LIBGO_IS_S390X_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_S390X\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_SPARC_TRUE}" && test -z "${LIBGO_IS_SPARC_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_SPARC\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_SPARC64_TRUE}" && test -z "${LIBGO_IS_SPARC64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_SPARC64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi -if test -z "${LIBGO_IS_X86_64_TRUE}" && test -z "${LIBGO_IS_X86_64_FALSE}"; then - as_fn_error "conditional \"LIBGO_IS_X86_64\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${USING_SPLIT_STACK_TRUE}" && test -z "${USING_SPLIT_STACK_FALSE}"; then as_fn_error "conditional \"USING_SPLIT_STACK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/libgo/configure.ac b/libgo/configure.ac index 21ece733f34..2224f40c3ca 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -142,6 +142,11 @@ AC_SUBST(LIBATOMIC) go_include="-include" AC_SUBST(go_include) +# All known GOOS values. This is the union of all operating systems +# supported by the gofrontend and all operating systems supported by +# the gc toolchain. +ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows" + is_darwin=no is_freebsd=no is_irix=no @@ -174,6 +179,7 @@ AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes) AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes) AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes) AC_SUBST(GOOS) +AC_SUBST(ALLGOOS) dnl Test whether we need to use DejaGNU or whether we can use the dnl simpler gotest approach. We can only use gotest for a native @@ -186,35 +192,46 @@ case ${host} in esac AC_SUBST(USE_DEJAGNU) -dnl N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). -is_386=no -is_alpha=no -is_arm=no -is_arm64=no -is_ia64=no -is_m68k=no -mips_abi=unknown -is_ppc=no -is_ppc64=no -is_ppc64le=no -is_s390=no -is_s390x=no -is_sparc=no -is_sparc64=no -is_x86_64=no +# All known GOARCH values. This is the union of all architectures +# supported by the gofrontend and all architectures supported by the +# gc toolchain. +# N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). +ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mipso32 mipsn32 mipso64 mipsn64 mips mipsle mips64 mips64le mips64p32 mips64pe32le ppc ppc64 ppc64le s390 s390x sparc sparc64" + +# All known GOARCH_FAMILY values. +ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 S390 S390X SPARC SPARC64" + GOARCH=unknown +GOARCH_FAMILY=unknown +GOARCH_BIGENDIAN=0 +GOARCH_CACHELINESIZE=64 +GOARCH_PHYSPAGESIZE=4096 +GOARCH_PCQUANTUM=1 +GOARCH_INT64ALIGN=8 +GOARCH_HUGEPAGESIZE=0 +GOARCH_MINFRAMESIZE=0 case ${host} in alpha*-*-*) - is_alpha=yes GOARCH=alpha + GOARCH_FAMILY=ALPHA + GOARCH_PHYSPAGESIZE=8192 + GOARCH_PCQUANTUM=4 ;; aarch64-*-*) - is_arm64=yes GOARCH=arm64 + GOARCH_FAMILY=ARM64 + GOARCH_CACHELINESIZE=32 + GOARCH_PHYSPAGESIZE=65536 + GOARCH_PCQUANTUM=4 + GOARCH_MINFRAMESIZE=8 ;; arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*) - is_arm=yes GOARCH=arm + GOARCH_FAMILY=ARM + GOARCH_CACHELINESIZE=32 + GOARCH_PCQUANTUM=4 + GOARCH_INT64ALIGN=4 + GOARCH_MINFRAMESIZE=4 ;; changequote(,)dnl i[34567]86-*-* | x86_64-*-*) @@ -223,20 +240,29 @@ changequote([,])dnl #ifdef __x86_64__ #error 64-bit #endif], -[is_386=yes], [is_x86_64=yes]) - if test "$is_386" = "yes"; then - GOARCH=386 - else - GOARCH=amd64 - fi +[GOARCH=386 +GOARCH_FAMILY=I386 +GOARCH_INT64ALIGN=4 +GOARCH_HUGEPAGESIZE="1 << 21" +], +[GOARCH=amd64 +GOARCH_FAMILY=AMD64 +GOARCH_HUGEPAGESIZE="1 << 21" +]) ;; ia64-*-*) - is_ia64=yes GOARCH=ia64 + GOARCH_FAMILY=IA64 + GOARCH_CACHELINESIZE=16384 + GOARCH_PHYSPAGESIZE=8192 ;; m68k*-*-*) - is_m68k=yes GOARCH=m68k + GOARCH_FAMILY=M68K + GOARCH_BIGENDIAN=1 + GOARCH_CACHELINESIZE=16 + GOARCH_PCQUANTUM=4 + GOARCH_INT64ALIGN=4 ;; mips*-*-*) AC_COMPILE_IFELSE([ @@ -267,72 +293,98 @@ changequote([,])dnl "n64") GOARCH=mipsn64 ;; "o64") GOARCH=mipso64 ;; esac + case "$mips_abi" in + "o32" | "n32") + GOARCH_FAMILY=MIPS + GOARCH_INT64ALIGN=4 + GOARCH_MINFRAMESIZE=4 + ;; + "n64" | "o64") + GOARCH_FAMILY=MIPS64 + GOARCH_MINFRAMESIZE=8 + ;; + esac + case "${host}" in + mips*el) + ;; + *) + GOARCH_BIGENDIAN=1 + ;; + esac + GOARCH_CACHELINESIZE=32 + GOARCH_PHYSPAGESIZE=16384 + GOARCH_PCQUANTUM=4 ;; rs6000*-*-* | powerpc*-*-*) AC_COMPILE_IFELSE([ #ifdef _ARCH_PPC64 #error 64-bit #endif], -[is_ppc=yes], - [AC_COMPILE_IFELSE([ +[GOARCH=ppc +GOARCH_FAMILY=PPC +GOARCH_BIGENDIAN=1 +GOARCH_INT64ALIGN=4 +], + [ +GOARCH_FAMILY=PPC64 +AC_COMPILE_IFELSE([ #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) #error 64be #endif], -[is_ppc64le=yes],[is_ppc64=yes])]) - if test "$is_ppc" = "yes"; then - GOARCH=ppc - elif test "$is_ppc64" = "yes"; then - GOARCH=ppc64 - else - GOARCH=ppc64le - fi +[GOARCH=ppc64le +], +[GOARCH=ppc64 +GOARCH_BIGENDIAN=1 +])]) + GOARCH_PHYSPAGESIZE=65536 + GOARCH_PCQUANTUM=4 + GOARCH_MINFRAMESIZE=32 ;; s390*-*-*) AC_COMPILE_IFELSE([ #if defined(__s390x__) #error 64-bit #endif], -[is_s390=yes], [is_s390x=yes]) - if test "$is_s390" = "yes"; then - GOARCH=s390 - else - GOARCH=s390x - fi +[GOARCH=s390 +GOARCH_FAMILY=S390 +GOARCH_INT64ALIGN=4 +GOARCH_MINFRAMESIZE=4 +], [GOARCH=s390x +GOARCH_FAMILY=S390X +GOARCH_MINFRAMESIZE=8 +]) + GOARCH_BIGENDIAN=1 + GOARCH_CACHELINESIZE=256 + GOARCH_PCQUANTUM=2 ;; sparc*-*-*) AC_COMPILE_IFELSE([ #if defined(__sparcv9) || defined(__arch64__) #error 64-bit #endif], -[is_sparc=yes], [is_sparc64=yes]) - if test "$is_sparc" = "yes"; then - GOARCH=sparc - else - GOARCH=sparc64 - fi +[GOARCH=sparc +GOARCH_FAMILY=SPARC +GOARCH_INT64ALIGN=4 +], +[GOARCH=sparc64 +GOARCH_FAMILY=SPARC64 +]) + GOARCH_BIGENDIAN=1 + GOARCH_PHYSPAGESIZE=8192 + GOARCH_PCQUANTUM=4 ;; esac -AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes) -AM_CONDITIONAL(LIBGO_IS_ALPHA, test $is_alpha = yes) -AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes) -AM_CONDITIONAL(LIBGO_IS_ARM64, test $is_arm64 = yes) -AM_CONDITIONAL(LIBGO_IS_IA64, test $is_ia64 = yes) -AM_CONDITIONAL(LIBGO_IS_M68K, test $is_m68k = yes) -AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != unknown) -AM_CONDITIONAL(LIBGO_IS_MIPSO32, test $mips_abi = o32) -AM_CONDITIONAL(LIBGO_IS_MIPSN32, test $mips_abi = n32) -AM_CONDITIONAL(LIBGO_IS_MIPSN64, test $mips_abi = n64) -AM_CONDITIONAL(LIBGO_IS_MIPSO64, test $mips_abi = o64) -AM_CONDITIONAL(LIBGO_IS_MIPS64, test $mips_abi = n64 -o $mips_abi = o64) -AM_CONDITIONAL(LIBGO_IS_PPC, test $is_ppc = yes) -AM_CONDITIONAL(LIBGO_IS_PPC64, test $is_ppc64 = yes) -AM_CONDITIONAL(LIBGO_IS_PPC64LE, test $is_ppc64le = yes) -AM_CONDITIONAL(LIBGO_IS_S390, test $is_s390 = yes) -AM_CONDITIONAL(LIBGO_IS_S390X, test $is_s390x = yes) -AM_CONDITIONAL(LIBGO_IS_SPARC, test $is_sparc = yes) -AM_CONDITIONAL(LIBGO_IS_SPARC64, test $is_sparc64 = yes) -AM_CONDITIONAL(LIBGO_IS_X86_64, test $is_x86_64 = yes) AC_SUBST(GOARCH) +AC_SUBST(GOARCH_FAMILY) +AC_SUBST(GOARCH_BIGENDIAN) +AC_SUBST(GOARCH_CACHELINESIZE) +AC_SUBST(GOARCH_PHYSPAGESIZE) +AC_SUBST(GOARCH_PCQUANTUM) +AC_SUBST(GOARCH_INT64ALIGN) +AC_SUBST(GOARCH_HUGEPAGESIZE) +AC_SUBST(GOARCH_MINFRAMESIZE) +AC_SUBST(ALLGOARCH) +AC_SUBST(ALLGOARCHFAMILY) dnl Some files are only present when needed for specific architectures. GO_LIBCALL_OS_FILE= diff --git a/libgo/go/compress/flate/deflate.go b/libgo/go/compress/flate/deflate.go index 8a085ba3474..9f53d51a6e7 100644 --- a/libgo/go/compress/flate/deflate.go +++ b/libgo/go/compress/flate/deflate.go @@ -15,7 +15,17 @@ const ( BestSpeed = 1 BestCompression = 9 DefaultCompression = -1 - HuffmanOnly = -2 // Disables match search and only does Huffman entropy reduction. + + // HuffmanOnly disables Lempel-Ziv match searching and only performs Huffman + // entropy encoding. This mode is useful in compressing data that has + // already been compressed with an LZ style algorithm (e.g. Snappy or LZ4) + // that lacks an entropy encoder. Compression gains are achieved when + // certain bytes in the input stream occur more frequently than others. + // + // Note that HuffmanOnly produces a compressed output that is + // RFC 1951 compliant. That is, any valid DEFLATE decompressor will + // continue to be able to decompress this output. + HuffmanOnly = -2 ) const ( @@ -644,7 +654,6 @@ func (d *compressor) close() error { // a very fast compression for all types of input, but sacrificing considerable // compression efficiency. // -// // If level is in the range [-2, 9] then the error returned will be nil. // Otherwise the error returned will be non-nil. func NewWriter(w io.Writer, level int) (*Writer, error) { @@ -715,7 +724,7 @@ func (w *Writer) Close() error { // the result of NewWriter or NewWriterDict called with dst // and w's level and dictionary. func (w *Writer) Reset(dst io.Writer) { - if dw, ok := w.d.w.w.(*dictWriter); ok { + if dw, ok := w.d.w.writer.(*dictWriter); ok { // w was created with NewWriterDict dw.w = dst w.d.reset(dw) diff --git a/libgo/go/compress/flate/deflate_test.go b/libgo/go/compress/flate/deflate_test.go index 27a3b3823a6..3322c40845d 100644 --- a/libgo/go/compress/flate/deflate_test.go +++ b/libgo/go/compress/flate/deflate_test.go @@ -6,6 +6,7 @@ package flate import ( "bytes" + "errors" "fmt" "internal/testenv" "io" @@ -631,3 +632,52 @@ func TestBestSpeed(t *testing.T) { } } } + +var errIO = errors.New("IO error") + +// failWriter fails with errIO exactly at the nth call to Write. +type failWriter struct{ n int } + +func (w *failWriter) Write(b []byte) (int, error) { + w.n-- + if w.n == -1 { + return 0, errIO + } + return len(b), nil +} + +func TestWriterPersistentError(t *testing.T) { + d, err := ioutil.ReadFile("../testdata/Mark.Twain-Tom.Sawyer.txt") + if err != nil { + t.Fatalf("ReadFile: %v", err) + } + d = d[:10000] // Keep this test short + + zw, err := NewWriter(nil, DefaultCompression) + if err != nil { + t.Fatalf("NewWriter: %v", err) + } + + // Sweep over the threshold at which an error is returned. + // The variable i makes it such that the ith call to failWriter.Write will + // return errIO. Since failWriter errors are not persistent, we must ensure + // that flate.Writer errors are persistent. + for i := 0; i < 1000; i++ { + fw := &failWriter{i} + zw.Reset(fw) + + _, werr := zw.Write(d) + cerr := zw.Close() + if werr != errIO && werr != nil { + t.Errorf("test %d, mismatching Write error: got %v, want %v", i, werr, errIO) + } + if cerr != errIO && fw.n < 0 { + t.Errorf("test %d, mismatching Close error: got %v, want %v", i, cerr, errIO) + } + if fw.n >= 0 { + // At this point, the failure threshold was sufficiently high enough + // that we wrote the whole stream without any errors. + return + } + } +} diff --git a/libgo/go/compress/flate/huffman_bit_writer.go b/libgo/go/compress/flate/huffman_bit_writer.go index c4adef9ff53..d8b5a3ebd7b 100644 --- a/libgo/go/compress/flate/huffman_bit_writer.go +++ b/libgo/go/compress/flate/huffman_bit_writer.go @@ -77,7 +77,11 @@ var offsetBase = []uint32{ var codegenOrder = []uint32{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15} type huffmanBitWriter struct { - w io.Writer + // writer is the underlying writer. + // Do not use it directly; use the write method, which ensures + // that Write errors are sticky. + writer io.Writer + // Data waiting to be written is bytes[0:nbytes] // and then the low nbits of bits. bits uint64 @@ -96,7 +100,7 @@ type huffmanBitWriter struct { func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter { return &huffmanBitWriter{ - w: w, + writer: w, literalFreq: make([]int32, maxNumLit), offsetFreq: make([]int32, offsetCodeCount), codegen: make([]uint8, maxNumLit+offsetCodeCount+1), @@ -107,7 +111,7 @@ func newHuffmanBitWriter(w io.Writer) *huffmanBitWriter { } func (w *huffmanBitWriter) reset(writer io.Writer) { - w.w = writer + w.writer = writer w.bits, w.nbits, w.nbytes, w.err = 0, 0, 0, nil w.bytes = [bufferSize]byte{} } @@ -129,11 +133,21 @@ func (w *huffmanBitWriter) flush() { n++ } w.bits = 0 - _, w.err = w.w.Write(w.bytes[:n]) + w.write(w.bytes[:n]) w.nbytes = 0 } +func (w *huffmanBitWriter) write(b []byte) { + if w.err != nil { + return + } + _, w.err = w.writer.Write(b) +} + func (w *huffmanBitWriter) writeBits(b int32, nb uint) { + if w.err != nil { + return + } w.bits |= uint64(b) << w.nbits w.nbits += nb if w.nbits >= 48 { @@ -150,7 +164,7 @@ func (w *huffmanBitWriter) writeBits(b int32, nb uint) { bytes[5] = byte(bits >> 40) n += 6 if n >= bufferFlushSize { - _, w.err = w.w.Write(w.bytes[:n]) + w.write(w.bytes[:n]) n = 0 } w.nbytes = n @@ -173,13 +187,10 @@ func (w *huffmanBitWriter) writeBytes(bytes []byte) { n++ } if n != 0 { - _, w.err = w.w.Write(w.bytes[:n]) - if w.err != nil { - return - } + w.write(w.bytes[:n]) } w.nbytes = 0 - _, w.err = w.w.Write(bytes) + w.write(bytes) } // RFC 1951 3.2.7 specifies a special run-length encoding for specifying @@ -341,7 +352,7 @@ func (w *huffmanBitWriter) writeCode(c hcode) { bytes[5] = byte(bits >> 40) n += 6 if n >= bufferFlushSize { - _, w.err = w.w.Write(w.bytes[:n]) + w.write(w.bytes[:n]) n = 0 } w.nbytes = n @@ -572,6 +583,9 @@ func (w *huffmanBitWriter) indexTokens(tokens []token) (numLiterals, numOffsets // writeTokens writes a slice of tokens to the output. // codes for literal and offset encoding must be supplied. func (w *huffmanBitWriter) writeTokens(tokens []token, leCodes, oeCodes []hcode) { + if w.err != nil { + return + } for _, t := range tokens { if t < matchType { w.writeCode(leCodes[t.literal()]) @@ -676,9 +690,9 @@ func (w *huffmanBitWriter) writeBlockHuff(eof bool, input []byte) { if n < bufferFlushSize { continue } - _, w.err = w.w.Write(w.bytes[:n]) + w.write(w.bytes[:n]) if w.err != nil { - return + return // Return early in the event of write failures } n = 0 } diff --git a/libgo/go/context/context_test.go b/libgo/go/context/context_test.go index 90e78e57ecc..cf182110fbd 100644 --- a/libgo/go/context/context_test.go +++ b/libgo/go/context/context_test.go @@ -255,6 +255,12 @@ func TestDeadline(t *testing.T) { o = otherContext{c} c, _ = WithDeadline(o, time.Now().Add(4*time.Second)) testDeadline(c, "WithDeadline+otherContext+WithDeadline", 2*time.Second, t) + + c, _ = WithDeadline(Background(), time.Now().Add(-time.Millisecond)) + testDeadline(c, "WithDeadline+inthepast", time.Second, t) + + c, _ = WithDeadline(Background(), time.Now()) + testDeadline(c, "WithDeadline+now", time.Second, t) } func TestTimeout(t *testing.T) { diff --git a/libgo/go/crypto/x509/root_cgo_darwin.go b/libgo/go/crypto/x509/root_cgo_darwin.go index 0e2fb357ee9..a4b33c7660e 100644 --- a/libgo/go/crypto/x509/root_cgo_darwin.go +++ b/libgo/go/crypto/x509/root_cgo_darwin.go @@ -10,9 +10,65 @@ package x509 #cgo CFLAGS: -mmacosx-version-min=10.6 -D__MAC_OS_X_VERSION_MAX_ALLOWED=1060 #cgo LDFLAGS: -framework CoreFoundation -framework Security +#include <errno.h> +#include <sys/sysctl.h> + #include <CoreFoundation/CoreFoundation.h> #include <Security/Security.h> +// FetchPEMRoots_MountainLion is the version of FetchPEMRoots from Go 1.6 +// which still works on OS X 10.8 (Mountain Lion). +// It lacks support for admin & user cert domains. +// See golang.org/issue/16473 +int FetchPEMRoots_MountainLion(CFDataRef *pemRoots) { + if (pemRoots == NULL) { + return -1; + } + CFArrayRef certs = NULL; + OSStatus err = SecTrustCopyAnchorCertificates(&certs); + if (err != noErr) { + return -1; + } + CFMutableDataRef combinedData = CFDataCreateMutable(kCFAllocatorDefault, 0); + int i, ncerts = CFArrayGetCount(certs); + for (i = 0; i < ncerts; i++) { + CFDataRef data = NULL; + SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs, i); + if (cert == NULL) { + continue; + } + // Note: SecKeychainItemExport is deprecated as of 10.7 in favor of SecItemExport. + // Once we support weak imports via cgo we should prefer that, and fall back to this + // for older systems. + err = SecKeychainItemExport(cert, kSecFormatX509Cert, kSecItemPemArmour, NULL, &data); + if (err != noErr) { + continue; + } + if (data != NULL) { + CFDataAppendBytes(combinedData, CFDataGetBytePtr(data), CFDataGetLength(data)); + CFRelease(data); + } + } + CFRelease(certs); + *pemRoots = combinedData; + return 0; +} + +// useOldCode reports whether the running machine is OS X 10.8 Mountain Lion +// or older. We only support Mountain Lion and higher, but we'll at least try our +// best on older machines and continue to use the old code path. +// +// See golang.org/issue/16473 +int useOldCode() { + char str[256]; + size_t size = sizeof(str); + memset(str, 0, size); + sysctlbyname("kern.osrelease", str, &size, NULL, 0); + // OS X 10.8 is osrelease "12.*", 10.7 is 11.*, 10.6 is 10.*. + // We never supported things before that. + return memcmp(str, "12.", 3) == 0 || memcmp(str, "11.", 3) == 0 || memcmp(str, "10.", 3) == 0; +} + // FetchPEMRoots fetches the system's list of trusted X.509 root certificates. // // On success it returns 0 and fills pemRoots with a CFDataRef that contains the extracted root @@ -21,6 +77,10 @@ package x509 // Note: The CFDataRef returned in pemRoots must be released (using CFRelease) after // we've consumed its content. int FetchPEMRoots(CFDataRef *pemRoots) { + if (useOldCode()) { + return FetchPEMRoots_MountainLion(pemRoots); + } + // Get certificates from all domains, not just System, this lets // the user add CAs to their "login" keychain, and Admins to add // to the "System" keychain diff --git a/libgo/go/hash/crc32/crc32_s390x.go b/libgo/go/hash/crc32/crc32_s390x.go index b8a580870c5..2a7926b4796 100644 --- a/libgo/go/hash/crc32/crc32_s390x.go +++ b/libgo/go/hash/crc32/crc32_s390x.go @@ -6,14 +6,9 @@ package crc32 -import ( - "unsafe" -) - const ( vxMinLen = 64 - vxAlignment = 16 - vxAlignMask = vxAlignment - 1 + vxAlignMask = 15 // align to 16 bytes ) // hasVectorFacility reports whether the machine has the z/Architecture @@ -51,20 +46,13 @@ func genericIEEE(crc uint32, p []byte) uint32 { return update(crc, IEEETable, p) } -// updateCastagnoli calculates the checksum of p using genericCastagnoli to -// align the data appropriately for vectorCastagnoli. It avoids using -// vectorCastagnoli entirely if the length of p is less than or equal to -// vxMinLen. +// updateCastagnoli calculates the checksum of p using +// vectorizedCastagnoli if possible and falling back onto +// genericCastagnoli as needed. func updateCastagnoli(crc uint32, p []byte) uint32 { // Use vectorized function if vector facility is available and // data length is above threshold. - if hasVX && len(p) > vxMinLen { - pAddr := uintptr(unsafe.Pointer(&p[0])) - if pAddr&vxAlignMask != 0 { - prealign := vxAlignment - int(pAddr&vxAlignMask) - crc = genericCastagnoli(crc, p[:prealign]) - p = p[prealign:] - } + if hasVX && len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedCastagnoli(crc, p[:aligned]) p = p[aligned:] @@ -77,19 +65,12 @@ func updateCastagnoli(crc uint32, p []byte) uint32 { return genericCastagnoli(crc, p) } -// updateIEEE calculates the checksum of p using genericIEEE to align the data -// appropriately for vectorIEEE. It avoids using vectorIEEE entirely if the length -// of p is less than or equal to vxMinLen. +// updateIEEE calculates the checksum of p using vectorizedIEEE if +// possible and falling back onto genericIEEE as needed. func updateIEEE(crc uint32, p []byte) uint32 { // Use vectorized function if vector facility is available and // data length is above threshold. - if hasVX && len(p) > vxMinLen { - pAddr := uintptr(unsafe.Pointer(&p[0])) - if pAddr&vxAlignMask != 0 { - prealign := vxAlignment - int(pAddr&vxAlignMask) - crc = genericIEEE(crc, p[:prealign]) - p = p[prealign:] - } + if hasVX && len(p) >= vxMinLen { aligned := len(p) & ^vxAlignMask crc = vectorizedIEEE(crc, p[:aligned]) p = p[aligned:] diff --git a/libgo/go/io/multi.go b/libgo/go/io/multi.go index ed05cac9e72..3a9d03652b0 100644 --- a/libgo/go/io/multi.go +++ b/libgo/go/io/multi.go @@ -18,15 +18,16 @@ func (mr *multiReader) Read(p []byte) (n int, err error) { } } n, err = mr.readers[0].Read(p) + if err == EOF { + mr.readers = mr.readers[1:] + } if n > 0 || err != EOF { - if err == EOF { - // Don't return EOF yet. There may be more bytes - // in the remaining readers. + if err == EOF && len(mr.readers) > 0 { + // Don't return EOF yet. More readers remain. err = nil } return } - mr.readers = mr.readers[1:] } return 0, EOF } diff --git a/libgo/go/io/multi_test.go b/libgo/go/io/multi_test.go index a434453f6b0..447e7f59635 100644 --- a/libgo/go/io/multi_test.go +++ b/libgo/go/io/multi_test.go @@ -197,3 +197,41 @@ func TestMultiReaderFlatten(t *testing.T) { myDepth+2, readDepth) } } + +// byteAndEOFReader is a Reader which reads one byte (the underlying +// byte) and io.EOF at once in its Read call. +type byteAndEOFReader byte + +func (b byteAndEOFReader) Read(p []byte) (n int, err error) { + if len(p) == 0 { + // Read(0 bytes) is useless. We expect no such useless + // calls in this test. + panic("unexpected call") + } + p[0] = byte(b) + return 1, EOF +} + +// In Go 1.7, this yielded bytes forever. +func TestMultiReaderSingleByteWithEOF(t *testing.T) { + got, err := ioutil.ReadAll(LimitReader(MultiReader(byteAndEOFReader('a'), byteAndEOFReader('b')), 10)) + if err != nil { + t.Fatal(err) + } + const want = "ab" + if string(got) != want { + t.Errorf("got %q; want %q", got, want) + } +} + +// Test that a reader returning (n, EOF) at the end of an MultiReader +// chain continues to return EOF on its final read, rather than +// yielding a (0, EOF). +func TestMultiReaderFinalEOF(t *testing.T) { + r := MultiReader(bytes.NewReader(nil), byteAndEOFReader('a')) + buf := make([]byte, 2) + n, err := r.Read(buf) + if n != 1 || err != EOF { + t.Errorf("got %v, %v; want 1, EOF", n, err) + } +} diff --git a/libgo/go/net/dial_unix_test.go b/libgo/go/net/dial_unix_test.go new file mode 100644 index 00000000000..47052547284 --- /dev/null +++ b/libgo/go/net/dial_unix_test.go @@ -0,0 +1,108 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd linux netbsd openbsd solaris + +package net + +import ( + "context" + "syscall" + "testing" + "time" +) + +// Issue 16523 +func TestDialContextCancelRace(t *testing.T) { + oldConnectFunc := connectFunc + oldGetsockoptIntFunc := getsockoptIntFunc + oldTestHookCanceledDial := testHookCanceledDial + defer func() { + connectFunc = oldConnectFunc + getsockoptIntFunc = oldGetsockoptIntFunc + testHookCanceledDial = oldTestHookCanceledDial + }() + + ln, err := newLocalListener("tcp") + if err != nil { + t.Fatal(err) + } + listenerDone := make(chan struct{}) + go func() { + defer close(listenerDone) + c, err := ln.Accept() + if err == nil { + c.Close() + } + }() + defer func() { <-listenerDone }() + defer ln.Close() + + sawCancel := make(chan bool, 1) + testHookCanceledDial = func() { + sawCancel <- true + } + + ctx, cancelCtx := context.WithCancel(context.Background()) + + connectFunc = func(fd int, addr syscall.Sockaddr) error { + err := oldConnectFunc(fd, addr) + t.Logf("connect(%d, addr) = %v", fd, err) + if err == nil { + // On some operating systems, localhost + // connects _sometimes_ succeed immediately. + // Prevent that, so we exercise the code path + // we're interested in testing. This seems + // harmless. It makes FreeBSD 10.10 work when + // run with many iterations. It failed about + // half the time previously. + return syscall.EINPROGRESS + } + return err + } + + getsockoptIntFunc = func(fd, level, opt int) (val int, err error) { + val, err = oldGetsockoptIntFunc(fd, level, opt) + t.Logf("getsockoptIntFunc(%d, %d, %d) = (%v, %v)", fd, level, opt, val, err) + if level == syscall.SOL_SOCKET && opt == syscall.SO_ERROR && err == nil && val == 0 { + t.Logf("canceling context") + + // Cancel the context at just the moment which + // caused the race in issue 16523. + cancelCtx() + + // And wait for the "interrupter" goroutine to + // cancel the dial by messing with its write + // timeout before returning. + select { + case <-sawCancel: + t.Logf("saw cancel") + case <-time.After(5 * time.Second): + t.Errorf("didn't see cancel after 5 seconds") + } + } + return + } + + var d Dialer + c, err := d.DialContext(ctx, "tcp", ln.Addr().String()) + if err == nil { + c.Close() + t.Fatal("unexpected successful dial; want context canceled error") + } + + select { + case <-ctx.Done(): + case <-time.After(5 * time.Second): + t.Fatal("expected context to be canceled") + } + + oe, ok := err.(*OpError) + if !ok || oe.Op != "dial" { + t.Fatalf("Dial error = %#v; want dial *OpError", err) + } + if oe.Err != ctx.Err() { + t.Errorf("DialContext = (%v, %v); want OpError with error %v", c, err, ctx.Err()) + } +} diff --git a/libgo/go/net/dnsclient_unix.go b/libgo/go/net/dnsclient_unix.go index 8f2dff46751..b5b6ffb1c50 100644 --- a/libgo/go/net/dnsclient_unix.go +++ b/libgo/go/net/dnsclient_unix.go @@ -141,7 +141,7 @@ func (d *Dialer) dialDNS(ctx context.Context, network, server string) (dnsConn, } // exchange sends a query on the connection and hopes for a response. -func exchange(ctx context.Context, server, name string, qtype uint16) (*dnsMsg, error) { +func exchange(ctx context.Context, server, name string, qtype uint16, timeout time.Duration) (*dnsMsg, error) { d := testHookDNSDialer() out := dnsMsg{ dnsMsgHdr: dnsMsgHdr{ @@ -152,6 +152,12 @@ func exchange(ctx context.Context, server, name string, qtype uint16) (*dnsMsg, }, } for _, network := range []string{"udp", "tcp"} { + // TODO(mdempsky): Refactor so defers from UDP-based + // exchanges happen before TCP-based exchange. + + ctx, cancel := context.WithDeadline(ctx, time.Now().Add(timeout)) + defer cancel() + c, err := d.dialDNS(ctx, network, server) if err != nil { return nil, err @@ -180,17 +186,10 @@ func tryOneName(ctx context.Context, cfg *dnsConfig, name string, qtype uint16) return "", nil, &DNSError{Err: "no DNS servers", Name: name} } - deadline := time.Now().Add(cfg.timeout) - if old, ok := ctx.Deadline(); !ok || deadline.Before(old) { - var cancel context.CancelFunc - ctx, cancel = context.WithDeadline(ctx, deadline) - defer cancel() - } - var lastErr error for i := 0; i < cfg.attempts; i++ { for _, server := range cfg.servers { - msg, err := exchange(ctx, server, name, qtype) + msg, err := exchange(ctx, server, name, qtype, cfg.timeout) if err != nil { lastErr = &DNSError{ Err: err.Error(), @@ -338,8 +337,9 @@ func lookup(ctx context.Context, name string, qtype uint16) (cname string, rrs [ } // avoidDNS reports whether this is a hostname for which we should not -// use DNS. Currently this includes only .onion and .local names, -// per RFC 7686 and RFC 6762, respectively. See golang.org/issue/13705. +// use DNS. Currently this includes only .onion, per RFC 7686. See +// golang.org/issue/13705. Does not cover .local names (RFC 6762), +// see golang.org/issue/16739. func avoidDNS(name string) bool { if name == "" { return true @@ -347,7 +347,7 @@ func avoidDNS(name string) bool { if name[len(name)-1] == '.' { name = name[:len(name)-1] } - return stringsHasSuffixFold(name, ".onion") || stringsHasSuffixFold(name, ".local") + return stringsHasSuffixFold(name, ".onion") } // nameList returns a list of names for sequential DNS queries. diff --git a/libgo/go/net/dnsclient_unix_test.go b/libgo/go/net/dnsclient_unix_test.go index 09bbd488660..6ebeeaeb8f4 100644 --- a/libgo/go/net/dnsclient_unix_test.go +++ b/libgo/go/net/dnsclient_unix_test.go @@ -40,9 +40,9 @@ func TestDNSTransportFallback(t *testing.T) { testenv.MustHaveExternalNetwork(t) for _, tt := range dnsTransportFallbackTests { - ctx, cancel := context.WithTimeout(context.Background(), time.Duration(tt.timeout)*time.Second) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - msg, err := exchange(ctx, tt.server, tt.name, tt.qtype) + msg, err := exchange(ctx, tt.server, tt.name, tt.qtype, time.Second) if err != nil { t.Error(err) continue @@ -82,9 +82,9 @@ func TestSpecialDomainName(t *testing.T) { server := "8.8.8.8:53" for _, tt := range specialDomainNameTests { - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - msg, err := exchange(ctx, server, tt.name, tt.qtype) + msg, err := exchange(ctx, server, tt.name, tt.qtype, 3*time.Second) if err != nil { t.Error(err) continue @@ -112,10 +112,11 @@ func TestAvoidDNSName(t *testing.T) { {"foo.ONION", true}, {"foo.ONION.", true}, - {"foo.local.", true}, - {"foo.local", true}, - {"foo.LOCAL", true}, - {"foo.LOCAL.", true}, + // But do resolve *.local address; Issue 16739 + {"foo.local.", false}, + {"foo.local", false}, + {"foo.LOCAL", false}, + {"foo.LOCAL.", false}, {"", true}, // will be rejected earlier too @@ -500,7 +501,7 @@ func TestErrorForOriginalNameWhenSearching(t *testing.T) { d := &fakeDNSDialer{} testHookDNSDialer = func() dnsDialer { return d } - d.rh = func(s string, q *dnsMsg) (*dnsMsg, error) { + d.rh = func(s string, q *dnsMsg, _ time.Time) (*dnsMsg, error) { r := &dnsMsg{ dnsMsgHdr: dnsMsgHdr{ id: q.id, @@ -539,14 +540,15 @@ func TestIgnoreLameReferrals(t *testing.T) { } defer conf.teardown() - if err := conf.writeAndUpdate([]string{"nameserver 192.0.2.1", "nameserver 192.0.2.2"}); err != nil { + if err := conf.writeAndUpdate([]string{"nameserver 192.0.2.1", // the one that will give a lame referral + "nameserver 192.0.2.2"}); err != nil { t.Fatal(err) } d := &fakeDNSDialer{} testHookDNSDialer = func() dnsDialer { return d } - d.rh = func(s string, q *dnsMsg) (*dnsMsg, error) { + d.rh = func(s string, q *dnsMsg, _ time.Time) (*dnsMsg, error) { t.Log(s, q) r := &dnsMsg{ dnsMsgHdr: dnsMsgHdr{ @@ -633,28 +635,30 @@ func BenchmarkGoLookupIPWithBrokenNameServer(b *testing.B) { type fakeDNSDialer struct { // reply handler - rh func(s string, q *dnsMsg) (*dnsMsg, error) + rh func(s string, q *dnsMsg, t time.Time) (*dnsMsg, error) } func (f *fakeDNSDialer) dialDNS(_ context.Context, n, s string) (dnsConn, error) { - return &fakeDNSConn{f.rh, s}, nil + return &fakeDNSConn{f.rh, s, time.Time{}}, nil } type fakeDNSConn struct { - rh func(s string, q *dnsMsg) (*dnsMsg, error) + rh func(s string, q *dnsMsg, t time.Time) (*dnsMsg, error) s string + t time.Time } func (f *fakeDNSConn) Close() error { return nil } -func (f *fakeDNSConn) SetDeadline(time.Time) error { +func (f *fakeDNSConn) SetDeadline(t time.Time) error { + f.t = t return nil } func (f *fakeDNSConn) dnsRoundTrip(q *dnsMsg) (*dnsMsg, error) { - return f.rh(f.s, q) + return f.rh(f.s, q, f.t) } // UDP round-tripper algorithm should ignore invalid DNS responses (issue 13281). @@ -724,3 +728,72 @@ func TestIgnoreDNSForgeries(t *testing.T) { t.Errorf("got address %v, want %v", got, TestAddr) } } + +// Issue 16865. If a name server times out, continue to the next. +func TestRetryTimeout(t *testing.T) { + origTestHookDNSDialer := testHookDNSDialer + defer func() { testHookDNSDialer = origTestHookDNSDialer }() + + conf, err := newResolvConfTest() + if err != nil { + t.Fatal(err) + } + defer conf.teardown() + + if err := conf.writeAndUpdate([]string{"nameserver 192.0.2.1", // the one that will timeout + "nameserver 192.0.2.2"}); err != nil { + t.Fatal(err) + } + + d := &fakeDNSDialer{} + testHookDNSDialer = func() dnsDialer { return d } + + var deadline0 time.Time + + d.rh = func(s string, q *dnsMsg, deadline time.Time) (*dnsMsg, error) { + t.Log(s, q, deadline) + + if deadline.IsZero() { + t.Error("zero deadline") + } + + if s == "192.0.2.1:53" { + deadline0 = deadline + time.Sleep(10 * time.Millisecond) + return nil, errTimeout + } + + if deadline == deadline0 { + t.Error("deadline didn't change") + } + + r := &dnsMsg{ + dnsMsgHdr: dnsMsgHdr{ + id: q.id, + response: true, + recursion_available: true, + }, + question: q.question, + answer: []dnsRR{ + &dnsRR_CNAME{ + Hdr: dnsRR_Header{ + Name: q.question[0].Name, + Rrtype: dnsTypeCNAME, + Class: dnsClassINET, + }, + Cname: "golang.org", + }, + }, + } + return r, nil + } + + _, err = goLookupCNAME(context.Background(), "www.golang.org") + if err != nil { + t.Fatal(err) + } + + if deadline0.IsZero() { + t.Error("deadline0 still zero", deadline0) + } +} diff --git a/libgo/go/net/fd_unix.go b/libgo/go/net/fd_unix.go index 6fbb9cbf114..0309db08ebc 100644 --- a/libgo/go/net/fd_unix.go +++ b/libgo/go/net/fd_unix.go @@ -64,7 +64,7 @@ func (fd *netFD) name() string { return fd.net + ":" + ls + "->" + rs } -func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) error { +func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (ret error) { // Do not need to call fd.writeLock here, // because fd is not yet accessible to user, // so no concurrent operations are possible. @@ -101,21 +101,44 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) error { defer fd.setWriteDeadline(noDeadline) } - // Wait for the goroutine converting context.Done into a write timeout - // to exist, otherwise our caller might cancel the context and - // cause fd.setWriteDeadline(aLongTimeAgo) to cancel a successful dial. - done := make(chan bool) // must be unbuffered - defer func() { done <- true }() - go func() { - select { - case <-ctx.Done(): - // Force the runtime's poller to immediately give - // up waiting for writability. - fd.setWriteDeadline(aLongTimeAgo) - <-done - case <-done: - } - }() + // Start the "interrupter" goroutine, if this context might be canceled. + // (The background context cannot) + // + // The interrupter goroutine waits for the context to be done and + // interrupts the dial (by altering the fd's write deadline, which + // wakes up waitWrite). + if ctx != context.Background() { + // Wait for the interrupter goroutine to exit before returning + // from connect. + done := make(chan struct{}) + interruptRes := make(chan error) + defer func() { + close(done) + if ctxErr := <-interruptRes; ctxErr != nil && ret == nil { + // The interrupter goroutine called setWriteDeadline, + // but the connect code below had returned from + // waitWrite already and did a successful connect (ret + // == nil). Because we've now poisoned the connection + // by making it unwritable, don't return a successful + // dial. This was issue 16523. + ret = ctxErr + fd.Close() // prevent a leak + } + }() + go func() { + select { + case <-ctx.Done(): + // Force the runtime's poller to immediately give up + // waiting for writability, unblocking waitWrite + // below. + fd.setWriteDeadline(aLongTimeAgo) + testHookCanceledDial() + interruptRes <- ctx.Err() + case <-done: + interruptRes <- nil + } + }() + } for { // Performing multiple connect system calls on a diff --git a/libgo/go/net/hook_unix.go b/libgo/go/net/hook_unix.go index 361ca5980c3..cf52567fcfd 100644 --- a/libgo/go/net/hook_unix.go +++ b/libgo/go/net/hook_unix.go @@ -9,7 +9,8 @@ package net import "syscall" var ( - testHookDialChannel = func() {} // see golang.org/issue/5349 + testHookDialChannel = func() {} // for golang.org/issue/5349 + testHookCanceledDial = func() {} // for golang.org/issue/16523 // Placeholders for socket system calls. socketFunc func(int, int, int) (int, error) = syscall.Socket diff --git a/libgo/go/net/http/h2_bundle.go b/libgo/go/net/http/h2_bundle.go index db774554b2c..5826bb7d858 100644 --- a/libgo/go/net/http/h2_bundle.go +++ b/libgo/go/net/http/h2_bundle.go @@ -28,6 +28,7 @@ import ( "io" "io/ioutil" "log" + "math" "net" "net/http/httptrace" "net/textproto" @@ -85,7 +86,16 @@ const ( http2noDialOnMiss = false ) -func (p *http2clientConnPool) getClientConn(_ *Request, addr string, dialOnMiss bool) (*http2ClientConn, error) { +func (p *http2clientConnPool) getClientConn(req *Request, addr string, dialOnMiss bool) (*http2ClientConn, error) { + if http2isConnectionCloseRequest(req) && dialOnMiss { + // It gets its own connection. + const singleUse = true + cc, err := p.t.dialClientConn(addr, singleUse) + if err != nil { + return nil, err + } + return cc, nil + } p.mu.Lock() for _, cc := range p.conns[addr] { if cc.CanTakeNewRequest() { @@ -128,7 +138,8 @@ func (p *http2clientConnPool) getStartDialLocked(addr string) *http2dialCall { // run in its own goroutine. func (c *http2dialCall) dial(addr string) { - c.res, c.err = c.p.t.dialClientConn(addr) + const singleUse = false // shared conn + c.res, c.err = c.p.t.dialClientConn(addr, singleUse) close(c.done) c.p.mu.Lock() @@ -393,9 +404,17 @@ func (e http2ConnectionError) Error() string { type http2StreamError struct { StreamID uint32 Code http2ErrCode + Cause error // optional additional detail +} + +func http2streamError(id uint32, code http2ErrCode) http2StreamError { + return http2StreamError{StreamID: id, Code: code} } func (e http2StreamError) Error() string { + if e.Cause != nil { + return fmt.Sprintf("stream error: stream ID %d; %v; %v", e.StreamID, e.Code, e.Cause) + } return fmt.Sprintf("stream error: stream ID %d; %v", e.StreamID, e.Code) } @@ -1105,6 +1124,7 @@ func http2parseDataFrame(fh http2FrameHeader, payload []byte) (http2Frame, error var ( http2errStreamID = errors.New("invalid stream ID") http2errDepStreamID = errors.New("invalid dependent stream ID") + http2errPadLength = errors.New("pad length too large") ) func http2validStreamIDOrZero(streamID uint32) bool { @@ -1118,18 +1138,40 @@ func http2validStreamID(streamID uint32) bool { // WriteData writes a DATA frame. // // It will perform exactly one Write to the underlying Writer. -// It is the caller's responsibility to not call other Write methods concurrently. +// It is the caller's responsibility not to violate the maximum frame size +// and to not call other Write methods concurrently. func (f *http2Framer) WriteData(streamID uint32, endStream bool, data []byte) error { + return f.WriteDataPadded(streamID, endStream, data, nil) +} +// WriteData writes a DATA frame with optional padding. +// +// If pad is nil, the padding bit is not sent. +// The length of pad must not exceed 255 bytes. +// +// It will perform exactly one Write to the underlying Writer. +// It is the caller's responsibility not to violate the maximum frame size +// and to not call other Write methods concurrently. +func (f *http2Framer) WriteDataPadded(streamID uint32, endStream bool, data, pad []byte) error { if !http2validStreamID(streamID) && !f.AllowIllegalWrites { return http2errStreamID } + if len(pad) > 255 { + return http2errPadLength + } var flags http2Flags if endStream { flags |= http2FlagDataEndStream } + if pad != nil { + flags |= http2FlagDataPadded + } f.startWrite(http2FrameData, flags, streamID) + if pad != nil { + f.wbuf = append(f.wbuf, byte(len(pad))) + } f.wbuf = append(f.wbuf, data...) + f.wbuf = append(f.wbuf, pad...) return f.endWrite() } @@ -1333,7 +1375,7 @@ func http2parseWindowUpdateFrame(fh http2FrameHeader, p []byte) (http2Frame, err if fh.StreamID == 0 { return nil, http2ConnectionError(http2ErrCodeProtocol) } - return nil, http2StreamError{fh.StreamID, http2ErrCodeProtocol} + return nil, http2streamError(fh.StreamID, http2ErrCodeProtocol) } return &http2WindowUpdateFrame{ http2FrameHeader: fh, @@ -1411,7 +1453,7 @@ func http2parseHeadersFrame(fh http2FrameHeader, p []byte) (_ http2Frame, err er } } if len(p)-int(padLength) <= 0 { - return nil, http2StreamError{fh.StreamID, http2ErrCodeProtocol} + return nil, http2streamError(fh.StreamID, http2ErrCodeProtocol) } hf.headerFragBuf = p[:len(p)-int(padLength)] return hf, nil @@ -1878,6 +1920,9 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr hdec.SetEmitEnabled(true) hdec.SetMaxStringLength(fr.maxHeaderStringLen()) hdec.SetEmitFunc(func(hf hpack.HeaderField) { + if http2VerboseLogs && http2logFrameReads { + log.Printf("http2: decoded hpack field %+v", hf) + } if !httplex.ValidHeaderFieldValue(hf.Value) { invalid = http2headerFieldValueError(hf.Value) } @@ -1936,11 +1981,17 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (*http2MetaHeadersFr } if invalid != nil { fr.errDetail = invalid - return nil, http2StreamError{mh.StreamID, http2ErrCodeProtocol} + if http2VerboseLogs { + log.Printf("http2: invalid header: %v", invalid) + } + return nil, http2StreamError{mh.StreamID, http2ErrCodeProtocol, invalid} } if err := mh.checkPseudos(); err != nil { fr.errDetail = err - return nil, http2StreamError{mh.StreamID, http2ErrCodeProtocol} + if http2VerboseLogs { + log.Printf("http2: invalid pseudo headers: %v", err) + } + return nil, http2StreamError{mh.StreamID, http2ErrCodeProtocol, err} } return mh, nil } @@ -3571,7 +3622,7 @@ func (sc *http2serverConn) wroteFrame(res http2frameWriteResult) { case http2stateOpen: st.state = http2stateHalfClosedLocal - errCancel := http2StreamError{st.id, http2ErrCodeCancel} + errCancel := http2streamError(st.id, http2ErrCodeCancel) sc.resetStream(errCancel) case http2stateHalfClosedRemote: sc.closeStream(st, http2errHandlerComplete) @@ -3764,7 +3815,7 @@ func (sc *http2serverConn) processWindowUpdate(f *http2WindowUpdateFrame) error return nil } if !st.flow.add(int32(f.Increment)) { - return http2StreamError{f.StreamID, http2ErrCodeFlowControl} + return http2streamError(f.StreamID, http2ErrCodeFlowControl) } default: if !sc.flow.add(int32(f.Increment)) { @@ -3786,7 +3837,7 @@ func (sc *http2serverConn) processResetStream(f *http2RSTStreamFrame) error { if st != nil { st.gotReset = true st.cancelCtx() - sc.closeStream(st, http2StreamError{f.StreamID, f.ErrCode}) + sc.closeStream(st, http2streamError(f.StreamID, f.ErrCode)) } return nil } @@ -3803,6 +3854,9 @@ func (sc *http2serverConn) closeStream(st *http2stream, err error) { } delete(sc.streams, st.id) if p := st.body; p != nil { + + sc.sendWindowUpdate(nil, p.Len()) + p.CloseWithError(err) } st.cw.Close() @@ -3879,36 +3933,51 @@ func (sc *http2serverConn) processSettingInitialWindowSize(val uint32) error { func (sc *http2serverConn) processData(f *http2DataFrame) error { sc.serveG.check() + data := f.Data() id := f.Header().StreamID st, ok := sc.streams[id] if !ok || st.state != http2stateOpen || st.gotTrailerHeader { - return http2StreamError{id, http2ErrCodeStreamClosed} + if sc.inflow.available() < int32(f.Length) { + return http2streamError(id, http2ErrCodeFlowControl) + } + + sc.inflow.take(int32(f.Length)) + sc.sendWindowUpdate(nil, int(f.Length)) + + return http2streamError(id, http2ErrCodeStreamClosed) } if st.body == nil { panic("internal error: should have a body in this state") } - data := f.Data() if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes { st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes)) - return http2StreamError{id, http2ErrCodeStreamClosed} + return http2streamError(id, http2ErrCodeStreamClosed) } - if len(data) > 0 { + if f.Length > 0 { - if int(st.inflow.available()) < len(data) { - return http2StreamError{id, http2ErrCodeFlowControl} + if st.inflow.available() < int32(f.Length) { + return http2streamError(id, http2ErrCodeFlowControl) } - st.inflow.take(int32(len(data))) - wrote, err := st.body.Write(data) - if err != nil { - return http2StreamError{id, http2ErrCodeStreamClosed} + st.inflow.take(int32(f.Length)) + + if len(data) > 0 { + wrote, err := st.body.Write(data) + if err != nil { + return http2streamError(id, http2ErrCodeStreamClosed) + } + if wrote != len(data) { + panic("internal error: bad Writer") + } + st.bodyBytes += int64(len(data)) } - if wrote != len(data) { - panic("internal error: bad Writer") + + if pad := int32(f.Length) - int32(len(data)); pad > 0 { + sc.sendWindowUpdate32(nil, pad) + sc.sendWindowUpdate32(st, pad) } - st.bodyBytes += int64(len(data)) } if f.StreamEnded() { st.endStream() @@ -3995,10 +4064,10 @@ func (sc *http2serverConn) processHeaders(f *http2MetaHeadersFrame) error { if sc.unackedSettings == 0 { - return http2StreamError{st.id, http2ErrCodeProtocol} + return http2streamError(st.id, http2ErrCodeProtocol) } - return http2StreamError{st.id, http2ErrCodeRefusedStream} + return http2streamError(st.id, http2ErrCodeRefusedStream) } rw, req, err := sc.newWriterAndRequest(st, f) @@ -4032,18 +4101,18 @@ func (st *http2stream) processTrailerHeaders(f *http2MetaHeadersFrame) error { } st.gotTrailerHeader = true if !f.StreamEnded() { - return http2StreamError{st.id, http2ErrCodeProtocol} + return http2streamError(st.id, http2ErrCodeProtocol) } if len(f.PseudoFields()) > 0 { - return http2StreamError{st.id, http2ErrCodeProtocol} + return http2streamError(st.id, http2ErrCodeProtocol) } if st.trailer != nil { for _, hf := range f.RegularFields() { key := sc.canonicalHeader(hf.Name) if !http2ValidTrailerHeader(key) { - return http2StreamError{st.id, http2ErrCodeProtocol} + return http2streamError(st.id, http2ErrCodeProtocol) } st.trailer[key] = append(st.trailer[key], hf.Value) } @@ -4097,18 +4166,18 @@ func (sc *http2serverConn) newWriterAndRequest(st *http2stream, f *http2MetaHead isConnect := method == "CONNECT" if isConnect { if path != "" || scheme != "" || authority == "" { - return nil, nil, http2StreamError{f.StreamID, http2ErrCodeProtocol} + return nil, nil, http2streamError(f.StreamID, http2ErrCodeProtocol) } } else if method == "" || path == "" || (scheme != "https" && scheme != "http") { - return nil, nil, http2StreamError{f.StreamID, http2ErrCodeProtocol} + return nil, nil, http2streamError(f.StreamID, http2ErrCodeProtocol) } bodyOpen := !f.StreamEnded() if method == "HEAD" && bodyOpen { - return nil, nil, http2StreamError{f.StreamID, http2ErrCodeProtocol} + return nil, nil, http2streamError(f.StreamID, http2ErrCodeProtocol) } var tlsState *tls.ConnectionState // nil if not scheme https @@ -4165,7 +4234,7 @@ func (sc *http2serverConn) newWriterAndRequest(st *http2stream, f *http2MetaHead var err error url_, err = url.ParseRequestURI(path) if err != nil { - return nil, nil, http2StreamError{f.StreamID, http2ErrCodeProtocol} + return nil, nil, http2streamError(f.StreamID, http2ErrCodeProtocol) } requestURI = path } @@ -4919,35 +4988,37 @@ func (t *http2Transport) initConnPool() { // ClientConn is the state of a single HTTP/2 client connection to an // HTTP/2 server. type http2ClientConn struct { - t *http2Transport - tconn net.Conn // usually *tls.Conn, except specialized impls - tlsState *tls.ConnectionState // nil only for specialized impls + t *http2Transport + tconn net.Conn // usually *tls.Conn, except specialized impls + tlsState *tls.ConnectionState // nil only for specialized impls + singleUse bool // whether being used for a single http.Request // readLoop goroutine fields: readerDone chan struct{} // closed on error readerErr error // set before readerDone is closed - mu sync.Mutex // guards following - cond *sync.Cond // hold mu; broadcast on flow/closed changes - flow http2flow // our conn-level flow control quota (cs.flow is per stream) - inflow http2flow // peer's conn-level flow control - closed bool - goAway *http2GoAwayFrame // if non-nil, the GoAwayFrame we received - goAwayDebug string // goAway frame's debug data, retained as a string - streams map[uint32]*http2clientStream // client-initiated - nextStreamID uint32 - bw *bufio.Writer - br *bufio.Reader - fr *http2Framer - lastActive time.Time - - // Settings from peer: + mu sync.Mutex // guards following + cond *sync.Cond // hold mu; broadcast on flow/closed changes + flow http2flow // our conn-level flow control quota (cs.flow is per stream) + inflow http2flow // peer's conn-level flow control + closed bool + wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back + goAway *http2GoAwayFrame // if non-nil, the GoAwayFrame we received + goAwayDebug string // goAway frame's debug data, retained as a string + streams map[uint32]*http2clientStream // client-initiated + nextStreamID uint32 + bw *bufio.Writer + br *bufio.Reader + fr *http2Framer + lastActive time.Time + // Settings from peer: (also guarded by mu) maxFrameSize uint32 maxConcurrentStreams uint32 initialWindowSize uint32 - hbuf bytes.Buffer // HPACK encoder writes into this - henc *hpack.Encoder - freeBuf [][]byte + + hbuf bytes.Buffer // HPACK encoder writes into this + henc *hpack.Encoder + freeBuf [][]byte wmu sync.Mutex // held while writing; acquire AFTER mu if holding both werr error // first write error that has occurred @@ -5117,7 +5188,7 @@ func http2shouldRetryRequest(req *Request, err error) bool { return err == http2errClientConnUnusable } -func (t *http2Transport) dialClientConn(addr string) (*http2ClientConn, error) { +func (t *http2Transport) dialClientConn(addr string, singleUse bool) (*http2ClientConn, error) { host, _, err := net.SplitHostPort(addr) if err != nil { return nil, err @@ -5126,7 +5197,7 @@ func (t *http2Transport) dialClientConn(addr string) (*http2ClientConn, error) { if err != nil { return nil, err } - return t.NewClientConn(tconn) + return t.newClientConn(tconn, singleUse) } func (t *http2Transport) newTLSConfig(host string) *tls.Config { @@ -5187,14 +5258,10 @@ func (t *http2Transport) expectContinueTimeout() time.Duration { } func (t *http2Transport) NewClientConn(c net.Conn) (*http2ClientConn, error) { - if http2VerboseLogs { - t.vlogf("http2: Transport creating client conn to %v", c.RemoteAddr()) - } - if _, err := c.Write(http2clientPreface); err != nil { - t.vlogf("client preface write error: %v", err) - return nil, err - } + return t.newClientConn(c, false) +} +func (t *http2Transport) newClientConn(c net.Conn, singleUse bool) (*http2ClientConn, error) { cc := &http2ClientConn{ t: t, tconn: c, @@ -5204,7 +5271,13 @@ func (t *http2Transport) NewClientConn(c net.Conn) (*http2ClientConn, error) { initialWindowSize: 65535, maxConcurrentStreams: 1000, streams: make(map[uint32]*http2clientStream), + singleUse: singleUse, + wantSettingsAck: true, } + if http2VerboseLogs { + t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr()) + } + cc.cond = sync.NewCond(&cc.mu) cc.flow.add(int32(http2initialWindowSize)) @@ -5228,6 +5301,8 @@ func (t *http2Transport) NewClientConn(c net.Conn) (*http2ClientConn, error) { if max := t.maxHeaderListSize(); max != 0 { initialSettings = append(initialSettings, http2Setting{ID: http2SettingMaxHeaderListSize, Val: max}) } + + cc.bw.Write(http2clientPreface) cc.fr.WriteSettings(initialSettings...) cc.fr.WriteWindowUpdate(0, http2transportDefaultConnFlow) cc.inflow.add(http2transportDefaultConnFlow + http2initialWindowSize) @@ -5236,32 +5311,6 @@ func (t *http2Transport) NewClientConn(c net.Conn) (*http2ClientConn, error) { return nil, cc.werr } - f, err := cc.fr.ReadFrame() - if err != nil { - return nil, err - } - sf, ok := f.(*http2SettingsFrame) - if !ok { - return nil, fmt.Errorf("expected settings frame, got: %T", f) - } - cc.fr.WriteSettingsAck() - cc.bw.Flush() - - sf.ForeachSetting(func(s http2Setting) error { - switch s.ID { - case http2SettingMaxFrameSize: - cc.maxFrameSize = s.Val - case http2SettingMaxConcurrentStreams: - cc.maxConcurrentStreams = s.Val - case http2SettingInitialWindowSize: - cc.initialWindowSize = s.Val - default: - - t.vlogf("Unhandled Setting: %v", s) - } - return nil - }) - go cc.readLoop() return cc, nil } @@ -5288,9 +5337,12 @@ func (cc *http2ClientConn) CanTakeNewRequest() bool { } func (cc *http2ClientConn) canTakeNewRequestLocked() bool { + if cc.singleUse && cc.nextStreamID > 1 { + return false + } return cc.goAway == nil && !cc.closed && int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) && - cc.nextStreamID < 2147483647 + cc.nextStreamID < math.MaxInt32 } func (cc *http2ClientConn) closeIfIdle() { @@ -5300,9 +5352,13 @@ func (cc *http2ClientConn) closeIfIdle() { return } cc.closed = true + nextID := cc.nextStreamID cc.mu.Unlock() + if http2VerboseLogs { + cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, nextID-2) + } cc.tconn.Close() } @@ -5404,12 +5460,15 @@ func http2bodyAndLength(req *Request) (body io.Reader, contentLen int64) { // We have a body but a zero content length. Test to see if // it's actually zero or just unset. var buf [1]byte - n, rerr := io.ReadFull(body, buf[:]) + n, rerr := body.Read(buf[:]) if rerr != nil && rerr != io.EOF { return http2errorReader{rerr}, -1 } if n == 1 { + if rerr == io.EOF { + return bytes.NewReader(buf[:]), 1 + } return io.MultiReader(bytes.NewReader(buf[:]), body), -1 } @@ -5494,9 +5553,10 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { bodyWritten := false ctx := http2reqContext(req) - reFunc := func(re http2resAndError) (*Response, error) { + handleReadLoopResponse := func(re http2resAndError) (*Response, error) { res := re.res if re.err != nil || res.StatusCode > 299 { + bodyWriter.cancel() cs.abortRequestBodyWrite(http2errStopReqBodyWrite) } @@ -5512,7 +5572,7 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { for { select { case re := <-readLoopResCh: - return reFunc(re) + return handleReadLoopResponse(re) case <-respHeaderTimer: cc.forgetStreamID(cs.ID) if !hasBody || bodyWritten { @@ -5525,7 +5585,7 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { case <-ctx.Done(): select { case re := <-readLoopResCh: - return reFunc(re) + return handleReadLoopResponse(re) default: } cc.forgetStreamID(cs.ID) @@ -5539,7 +5599,7 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { case <-req.Cancel: select { case re := <-readLoopResCh: - return reFunc(re) + return handleReadLoopResponse(re) default: } cc.forgetStreamID(cs.ID) @@ -5553,14 +5613,15 @@ func (cc *http2ClientConn) RoundTrip(req *Request) (*Response, error) { case <-cs.peerReset: select { case re := <-readLoopResCh: - return reFunc(re) + return handleReadLoopResponse(re) default: } return nil, cs.resetErr case err := <-bodyWriter.resc: + select { case re := <-readLoopResCh: - return reFunc(re) + return handleReadLoopResponse(re) default: } if err != nil { @@ -5670,26 +5731,29 @@ func (cs *http2clientStream) writeRequestBody(body io.Reader, bodyCloser io.Clos } } + if sentEnd { + + return nil + } + + var trls []byte + if hasTrailers { + cc.mu.Lock() + defer cc.mu.Unlock() + trls = cc.encodeTrailers(req) + } + cc.wmu.Lock() - if !sentEnd { - var trls []byte - if hasTrailers { - cc.mu.Lock() - trls = cc.encodeTrailers(req) - cc.mu.Unlock() - } + defer cc.wmu.Unlock() - if len(trls) > 0 { - err = cc.writeHeaders(cs.ID, true, trls) - } else { - err = cc.fr.WriteData(cs.ID, true, nil) - } + if len(trls) > 0 { + err = cc.writeHeaders(cs.ID, true, trls) + } else { + err = cc.fr.WriteData(cs.ID, true, nil) } if ferr := cc.bw.Flush(); ferr != nil && err == nil { err = ferr } - cc.wmu.Unlock() - return err } @@ -5918,6 +5982,14 @@ func (e http2GoAwayError) Error() string { e.LastStreamID, e.ErrCode, e.DebugData) } +func http2isEOFOrNetReadError(err error) bool { + if err == io.EOF { + return true + } + ne, ok := err.(*net.OpError) + return ok && ne.Op == "read" +} + func (rl *http2clientConnReadLoop) cleanup() { cc := rl.cc defer cc.tconn.Close() @@ -5926,16 +5998,14 @@ func (rl *http2clientConnReadLoop) cleanup() { err := cc.readerErr cc.mu.Lock() - if err == io.EOF { - if cc.goAway != nil { - err = http2GoAwayError{ - LastStreamID: cc.goAway.LastStreamID, - ErrCode: cc.goAway.ErrCode, - DebugData: cc.goAwayDebug, - } - } else { - err = io.ErrUnexpectedEOF + if cc.goAway != nil && http2isEOFOrNetReadError(err) { + err = http2GoAwayError{ + LastStreamID: cc.goAway.LastStreamID, + ErrCode: cc.goAway.ErrCode, + DebugData: cc.goAwayDebug, } + } else if err == io.EOF { + err = io.ErrUnexpectedEOF } for _, cs := range rl.activeRes { cs.bufPipe.CloseWithError(err) @@ -5954,16 +6024,21 @@ func (rl *http2clientConnReadLoop) cleanup() { func (rl *http2clientConnReadLoop) run() error { cc := rl.cc - rl.closeWhenIdle = cc.t.disableKeepAlives() + rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse gotReply := false + gotSettings := false for { f, err := cc.fr.ReadFrame() if err != nil { - cc.vlogf("Transport readFrame error: (%T) %v", err, err) + cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) } if se, ok := err.(http2StreamError); ok { if cs := cc.streamByID(se.StreamID, true); cs != nil { - rl.endStreamError(cs, cc.fr.errDetail) + cs.cc.writeStreamReset(cs.ID, se.Code, err) + if se.Cause == nil { + se.Cause = cc.fr.errDetail + } + rl.endStreamError(cs, se) } continue } else if err != nil { @@ -5972,6 +6047,13 @@ func (rl *http2clientConnReadLoop) run() error { if http2VerboseLogs { cc.vlogf("http2: Transport received %s", http2summarizeFrame(f)) } + if !gotSettings { + if _, ok := f.(*http2SettingsFrame); !ok { + cc.logf("protocol error: received %T before a SETTINGS frame", f) + return http2ConnectionError(http2ErrCodeProtocol) + } + gotSettings = true + } maybeIdle := false switch f := f.(type) { @@ -6000,6 +6082,9 @@ func (rl *http2clientConnReadLoop) run() error { cc.logf("Transport: unhandled response frame type %T", f) } if err != nil { + if http2VerboseLogs { + cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, http2summarizeFrame(f), err) + } return err } if rl.closeWhenIdle && gotReply && maybeIdle && len(rl.activeRes) == 0 { @@ -6238,10 +6323,27 @@ var http2errClosedResponseBody = errors.New("http2: response body closed") func (b http2transportResponseBody) Close() error { cs := b.cs - if cs.bufPipe.Err() != io.EOF { + cc := cs.cc - cs.cc.writeStreamReset(cs.ID, http2ErrCodeCancel, nil) + serverSentStreamEnd := cs.bufPipe.Err() == io.EOF + unread := cs.bufPipe.Len() + + if unread > 0 || !serverSentStreamEnd { + cc.mu.Lock() + cc.wmu.Lock() + if !serverSentStreamEnd { + cc.fr.WriteRSTStream(cs.ID, http2ErrCodeCancel) + } + + if unread > 0 { + cc.inflow.add(int32(unread)) + cc.fr.WriteWindowUpdate(0, uint32(unread)) + } + cc.bw.Flush() + cc.wmu.Unlock() + cc.mu.Unlock() } + cs.bufPipe.BreakWithError(http2errClosedResponseBody) return nil } @@ -6249,6 +6351,7 @@ func (b http2transportResponseBody) Close() error { func (rl *http2clientConnReadLoop) processData(f *http2DataFrame) error { cc := rl.cc cs := cc.streamByID(f.StreamID, f.StreamEnded()) + data := f.Data() if cs == nil { cc.mu.Lock() neverSent := cc.nextStreamID @@ -6259,27 +6362,49 @@ func (rl *http2clientConnReadLoop) processData(f *http2DataFrame) error { return http2ConnectionError(http2ErrCodeProtocol) } + if f.Length > 0 { + cc.mu.Lock() + cc.inflow.add(int32(f.Length)) + cc.mu.Unlock() + + cc.wmu.Lock() + cc.fr.WriteWindowUpdate(0, uint32(f.Length)) + cc.bw.Flush() + cc.wmu.Unlock() + } return nil } - if data := f.Data(); len(data) > 0 { - if cs.bufPipe.b == nil { + if f.Length > 0 { + if len(data) > 0 && cs.bufPipe.b == nil { cc.logf("http2: Transport received DATA frame for closed stream; closing connection") return http2ConnectionError(http2ErrCodeProtocol) } cc.mu.Lock() - if cs.inflow.available() >= int32(len(data)) { - cs.inflow.take(int32(len(data))) + if cs.inflow.available() >= int32(f.Length) { + cs.inflow.take(int32(f.Length)) } else { cc.mu.Unlock() return http2ConnectionError(http2ErrCodeFlowControl) } + + if pad := int32(f.Length) - int32(len(data)); pad > 0 { + cs.inflow.add(pad) + cc.inflow.add(pad) + cc.wmu.Lock() + cc.fr.WriteWindowUpdate(0, uint32(pad)) + cc.fr.WriteWindowUpdate(cs.ID, uint32(pad)) + cc.bw.Flush() + cc.wmu.Unlock() + } cc.mu.Unlock() - if _, err := cs.bufPipe.Write(data); err != nil { - rl.endStreamError(cs, err) - return err + if len(data) > 0 { + if _, err := cs.bufPipe.Write(data); err != nil { + rl.endStreamError(cs, err) + return err + } } } @@ -6304,9 +6429,14 @@ func (rl *http2clientConnReadLoop) endStreamError(cs *http2clientStream, err err } cs.bufPipe.closeWithErrorAndCode(err, code) delete(rl.activeRes, cs.ID) - if cs.req.Close || cs.req.Header.Get("Connection") == "close" { + if http2isConnectionCloseRequest(cs.req) { rl.closeWhenIdle = true } + + select { + case cs.resc <- http2resAndError{err: err}: + default: + } } func (cs *http2clientStream) copyTrailers() { @@ -6334,7 +6464,16 @@ func (rl *http2clientConnReadLoop) processSettings(f *http2SettingsFrame) error cc := rl.cc cc.mu.Lock() defer cc.mu.Unlock() - return f.ForeachSetting(func(s http2Setting) error { + + if f.IsAck() { + if cc.wantSettingsAck { + cc.wantSettingsAck = false + return nil + } + return http2ConnectionError(http2ErrCodeProtocol) + } + + err := f.ForeachSetting(func(s http2Setting) error { switch s.ID { case http2SettingMaxFrameSize: cc.maxFrameSize = s.Val @@ -6342,6 +6481,16 @@ func (rl *http2clientConnReadLoop) processSettings(f *http2SettingsFrame) error cc.maxConcurrentStreams = s.Val case http2SettingInitialWindowSize: + if s.Val > math.MaxInt32 { + return http2ConnectionError(http2ErrCodeFlowControl) + } + + delta := int32(s.Val) - int32(cc.initialWindowSize) + for _, cs := range cc.streams { + cs.flow.add(delta) + } + cc.cond.Broadcast() + cc.initialWindowSize = s.Val default: @@ -6349,6 +6498,16 @@ func (rl *http2clientConnReadLoop) processSettings(f *http2SettingsFrame) error } return nil }) + if err != nil { + return err + } + + cc.wmu.Lock() + defer cc.wmu.Unlock() + + cc.fr.WriteSettingsAck() + cc.bw.Flush() + return cc.werr } func (rl *http2clientConnReadLoop) processWindowUpdate(f *http2WindowUpdateFrame) error { @@ -6382,7 +6541,7 @@ func (rl *http2clientConnReadLoop) processResetStream(f *http2RSTStreamFrame) er case <-cs.peerReset: default: - err := http2StreamError{cs.ID, f.ErrCode} + err := http2streamError(cs.ID, f.ErrCode) cs.resetErr = err close(cs.peerReset) cs.bufPipe.CloseWithError(err) @@ -6560,6 +6719,12 @@ func (s http2bodyWriterState) scheduleBodyWrite() { } } +// isConnectionCloseRequest reports whether req should use its own +// connection for a single request and then close the connection. +func http2isConnectionCloseRequest(req *Request) bool { + return req.Close || httplex.HeaderValuesContainsToken(req.Header["Connection"], "close") +} + // writeFramer is implemented by any type that is used to write frames. type http2writeFramer interface { writeFrame(http2writeContext) error diff --git a/libgo/go/net/http/serve_test.go b/libgo/go/net/http/serve_test.go index 139ce3eafc7..13e5f283e4c 100644 --- a/libgo/go/net/http/serve_test.go +++ b/libgo/go/net/http/serve_test.go @@ -4716,3 +4716,14 @@ func BenchmarkCloseNotifier(b *testing.B) { } b.StopTimer() } + +// Verify this doesn't race (Issue 16505) +func TestConcurrentServerServe(t *testing.T) { + for i := 0; i < 100; i++ { + ln1 := &oneConnListener{conn: nil} + ln2 := &oneConnListener{conn: nil} + srv := Server{} + go func() { srv.Serve(ln1) }() + go func() { srv.Serve(ln2) }() + } +} diff --git a/libgo/go/net/http/server.go b/libgo/go/net/http/server.go index 7b2b4b2f423..89574a8b36e 100644 --- a/libgo/go/net/http/server.go +++ b/libgo/go/net/http/server.go @@ -2129,8 +2129,8 @@ type Server struct { ErrorLog *log.Logger disableKeepAlives int32 // accessed atomically. - nextProtoOnce sync.Once // guards initialization of TLSNextProto in Serve - nextProtoErr error + nextProtoOnce sync.Once // guards setupHTTP2_* init + nextProtoErr error // result of http2.ConfigureServer if used } // A ConnState represents the state of a client connection to a server. @@ -2260,10 +2260,8 @@ func (srv *Server) Serve(l net.Listener) error { } var tempDelay time.Duration // how long to sleep on accept failure - if srv.shouldConfigureHTTP2ForServe() { - if err := srv.setupHTTP2(); err != nil { - return err - } + if err := srv.setupHTTP2_Serve(); err != nil { + return err } // TODO: allow changing base context? can't imagine concrete @@ -2408,7 +2406,7 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { // Setup HTTP/2 before srv.Serve, to initialize srv.TLSConfig // before we clone it and create the TLS Listener. - if err := srv.setupHTTP2(); err != nil { + if err := srv.setupHTTP2_ListenAndServeTLS(); err != nil { return err } @@ -2436,14 +2434,36 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error { return srv.Serve(tlsListener) } -func (srv *Server) setupHTTP2() error { +// setupHTTP2_ListenAndServeTLS conditionally configures HTTP/2 on +// srv and returns whether there was an error setting it up. If it is +// not configured for policy reasons, nil is returned. +func (srv *Server) setupHTTP2_ListenAndServeTLS() error { srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults) return srv.nextProtoErr } +// setupHTTP2_Serve is called from (*Server).Serve and conditionally +// configures HTTP/2 on srv using a more conservative policy than +// setupHTTP2_ListenAndServeTLS because Serve may be called +// concurrently. +// +// The tests named TestTransportAutomaticHTTP2* and +// TestConcurrentServerServe in server_test.go demonstrate some +// of the supported use cases and motivations. +func (srv *Server) setupHTTP2_Serve() error { + srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults_Serve) + return srv.nextProtoErr +} + +func (srv *Server) onceSetNextProtoDefaults_Serve() { + if srv.shouldConfigureHTTP2ForServe() { + srv.onceSetNextProtoDefaults() + } +} + // onceSetNextProtoDefaults configures HTTP/2, if the user hasn't // configured otherwise. (by setting srv.TLSNextProto non-nil) -// It must only be called via srv.nextProtoOnce (use srv.setupHTTP2). +// It must only be called via srv.nextProtoOnce (use srv.setupHTTP2_*). func (srv *Server) onceSetNextProtoDefaults() { if strings.Contains(os.Getenv("GODEBUG"), "http2server=0") { return diff --git a/libgo/go/net/http/transport.go b/libgo/go/net/http/transport.go index 9164d0d827c..1f0763471b8 100644 --- a/libgo/go/net/http/transport.go +++ b/libgo/go/net/http/transport.go @@ -383,6 +383,11 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { return resp, nil } if !pconn.shouldRetryRequest(req, err) { + // Issue 16465: return underlying net.Conn.Read error from peek, + // as we've historically done. + if e, ok := err.(transportReadFromServerError); ok { + err = e.err + } return nil, err } testHookRoundTripRetried() @@ -393,6 +398,15 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { // HTTP request on a new connection. The non-nil input error is the // error from roundTrip. func (pc *persistConn) shouldRetryRequest(req *Request, err error) bool { + if err == http2ErrNoCachedConn { + // Issue 16582: if the user started a bunch of + // requests at once, they can all pick the same conn + // and violate the server's max concurrent streams. + // Instead, match the HTTP/1 behavior for now and dial + // again to get a new TCP connection, rather than failing + // this request. + return true + } if err == errMissingHost { // User error. return false @@ -415,11 +429,19 @@ func (pc *persistConn) shouldRetryRequest(req *Request, err error) bool { // first, per golang.org/issue/15723 return false } - if _, ok := err.(nothingWrittenError); ok { + switch err.(type) { + case nothingWrittenError: // We never wrote anything, so it's safe to retry. return true + case transportReadFromServerError: + // We got some non-EOF net.Conn.Read failure reading + // the 1st response byte from the server. + return true } - if err == errServerClosedIdle || err == errServerClosedConn { + if err == errServerClosedIdle { + // The server replied with io.EOF while we were trying to + // read the response. Probably an unfortunately keep-alive + // timeout, just as the client was writing a request. return true } return false // conservatively @@ -476,8 +498,9 @@ func (t *Transport) CloseIdleConnections() { // CancelRequest cancels an in-flight request by closing its connection. // CancelRequest should only be called after RoundTrip has returned. // -// Deprecated: Use Request.Cancel instead. CancelRequest cannot cancel -// HTTP/2 requests. +// Deprecated: Use Request.WithContext to create a request with a +// cancelable context instead. CancelRequest cannot cancel HTTP/2 +// requests. func (t *Transport) CancelRequest(req *Request) { t.reqMu.Lock() cancel := t.reqCanceler[req] @@ -566,10 +589,26 @@ var ( errCloseIdleConns = errors.New("http: CloseIdleConnections called") errReadLoopExiting = errors.New("http: persistConn.readLoop exiting") errServerClosedIdle = errors.New("http: server closed idle connection") - errServerClosedConn = errors.New("http: server closed connection") errIdleConnTimeout = errors.New("http: idle connection timeout") + errNotCachingH2Conn = errors.New("http: not caching alternate protocol's connections") ) +// transportReadFromServerError is used by Transport.readLoop when the +// 1 byte peek read fails and we're actually anticipating a response. +// Usually this is just due to the inherent keep-alive shut down race, +// where the server closed the connection at the same time the client +// wrote. The underlying err field is usually io.EOF or some +// ECONNRESET sort of thing which varies by platform. But it might be +// the user's custom net.Conn.Read error too, so we carry it along for +// them to return from Transport.RoundTrip. +type transportReadFromServerError struct { + err error +} + +func (e transportReadFromServerError) Error() string { + return fmt.Sprintf("net/http: Transport failed to read from server: %v", e.err) +} + func (t *Transport) putOrCloseIdleConn(pconn *persistConn) { if err := t.tryPutIdleConn(pconn); err != nil { pconn.close(err) @@ -595,6 +634,9 @@ func (t *Transport) tryPutIdleConn(pconn *persistConn) error { if pconn.isBroken() { return errConnBroken } + if pconn.alt != nil { + return errNotCachingH2Conn + } pconn.markReused() key := pconn.cacheKey @@ -1293,7 +1335,10 @@ func (pc *persistConn) mapRoundTripErrorFromReadLoop(startBytesWritten int64, er if pc.isCanceled() { return errRequestCanceled } - if err == errServerClosedIdle || err == errServerClosedConn { + if err == errServerClosedIdle { + return err + } + if _, ok := err.(transportReadFromServerError); ok { return err } if pc.isBroken() { @@ -1314,7 +1359,11 @@ func (pc *persistConn) mapRoundTripErrorAfterClosed(startBytesWritten int64) err return errRequestCanceled } err := pc.closed - if err == errServerClosedIdle || err == errServerClosedConn { + if err == errServerClosedIdle { + // Don't decorate + return err + } + if _, ok := err.(transportReadFromServerError); ok { // Don't decorate return err } @@ -1383,7 +1432,7 @@ func (pc *persistConn) readLoop() { if err == nil { resp, err = pc.readResponse(rc, trace) } else { - err = errServerClosedConn + err = transportReadFromServerError{err} closeErr = err } @@ -1784,6 +1833,7 @@ func (pc *persistConn) roundTrip(req *transportRequest) (resp *Response, err err var re responseAndError var respHeaderTimer <-chan time.Time cancelChan := req.Request.Cancel + ctxDoneChan := req.Context().Done() WaitResponse: for { testHookWaitResLoop() @@ -1815,9 +1865,11 @@ WaitResponse: case <-cancelChan: pc.t.CancelRequest(req.Request) cancelChan = nil - case <-req.Context().Done(): + ctxDoneChan = nil + case <-ctxDoneChan: pc.t.CancelRequest(req.Request) cancelChan = nil + ctxDoneChan = nil } } diff --git a/libgo/go/net/http/transport_internal_test.go b/libgo/go/net/http/transport_internal_test.go index a157d906300..a05ca6ed0d8 100644 --- a/libgo/go/net/http/transport_internal_test.go +++ b/libgo/go/net/http/transport_internal_test.go @@ -46,17 +46,22 @@ func TestTransportPersistConnReadLoopEOF(t *testing.T) { conn.Close() // simulate the server hanging up on the client _, err = pc.roundTrip(treq) - if err != errServerClosedConn && err != errServerClosedIdle { + if !isTransportReadFromServerError(err) && err != errServerClosedIdle { t.Fatalf("roundTrip = %#v, %v; want errServerClosedConn or errServerClosedIdle", err, err) } <-pc.closech err = pc.closed - if err != errServerClosedConn && err != errServerClosedIdle { + if !isTransportReadFromServerError(err) && err != errServerClosedIdle { t.Fatalf("pc.closed = %#v, %v; want errServerClosedConn or errServerClosedIdle", err, err) } } +func isTransportReadFromServerError(err error) bool { + _, ok := err.(transportReadFromServerError) + return ok +} + func newLocalListener(t *testing.T) net.Listener { ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { diff --git a/libgo/go/net/http/transport_test.go b/libgo/go/net/http/transport_test.go index 72b98f16d7e..298682d04de 100644 --- a/libgo/go/net/http/transport_test.go +++ b/libgo/go/net/http/transport_test.go @@ -3511,6 +3511,100 @@ func TestTransportIdleConnTimeout(t *testing.T) { } } +// Issue 16208: Go 1.7 crashed after Transport.IdleConnTimeout if an +// HTTP/2 connection was established but but its caller no longer +// wanted it. (Assuming the connection cache was enabled, which it is +// by default) +// +// This test reproduced the crash by setting the IdleConnTimeout low +// (to make the test reasonable) and then making a request which is +// canceled by the DialTLS hook, which then also waits to return the +// real connection until after the RoundTrip saw the error. Then we +// know the successful tls.Dial from DialTLS will need to go into the +// idle pool. Then we give it a of time to explode. +func TestIdleConnH2Crash(t *testing.T) { + cst := newClientServerTest(t, h2Mode, HandlerFunc(func(w ResponseWriter, r *Request) { + // nothing + })) + defer cst.close() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + gotErr := make(chan bool, 1) + + cst.tr.IdleConnTimeout = 5 * time.Millisecond + cst.tr.DialTLS = func(network, addr string) (net.Conn, error) { + cancel() + <-gotErr + c, err := tls.Dial(network, addr, &tls.Config{ + InsecureSkipVerify: true, + NextProtos: []string{"h2"}, + }) + if err != nil { + t.Error(err) + return nil, err + } + if cs := c.ConnectionState(); cs.NegotiatedProtocol != "h2" { + t.Errorf("protocol = %q; want %q", cs.NegotiatedProtocol, "h2") + c.Close() + return nil, errors.New("bogus") + } + return c, nil + } + + req, _ := NewRequest("GET", cst.ts.URL, nil) + req = req.WithContext(ctx) + res, err := cst.c.Do(req) + if err == nil { + res.Body.Close() + t.Fatal("unexpected success") + } + gotErr <- true + + // Wait for the explosion. + time.Sleep(cst.tr.IdleConnTimeout * 10) +} + +type funcConn struct { + net.Conn + read func([]byte) (int, error) + write func([]byte) (int, error) +} + +func (c funcConn) Read(p []byte) (int, error) { return c.read(p) } +func (c funcConn) Write(p []byte) (int, error) { return c.write(p) } +func (c funcConn) Close() error { return nil } + +// Issue 16465: Transport.RoundTrip should return the raw net.Conn.Read error from Peek +// back to the caller. +func TestTransportReturnsPeekError(t *testing.T) { + errValue := errors.New("specific error value") + + wrote := make(chan struct{}) + var wroteOnce sync.Once + + tr := &Transport{ + Dial: func(network, addr string) (net.Conn, error) { + c := funcConn{ + read: func([]byte) (int, error) { + <-wrote + return 0, errValue + }, + write: func(p []byte) (int, error) { + wroteOnce.Do(func() { close(wrote) }) + return len(p), nil + }, + } + return c, nil + }, + } + _, err := tr.RoundTrip(httptest.NewRequest("GET", "http://fake.tld/", nil)) + if err != errValue { + t.Errorf("error = %#v; want %v", err, errValue) + } +} + var errFakeRoundTrip = errors.New("fake roundtrip") type funcRoundTripper func() diff --git a/libgo/go/os/wait_waitid.go b/libgo/go/os/wait_waitid.go index 5dbd7f97662..74b7494c0de 100644 --- a/libgo/go/os/wait_waitid.go +++ b/libgo/go/os/wait_waitid.go @@ -28,6 +28,12 @@ func (p *Process) blockUntilWaitable() (bool, error) { _, _, e := syscall.Syscall6(syscall.SYS_WAITID, _P_PID, uintptr(p.Pid), uintptr(unsafe.Pointer(psig)), syscall.WEXITED|syscall.WNOWAIT, 0, 0) runtime.KeepAlive(psig) if e != 0 { + // waitid has been available since Linux 2.6.9, but + // reportedly is not available in Ubuntu on Windows. + // See issue 16610. + if e == syscall.ENOSYS { + return false, nil + } return false, NewSyscallError("waitid", e) } return true, nil diff --git a/libgo/go/path/filepath/export_windows_test.go b/libgo/go/path/filepath/export_windows_test.go index 8ca007f70aa..a7e2e6422bc 100644 --- a/libgo/go/path/filepath/export_windows_test.go +++ b/libgo/go/path/filepath/export_windows_test.go @@ -4,4 +4,7 @@ package filepath -var ToNorm = toNorm +var ( + ToNorm = toNorm + NormBase = normBase +) diff --git a/libgo/go/path/filepath/path_test.go b/libgo/go/path/filepath/path_test.go index 4d5e3bdcb6d..9c3f287ecbd 100644 --- a/libgo/go/path/filepath/path_test.go +++ b/libgo/go/path/filepath/path_test.go @@ -843,7 +843,7 @@ func TestEvalSymlinks(t *testing.T) { if p, err := filepath.EvalSymlinks(path); err != nil { t.Errorf("EvalSymlinks(%q) error: %v", d.path, err) } else if filepath.Clean(p) != filepath.Clean(dest) { - t.Errorf("Clean(%q)=%q, want %q", path, p, dest) + t.Errorf("EvalSymlinks(%q)=%q, want %q", path, p, dest) } // test EvalSymlinks(".") @@ -875,6 +875,34 @@ func TestEvalSymlinks(t *testing.T) { t.Errorf(`EvalSymlinks(".") in %q directory returns %q, want "." or %q`, d.path, p, want) }() + // test EvalSymlinks(".."+path) + func() { + defer func() { + err := os.Chdir(wd) + if err != nil { + t.Fatal(err) + } + }() + + err := os.Chdir(simpleJoin(tmpDir, "test")) + if err != nil { + t.Error(err) + return + } + + path := simpleJoin("..", d.path) + dest := simpleJoin("..", d.dest) + if filepath.IsAbs(d.dest) || os.IsPathSeparator(d.dest[0]) { + dest = d.dest + } + + if p, err := filepath.EvalSymlinks(path); err != nil { + t.Errorf("EvalSymlinks(%q) error: %v", d.path, err) + } else if filepath.Clean(p) != filepath.Clean(dest) { + t.Errorf("EvalSymlinks(%q)=%q, want %q", path, p, dest) + } + }() + // test EvalSymlinks where parameter is relative path func() { defer func() { @@ -892,7 +920,7 @@ func TestEvalSymlinks(t *testing.T) { if p, err := filepath.EvalSymlinks(d.path); err != nil { t.Errorf("EvalSymlinks(%q) error: %v", d.path, err) } else if filepath.Clean(p) != filepath.Clean(d.dest) { - t.Errorf("Clean(%q)=%q, want %q", d.path, p, d.dest) + t.Errorf("EvalSymlinks(%q)=%q, want %q", d.path, p, d.dest) } }() } diff --git a/libgo/go/path/filepath/symlink_windows.go b/libgo/go/path/filepath/symlink_windows.go index 243352819e0..bb05aabc924 100644 --- a/libgo/go/path/filepath/symlink_windows.go +++ b/libgo/go/path/filepath/symlink_windows.go @@ -22,7 +22,7 @@ func normVolumeName(path string) string { return strings.ToUpper(volume) } -// normBase retruns the last element of path. +// normBase returns the last element of path with correct case. func normBase(path string) (string, error) { p, err := syscall.UTF16PtrFromString(path) if err != nil { @@ -40,7 +40,24 @@ func normBase(path string) (string, error) { return syscall.UTF16ToString(data.FileName[:]), nil } -func toNorm(path string, base func(string) (string, error)) (string, error) { +// baseIsDotDot returns whether the last element of path is "..". +// The given path should be 'Clean'-ed in advance. +func baseIsDotDot(path string) bool { + i := strings.LastIndexByte(path, Separator) + return path[i+1:] == ".." +} + +// toNorm returns the normalized path that is guranteed to be unique. +// It should accept the following formats: +// * UNC paths (e.g \\server\share\foo\bar) +// * absolute paths (e.g C:\foo\bar) +// * relative paths begin with drive letter (e.g C:foo\bar, C:..\foo\bar, C:.., C:.) +// * relative paths begin with '\' (e.g \foo\bar) +// * relative paths begin without '\' (e.g foo\bar, ..\foo\bar, .., .) +// The returned normalized path will be in the same form (of 5 listed above) as the input path. +// If two paths A and B are indicating the same file with the same format, toNorm(A) should be equal to toNorm(B). +// The normBase parameter should be equal to the normBase func, except for in tests. See docs on the normBase func. +func toNorm(path string, normBase func(string) (string, error)) (string, error) { if path == "" { return path, nil } @@ -58,7 +75,13 @@ func toNorm(path string, base func(string) (string, error)) (string, error) { var normPath string for { - name, err := base(volume + path) + if baseIsDotDot(path) { + normPath = path + `\` + normPath + + break + } + + name, err := normBase(volume + path) if err != nil { return "", err } diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go index 7045e448ea3..e601c2cbde2 100644 --- a/libgo/go/reflect/all_test.go +++ b/libgo/go/reflect/all_test.go @@ -5752,6 +5752,8 @@ func TestTypeStrings(t *testing.T) { {TypeOf(new(XM)), "*reflect_test.XM"}, {TypeOf(new(XM).String), "func() string"}, {TypeOf(new(XM)).Method(0).Type, "func(*reflect_test.XM) string"}, + {ChanOf(3, TypeOf(XM{})), "chan reflect_test.XM"}, + {MapOf(TypeOf(int(0)), TypeOf(XM{})), "map[int]reflect_test.XM"}, } for i, test := range stringTests { diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index fbbf56ced70..e0c5aacc55a 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -157,6 +157,8 @@ of the run-time system. */ package runtime +import "runtime/internal/sys" + // Gosched yields the processor, allowing other goroutines to run. It does not // suspend the current goroutine, so execution resumes automatically. func Gosched() @@ -282,23 +284,23 @@ func GOROOT() string { if s != "" { return s } - return defaultGoroot + return sys.DefaultGoroot } // Version returns the Go tree's version string. // It is either the commit hash and date at the time of the build or, // when possible, a release tag like "go1.3". func Version() string { - return theVersion + return sys.TheVersion } // GOOS is the running program's operating system target: // one of darwin, freebsd, linux, and so on. -const GOOS string = theGoos +const GOOS string = sys.GOOS // GOARCH is the running program's architecture target: // 386, amd64, arm, or s390x. -const GOARCH string = theGoarch +const GOARCH string = sys.GOARCH // GCCGOTOOLDIR is the Tool Dir for the gccgo build -const GCCGOTOOLDIR string = theGccgoToolDir +const GCCGOTOOLDIR string = sys.GccgoToolDir diff --git a/libgo/go/runtime/internal/atomic/atomic.c b/libgo/go/runtime/internal/atomic/atomic.c new file mode 100644 index 00000000000..3393fbef44e --- /dev/null +++ b/libgo/go/runtime/internal/atomic/atomic.c @@ -0,0 +1,237 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include <stdint.h> + +#include "runtime.h" + +uint32_t Load (uint32_t *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Load") + __attribute__ ((no_split_stack)); + +uint32_t +Load (uint32_t *ptr) +{ + return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); +} + +void *Loadp (void *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Loadp") + __attribute__ ((no_split_stack)); + +void * +Loadp (void *ptr) +{ + return __atomic_load_n ((void **) ptr, __ATOMIC_ACQUIRE); +} + +uint64_t Load64 (uint64_t *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Load64") + __attribute__ ((no_split_stack)); + +uint64_t +Load64 (uint64_t *ptr) +{ + return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); +} + +uintptr_t Loaduintptr (uintptr_t *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Loaduintptr") + __attribute__ ((no_split_stack)); + +uintptr_t +Loaduintptr (uintptr_t *ptr) +{ + return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); +} + +uintgo Loaduint (uintgo *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Loaduint") + __attribute__ ((no_split_stack)); + +uintgo +Loaduint (uintgo *ptr) +{ + return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); +} + +int64_t Loadint64 (int64_t *ptr) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Loadint64") + __attribute__ ((no_split_stack)); + +int64_t +Loadint64 (int64_t *ptr) +{ + return __atomic_load_n (ptr, __ATOMIC_ACQUIRE); +} + +uint32_t Xadd (uint32_t *ptr, int32_t delta) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xadd") + __attribute__ ((no_split_stack)); + +uint32_t +Xadd (uint32_t *ptr, int32_t delta) +{ + return __atomic_add_fetch (ptr, (uint32_t) delta, __ATOMIC_SEQ_CST); +} + +uint64_t Xadd64 (uint64_t *ptr, int64_t delta) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xadd64") + __attribute__ ((no_split_stack)); + +uint64_t +Xadd64 (uint64_t *ptr, int64_t delta) +{ + return __atomic_add_fetch (ptr, (uint64_t) delta, __ATOMIC_SEQ_CST); +} + +uintptr_t Xadduintptr (uintptr_t *ptr, uintptr_t delta) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xadduintptr") + __attribute__ ((no_split_stack)); + +uintptr_t +Xadduintptr (uintptr_t *ptr, uintptr_t delta) +{ + return __atomic_add_fetch (ptr, delta, __ATOMIC_SEQ_CST); +} + +int64_t Xaddint64 (int64_t *ptr, int64_t delta) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xaddint64") + __attribute__ ((no_split_stack)); + +int64_t +Xaddint64 (int64_t *ptr, int64_t delta) +{ + return __atomic_add_fetch (ptr, delta, __ATOMIC_SEQ_CST); +} + +uint32_t Xchg (uint32_t *ptr, uint32_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xchg") + __attribute__ ((no_split_stack)); + +uint32_t +Xchg (uint32_t *ptr, uint32_t new) +{ + return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST); +} + +uint64_t Xchg64 (uint64_t *ptr, uint64_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xchg64") + __attribute__ ((no_split_stack)); + +uint64_t +Xchg64 (uint64_t *ptr, uint64_t new) +{ + return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST); +} + +uintptr_t Xchguintptr (uintptr_t *ptr, uintptr_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Xchguintptr") + __attribute__ ((no_split_stack)); + +uintptr_t +Xchguintptr (uintptr_t *ptr, uintptr_t new) +{ + return __atomic_exchange_n (ptr, new, __ATOMIC_SEQ_CST); +} + +void And8 (uint8_t *ptr, uint8_t val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.And8") + __attribute__ ((no_split_stack)); + +void +And8 (uint8_t *ptr, uint8_t val) +{ + __atomic_and_fetch (ptr, val, __ATOMIC_SEQ_CST); +} + +void Or8 (uint8_t *ptr, uint8_t val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Or8") + __attribute__ ((no_split_stack)); + +void +Or8 (uint8_t *ptr, uint8_t val) +{ + __atomic_or_fetch (ptr, val, __ATOMIC_SEQ_CST); +} + +_Bool Cas (uint32_t *ptr, uint32_t old, uint32_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Cas") + __attribute__ ((no_split_stack)); + +_Bool +Cas (uint32_t *ptr, uint32_t old, uint32_t new) +{ + return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); +} + +_Bool Cas64 (uint64_t *ptr, uint64_t old, uint64_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Cas64") + __attribute__ ((no_split_stack)); + +_Bool +Cas64 (uint64_t *ptr, uint64_t old, uint64_t new) +{ + return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); +} + +_Bool Casp1 (void **ptr, void *old, void *new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Casp1") + __attribute__ ((no_split_stack)); + +_Bool +Casp1 (void **ptr, void *old, void *new) +{ + return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); +} + +_Bool Casuintptr (uintptr_t *ptr, uintptr_t old, uintptr_t new) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Casuintptr") + __attribute__ ((no_split_stack)); + +_Bool +Casuintptr (uintptr_t *ptr, uintptr_t old, uintptr_t new) +{ + return __atomic_compare_exchange_n (ptr, &old, new, false, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); +} + +void Store (uint32_t *ptr, uint32_t val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Store") + __attribute__ ((no_split_stack)); + +void +Store (uint32_t *ptr, uint32_t val) +{ + __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST); +} + +void Store64 (uint64_t *ptr, uint64_t val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Store64") + __attribute__ ((no_split_stack)); + +void +Store64 (uint64_t *ptr, uint64_t val) +{ + __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST); +} + +void Storeuintptr (uintptr_t *ptr, uintptr_t val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.Storeuintptr") + __attribute__ ((no_split_stack)); + +void +Storeuintptr (uintptr_t *ptr, uintptr_t val) +{ + __atomic_store_n (ptr, val, __ATOMIC_SEQ_CST); +} + +void StorepNoWB (void *ptr, void *val) + __asm__ (GOSYM_PREFIX "runtime_internal_atomic.StorepNoWB") + __attribute__ ((no_split_stack)); + +void +StorepNoWB (void *ptr, void *val) +{ + __atomic_store_n ((void**) ptr, val, __ATOMIC_SEQ_CST); +} diff --git a/libgo/go/runtime/internal/atomic/atomic_test.go b/libgo/go/runtime/internal/atomic/atomic_test.go new file mode 100644 index 00000000000..d5dc552b952 --- /dev/null +++ b/libgo/go/runtime/internal/atomic/atomic_test.go @@ -0,0 +1,67 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package atomic_test + +import ( + "runtime" + "runtime/internal/atomic" + "testing" + "unsafe" +) + +func runParallel(N, iter int, f func()) { + defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(int(N))) + done := make(chan bool) + for i := 0; i < N; i++ { + go func() { + for j := 0; j < iter; j++ { + f() + } + done <- true + }() + } + for i := 0; i < N; i++ { + <-done + } +} + +func TestXadduintptr(t *testing.T) { + const N = 20 + const iter = 100000 + inc := uintptr(100) + total := uintptr(0) + runParallel(N, iter, func() { + atomic.Xadduintptr(&total, inc) + }) + if want := uintptr(N * iter * inc); want != total { + t.Fatalf("xadduintpr error, want %d, got %d", want, total) + } + total = 0 + runParallel(N, iter, func() { + atomic.Xadduintptr(&total, inc) + atomic.Xadduintptr(&total, uintptr(-int64(inc))) + }) + if total != 0 { + t.Fatalf("xadduintpr total error, want %d, got %d", 0, total) + } +} + +// Tests that xadduintptr correctly updates 64-bit values. The place where +// we actually do so is mstats.go, functions mSysStat{Inc,Dec}. +func TestXadduintptrOnUint64(t *testing.T) { + /* if runtime.BigEndian != 0 { + // On big endian architectures, we never use xadduintptr to update + // 64-bit values and hence we skip the test. (Note that functions + // mSysStat{Inc,Dec} in mstats.go have explicit checks for + // big-endianness.) + return + }*/ + const inc = 100 + val := uint64(0) + atomic.Xadduintptr((*uintptr)(unsafe.Pointer(&val)), inc) + if inc != val { + t.Fatalf("xadduintptr should increase lower-order bits, want %d, got %d", inc, val) + } +} diff --git a/libgo/go/runtime/internal/atomic/gccgo.go b/libgo/go/runtime/internal/atomic/gccgo.go new file mode 100644 index 00000000000..696736465fd --- /dev/null +++ b/libgo/go/runtime/internal/atomic/gccgo.go @@ -0,0 +1,59 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package atomic + +// Stubs for atomic functions that in gccgo are implemented in C. + +import "unsafe" + +//go:noescape +func Load(ptr *uint32) uint32 + +//go:noescape +func Loadp(ptr unsafe.Pointer) unsafe.Pointer + +//go:noescape +func Load64(ptr *uint64) uint64 + +//go:noescape +func Xadd(ptr *uint32, delta int32) uint32 + +//go:noescape +func Xadd64(ptr *uint64, delta int64) uint64 + +//go:noescape +func Xadduintptr(ptr *uintptr, delta uintptr) uintptr + +//go:noescape +func Xchg(ptr *uint32, new uint32) uint32 + +//go:noescape +func Xchg64(ptr *uint64, new uint64) uint64 + +//go:noescape +func Xchguintptr(ptr *uintptr, new uintptr) uintptr + +//go:noescape +func And8(ptr *uint8, val uint8) + +//go:noescape +func Or8(ptr *uint8, val uint8) + +// NOTE: Do not add atomicxor8 (XOR is not idempotent). + +//go:noescape +func Cas64(ptr *uint64, old, new uint64) bool + +//go:noescape +func Store(ptr *uint32, val uint32) + +//go:noescape +func Store64(ptr *uint64, val uint64) + +// StorepNoWB performs *ptr = val atomically and without a write +// barrier. +// +// NO go:noescape annotation; see atomic_pointer.go. +func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) diff --git a/libgo/go/runtime/internal/atomic/stubs.go b/libgo/go/runtime/internal/atomic/stubs.go new file mode 100644 index 00000000000..497b98046d8 --- /dev/null +++ b/libgo/go/runtime/internal/atomic/stubs.go @@ -0,0 +1,33 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package atomic + +import "unsafe" + +//go:noescape +func Cas(ptr *uint32, old, new uint32) bool + +// NO go:noescape annotation; see atomic_pointer.go. +func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool + +//go:noescape +func Casuintptr(ptr *uintptr, old, new uintptr) bool + +//go:noescape +func Storeuintptr(ptr *uintptr, new uintptr) + +//go:noescape +func Loaduintptr(ptr *uintptr) uintptr + +//go:noescape +func Loaduint(ptr *uint) uint + +// TODO(matloob): Should these functions have the go:noescape annotation? + +//go:noescape +func Loadint64(ptr *int64) int64 + +//go:noescape +func Xaddint64(ptr *int64, delta int64) int64 diff --git a/libgo/go/runtime/internal/sys/intrinsics.go b/libgo/go/runtime/internal/sys/intrinsics.go new file mode 100644 index 00000000000..f33209a8878 --- /dev/null +++ b/libgo/go/runtime/internal/sys/intrinsics.go @@ -0,0 +1,77 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sys + +//extern __builtin_ctz +func builtinCtz32(uint32) int32 + +//extern __builtin_ctzll +func builtinCtz64(uint64) int32 + +//go:nosplit + +// Ctz64 counts trailing (low-order) zeroes, +// and if all are zero, then 64. +func Ctz64(x uint64) uint64 { + if x == 0 { + return 64 + } + return uint64(builtinCtz64(x)) +} + +//go:nosplit + +// Ctz32 counts trailing (low-order) zeroes, +// and if all are zero, then 32. +func Ctz32(x uint32) uint32 { + if x == 0 { + return 32 + } + return uint32(builtinCtz32(x)) +} + +//go:nosplit + +// Ctz16 counts trailing (low-order) zeroes, +// and if all are zero, then 16. +func Ctz16(x uint16) uint16 { + if x == 0 { + return 16 + } + return uint16(builtinCtz32(uint32(x))) +} + +//go:nosplit + +// Ctz8 counts trailing (low-order) zeroes, +// and if all are zero, then 8. +func Ctz8(x uint8) uint8 { + if x == 0 { + return 8 + } + return uint8(builtinCtz32(uint32(x))) +} + +//extern __builtin_bswap64 +func bswap64(uint64) uint64 + +//go:nosplit + +// Bswap64 returns its input with byte order reversed +// 0x0102030405060708 -> 0x0807060504030201 +func Bswap64(x uint64) uint64 { + return bswap64(x) +} + +//extern __builtin_bswap32 +func bswap32(uint32) uint32 + +//go:nosplit + +// Bswap32 returns its input with byte order reversed +// 0x01020304 -> 0x04030201 +func Bswap32(x uint32) uint32 { + return bswap32(x) +} diff --git a/libgo/go/runtime/internal/sys/intrinsics_test.go b/libgo/go/runtime/internal/sys/intrinsics_test.go new file mode 100644 index 00000000000..097631bc1e5 --- /dev/null +++ b/libgo/go/runtime/internal/sys/intrinsics_test.go @@ -0,0 +1,54 @@ +package sys_test + +import ( + "runtime/internal/sys" + "testing" +) + +func TestCtz64(t *testing.T) { + for i := uint(0); i <= 64; i++ { + x := uint64(5) << i + if got := sys.Ctz64(x); got != uint64(i) { + t.Errorf("Ctz64(%d)=%d, want %d", x, got, i) + } + } +} +func TestCtz32(t *testing.T) { + for i := uint(0); i <= 32; i++ { + x := uint32(5) << i + if got := sys.Ctz32(x); got != uint32(i) { + t.Errorf("Ctz32(%d)=%d, want %d", x, got, i) + } + } +} +func TestCtz16(t *testing.T) { + for i := uint(0); i <= 16; i++ { + x := uint16(5) << i + if got := sys.Ctz16(x); got != uint16(i) { + t.Errorf("Ctz16(%d)=%d, want %d", x, got, i) + } + } +} +func TestCtz8(t *testing.T) { + for i := uint(0); i <= 8; i++ { + x := uint8(5) << i + if got := sys.Ctz8(x); got != uint8(i) { + t.Errorf("Ctz8(%d)=%d, want %d", x, got, i) + } + } +} + +func TestBswap64(t *testing.T) { + x := uint64(0x1122334455667788) + y := sys.Bswap64(x) + if y != 0x8877665544332211 { + t.Errorf("Bswap(%x)=%x, want 0x8877665544332211", x, y) + } +} +func TestBswap32(t *testing.T) { + x := uint32(0x11223344) + y := sys.Bswap32(x) + if y != 0x44332211 { + t.Errorf("Bswap(%x)=%x, want 0x44332211", x, y) + } +} diff --git a/libgo/go/runtime/internal/sys/stubs.go b/libgo/go/runtime/internal/sys/stubs.go new file mode 100644 index 00000000000..0a94502f32d --- /dev/null +++ b/libgo/go/runtime/internal/sys/stubs.go @@ -0,0 +1,11 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sys + +// Declarations for runtime services implemented in C or assembly. + +const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const +const RegSize = 4 << (^Uintreg(0) >> 63) // unsafe.Sizeof(uintreg(0)) but an ideal const +const SpAlign = 1*(1-GoarchArm64) + 16*GoarchArm64 // SP alignment: 1 normally, 16 for ARM64 diff --git a/libgo/go/runtime/internal/sys/sys.go b/libgo/go/runtime/internal/sys/sys.go new file mode 100644 index 00000000000..586a763717d --- /dev/null +++ b/libgo/go/runtime/internal/sys/sys.go @@ -0,0 +1,15 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// package sys contains system- and configuration- and architecture-specific +// constants used by the runtime. +package sys + +// The next line makes 'go generate' write the zgen_*.go files with +// per-OS and per-arch information, including constants +// named goos_$GOOS and goarch_$GOARCH for every +// known GOOS and GOARCH. The constant is 1 on the +// current system, 0 otherwise; multiplying by them is +// useful for defining GOOS- or GOARCH-specific constants. +//go:generate go run gengoos.go diff --git a/libgo/go/runtime/pprof/pprof.go b/libgo/go/runtime/pprof/pprof.go index d2e5b63fedb..0a58bafd85f 100644 --- a/libgo/go/runtime/pprof/pprof.go +++ b/libgo/go/runtime/pprof/pprof.go @@ -4,8 +4,69 @@ // Package pprof writes runtime profiling data in the format expected // by the pprof visualization tool. +// +// Profiling a Go program +// +// The first step to profiling a Go program is to enable profiling. +// Support for profiling benchmarks built with the standard testing +// package is built into go test. For example, the following command +// runs benchmarks in the current directory and writes the CPU and +// memory profiles to cpu.prof and mem.prof: +// +// go test -cpuprofile cpu.prof -memprofile mem.prof -bench . +// +// To add equivalent profiling support to a standalone program, add +// code like the following to your main function: +// +// var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") +// var memprofile = flag.String("memprofile", "", "write memory profile to `file`") +// +// func main() { +// flag.Parse() +// if *cpuprofile != "" { +// f, err := os.Create(*cpuprofile) +// if err != nil { +// log.Fatal("could not create CPU profile: ", err) +// } +// if err := pprof.StartCPUProfile(f); err != nil { +// log.Fatal("could not start CPU profile: ", err) +// } +// defer pprof.StopCPUProfile() +// } +// ... +// if *memprofile != "" { +// f, err := os.Create(*memprofile) +// if err != nil { +// log.Fatal("could not create memory profile: ", err) +// } +// runtime.GC() // get up-to-date statistics +// if err := pprof.WriteHeapProfile(f); err != nil { +// log.Fatal("could not write memory profile: ", err) +// } +// f.Close() +// } +// } +// +// There is also a standard HTTP interface to profiling data. Adding +// the following line will install handlers under the /debug/pprof/ +// URL to download live profiles: +// +// import _ "net/http/pprof" +// +// See the net/http/pprof package for more details. +// +// Profiles can then be visualized with the pprof tool: +// +// go tool pprof cpu.prof +// +// There are many commands available from the pprof command line. +// Commonly used commands include "top", which prints a summary of the +// top program hot-spots, and "web", which opens an interactive graph +// of hot-spots and their call graphs. Use "help" for information on +// all pprof commands. +// // For more information about pprof, see -// http://github.com/google/pprof/. +// https://github.com/google/pprof/blob/master/doc/pprof.md. package pprof import ( diff --git a/libgo/go/runtime/runtime2.go b/libgo/go/runtime/runtime2.go index 05ce513aa9a..468d11e8e83 100644 --- a/libgo/go/runtime/runtime2.go +++ b/libgo/go/runtime/runtime2.go @@ -805,7 +805,11 @@ var ( // _ucontext_t is a Go version of the C ucontext_t type, used by getcontext. // _sizeof_ucontext_t is defined by the Makefile from <ucontext.h>. -type _ucontext_t [_sizeof_ucontext_t / unsafe.Sizeof(uintptr(0))]unsafe.Pointer +// On some systems getcontext and friends require a value that is +// aligned to a 16-byte boundary. We implement this by increasing the +// required size and picking an appropriate offset when we use the +// array. +type _ucontext_t [(_sizeof_ucontext_t + 15) / unsafe.Sizeof(unsafe.Pointer(nil))]unsafe.Pointer // traceback is used to collect stack traces from other goroutines. type traceback struct { diff --git a/libgo/go/syscall/syscall_darwin_test.go b/libgo/go/syscall/syscall_darwin_test.go new file mode 100644 index 00000000000..cea5636d07d --- /dev/null +++ b/libgo/go/syscall/syscall_darwin_test.go @@ -0,0 +1,23 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin +// +build amd64 386 arm arm64 + +package syscall_test + +import ( + "syscall" + "testing" +) + +func TestDarwinGettimeofday(t *testing.T) { + tv := &syscall.Timeval{} + if err := syscall.Gettimeofday(tv); err != nil { + t.Fatal(err) + } + if tv.Sec == 0 && tv.Usec == 0 { + t.Fatal("Sec and Usec both zero") + } +} diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 1ac03a42372..6ac8857338b 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -156,6 +156,26 @@ fixcontext(ucontext_t *c) #endif +// ucontext_arg returns a properly aligned ucontext_t value. On some +// systems a ucontext_t value must be aligned to a 16-byte boundary. +// The g structure that has fields of type ucontext_t is defined in +// Go, and Go has no simple way to align a field to such a boundary. +// So we make the field larger in runtime2.go and pick an appropriate +// offset within the field here. +static ucontext_t* +ucontext_arg(void** go_ucontext) +{ + uintptr_t p = (uintptr_t)go_ucontext; + size_t align = __alignof__(ucontext_t); + if(align > 16) { + // We only ensured space for up to a 16 byte alignment + // in libgo/go/runtime/runtime2.go. + runtime_throw("required alignment of ucontext_t too large"); + } + p = (p + align - 1) &~ (uintptr_t)(align - 1); + return (ucontext_t*)p; +} + // We can not always refer to the TLS variables directly. The // compiler will call tls_get_addr to get the address of the variable, // and it may hold it in a register across a call to schedule. When @@ -245,8 +265,8 @@ runtime_gogo(G* newg) #endif g = newg; newg->fromgogo = true; - fixcontext((ucontext_t*)&newg->context[0]); - setcontext((ucontext_t*)&newg->context[0]); + fixcontext(ucontext_arg(&newg->context[0])); + setcontext(ucontext_arg(&newg->context[0])); runtime_throw("gogo setcontext returned"); } @@ -278,7 +298,7 @@ runtime_mcall(void (*pfn)(G*)) gp->gcnextsp = &pfn; #endif gp->fromgogo = false; - getcontext((ucontext_t*)&gp->context[0]); + getcontext(ucontext_arg(&gp->context[0])); // When we return from getcontext, we may be running // in a new thread. That means that g may have @@ -305,8 +325,8 @@ runtime_mcall(void (*pfn)(G*)) // the getcontext call just above. g = mp->g0; - fixcontext((ucontext_t*)&mp->g0->context[0]); - setcontext((ucontext_t*)&mp->g0->context[0]); + fixcontext(ucontext_arg(&mp->g0->context[0])); + setcontext(ucontext_arg(&mp->g0->context[0])); runtime_throw("runtime: mcall function returned"); } } @@ -709,7 +729,7 @@ runtime_tracebackothers(G * volatile me) #ifdef USING_SPLIT_STACK __splitstack_getcontext(&me->stackcontext[0]); #endif - getcontext((ucontext_t*)&me->context[0]); + getcontext(ucontext_arg(&me->context[0])); if(gp->traceback != nil) { runtime_gogo(gp); @@ -750,7 +770,7 @@ runtime_tracebackothers(G * volatile me) #ifdef USING_SPLIT_STACK __splitstack_getcontext(&me->stackcontext[0]); #endif - getcontext((ucontext_t*)&me->context[0]); + getcontext(ucontext_arg(&me->context[0])); if(gp->traceback != nil) { runtime_gogo(gp); @@ -1063,7 +1083,7 @@ runtime_mstart(void* mp) g->gcstacksize = 0; g->gcnextsp = ∓ #endif - getcontext((ucontext_t*)&g->context[0]); + getcontext(ucontext_arg(&g->context[0])); if(g->entry != nil) { // Got here from mcall. @@ -1251,7 +1271,7 @@ runtime_needm(void) g->gcstacksize = 0; g->gcnextsp = ∓ #endif - getcontext((ucontext_t*)&g->context[0]); + getcontext(ucontext_arg(&g->context[0])); if(g->entry != nil) { // Got here from mcall. @@ -1282,6 +1302,7 @@ runtime_newextram(void) G *gp; byte *g0_sp, *sp; uintptr g0_spsize, spsize; + ucontext_t *uc; // Create extra goroutine locked to extra m. // The goroutine is the context in which the cgo callback will run. @@ -1302,10 +1323,11 @@ runtime_newextram(void) // The context for gp will be set up in runtime_needm. But // here we need to set up the context for g0. - getcontext((ucontext_t*)&mp->g0->context[0]); - ((ucontext_t*)&mp->g0->context[0])->uc_stack.ss_sp = g0_sp; - ((ucontext_t*)&mp->g0->context[0])->uc_stack.ss_size = (size_t)g0_spsize; - makecontext((ucontext_t*)&mp->g0->context[0], kickoff, 0); + uc = ucontext_arg(&mp->g0->context[0]); + getcontext(uc); + uc->uc_stack.ss_sp = g0_sp; + uc->uc_stack.ss_size = (size_t)g0_spsize; + makecontext(uc, kickoff, 0); // Add m to the extra list. mnext = lockextra(true); @@ -2007,7 +2029,7 @@ runtime_entersyscall() { // Save the registers in the g structure so that any pointers // held in registers will be seen by the garbage collector. - getcontext((ucontext_t*)&g->gcregs[0]); + getcontext(ucontext_arg(&g->gcregs[0])); // Do the work in a separate function, so that this function // doesn't save any registers on its own stack. If this @@ -2086,7 +2108,7 @@ runtime_entersyscallblock(void) // Save the registers in the g structure so that any pointers // held in registers will be seen by the garbage collector. - getcontext((ucontext_t*)&g->gcregs[0]); + getcontext(ucontext_arg(&g->gcregs[0])); g->atomicstatus = _Gsyscall; @@ -2375,14 +2397,13 @@ __go_go(void (*fn)(void*), void* arg) byte * volatile vsp = sp; size_t volatile vspsize = spsize; G * volatile vnewg = newg; + ucontext_t * volatile uc; - getcontext((ucontext_t*)&vnewg->context[0]); - ((ucontext_t*)&vnewg->context[0])->uc_stack.ss_sp = vsp; -#ifdef MAKECONTEXT_STACK_TOP - ((ucontext_t*)&vnewg->context[0])->uc_stack.ss_sp += vspsize; -#endif - ((ucontext_t*)&vnewg->context[0])->uc_stack.ss_size = vspsize; - makecontext((ucontext_t*)&vnewg->context[0], kickoff, 0); + uc = ucontext_arg(&vnewg->context[0]); + getcontext(uc); + uc->uc_stack.ss_sp = vsp; + uc->uc_stack.ss_size = vspsize; + makecontext(uc, kickoff, 0); runqput(p, vnewg); diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in index ba04a504cfb..6c82a639d5f 100644 --- a/libgo/testsuite/Makefile.in +++ b/libgo/testsuite/Makefile.in @@ -79,6 +79,9 @@ am__can_run_installinfo = \ DEJATOOL = $(PACKAGE) RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir ACLOCAL = @ACLOCAL@ +ALLGOARCH = @ALLGOARCH@ +ALLGOARCHFAMILY = @ALLGOARCHFAMILY@ +ALLGOOS = @ALLGOOS@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ @@ -103,6 +106,14 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GOARCH = @GOARCH@ +GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@ +GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@ +GOARCH_FAMILY = @GOARCH_FAMILY@ +GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@ +GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@ +GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@ +GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@ +GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@ GOC = @GOC@ GOCFLAGS = @GOCFLAGS@ GOOS = @GOOS@ diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 32b11ec067f..e7749b2be4e 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,7 @@ +2016-09-14 Marek Polacek <polacek@redhat.com> + + * testsuite/libgomp.c++/atomic-3.C: Use -Wno-deprecated. + 2016-08-19 Jakub Jelinek <jakub@redhat.com> PR fortran/71014 diff --git a/libgomp/testsuite/libgomp.c++/atomic-3.C b/libgomp/testsuite/libgomp.c++/atomic-3.C index 660b260e19f..f957b2fece5 100644 --- a/libgomp/testsuite/libgomp.c++/atomic-3.C +++ b/libgomp/testsuite/libgomp.c++/atomic-3.C @@ -1,4 +1,5 @@ // { dg-do run } +// { dg-options "-Wno-deprecated" } extern "C" void abort (void); bool v, x1, x2, x3, x4, x5, x6; diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 0b97a904c6f..5934bc1fa8a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,13 @@ +2016-09-19 Andrew Stubbs <ams@codesourcery.com> + + * pex-win32.c (argv_to_cmdline): Quote zero-length parameters. + * testsuite/test-pexecute.c (main): Insert check for zero-length parameters. + +2016-09-10 Mark Wielaard <mjw@redhat.com> + + * cp-demangle.c (d_substitution): Change struct demangle_component + variable name from c to dc. + 2016-08-12 Marek Polacek <polacek@redhat.com> PR c/7652 diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 1c2bce29179..a843dc38f98 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -3769,7 +3769,7 @@ d_substitution (struct d_info *di, int prefix) { const char *s; int len; - struct demangle_component *c; + struct demangle_component *dc; if (p->set_last_name != NULL) di->last_name = d_make_sub (di, p->set_last_name, @@ -3785,15 +3785,15 @@ d_substitution (struct d_info *di, int prefix) len = p->simple_len; } di->expansion += len; - c = d_make_sub (di, s, len); + dc = d_make_sub (di, s, len); if (d_peek_char (di) == 'B') { /* If there are ABI tags on the abbreviation, it becomes a substitution candidate. */ - c = d_abi_tags (di, c); - d_add_substitution (di, c); + dc = d_abi_tags (di, dc); + d_add_substitution (di, dc); } - return c; + return dc; } } diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c index 66d2f1157c7..4c15b0d11a0 100644 --- a/libiberty/pex-win32.c +++ b/libiberty/pex-win32.c @@ -370,6 +370,8 @@ argv_to_cmdline (char *const *argv) cmdline_len++; } } + if (j == 0) + needs_quotes = 1; /* Trailing backslashes also need to be escaped because they will be followed by the terminating quote. */ if (needs_quotes) @@ -394,6 +396,8 @@ argv_to_cmdline (char *const *argv) break; } } + if (j == 0) + needs_quotes = 1; if (needs_quotes) { diff --git a/libiberty/testsuite/test-pexecute.c b/libiberty/testsuite/test-pexecute.c index 8e01fda479a..f62239d49b8 100644 --- a/libiberty/testsuite/test-pexecute.c +++ b/libiberty/testsuite/test-pexecute.c @@ -285,6 +285,20 @@ main (int argc, char **argv) ERROR ("echo exit status failed"); pex_free (pex1); + /* Check empty parameters don't get lost. */ + pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp"); + subargv[1] = "echo"; + subargv[2] = "foo"; + subargv[3] = ""; + subargv[4] = "bar"; + subargv[5] = NULL; + TEST_PEX_RUN (pex1, 0, "./test-pexecute", subargv, NULL, NULL); + e = TEST_PEX_READ_OUTPUT (pex1); + CHECK_LINE (e, "foo bar"); /* Two spaces! */ + if (TEST_PEX_GET_STATUS_1 (pex1) != 0) + ERROR ("echo exit status failed"); + pex_free (pex1); + pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp"); subargv[1] = "echo"; subargv[2] = "bar"; diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index d9eb7fa3bd2..a06ab4de7e7 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,8 @@ +2016-09-05 Jakub Jelinek <jakub@redhat.com> + + PR sanitizer/77396 + * asan/asan_globals.cc: Cherry-pick upstream r280657. + 2016-08-12 Jakub Jelinek <jakub@redhat.com> PR sanitizer/71042 diff --git a/libsanitizer/asan/asan_globals.cc b/libsanitizer/asan/asan_globals.cc index 9c3588b8e08..f3531cbd133 100644 --- a/libsanitizer/asan/asan_globals.cc +++ b/libsanitizer/asan/asan_globals.cc @@ -248,10 +248,10 @@ void __asan_unregister_globals(__asan_global *globals, uptr n) { // initializer can only touch global variables in the same TU. void __asan_before_dynamic_init(const char *module_name) { if (!flags()->check_initialization_order || - !CanPoisonMemory()) + !CanPoisonMemory() || + !dynamic_init_globals) return; bool strict_init_order = flags()->strict_init_order; - CHECK(dynamic_init_globals); CHECK(module_name); CHECK(asan_inited); BlockingMutexLock lock(&mu_for_globals); @@ -274,7 +274,8 @@ void __asan_before_dynamic_init(const char *module_name) { // TU are poisoned. It simply unpoisons all dynamically initialized globals. void __asan_after_dynamic_init() { if (!flags()->check_initialization_order || - !CanPoisonMemory()) + !CanPoisonMemory() || + !dynamic_init_globals) return; CHECK(asan_inited); BlockingMutexLock lock(&mu_for_globals); diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 10761e8c38a..70ff276beb4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,458 @@ +2016-09-17 Jonathan Wakely <jwakely@redhat.com> + + * python/libstdcxx/v6/printers.py (StdVariantPrinter): Define. + (StdExpAnyPrinter, StdExpOptionalPrinter, StdExpStringViewPrinter): + Register for C++17 components in namespace std. Strip inline namespace + from typename. + +2016-09-16 Jonathan Wakely <jwakely@redhat.com> + + * doc/xml/manual/profile_mode.xml: Fix typo. + * doc/html/manual/profile_mode_devel.html: Regenerate. + +2016-09-16 Jonathan Wakely <jwakely@redhat.com> + Marc Glisse <marc.glisse@inria.fr> + + * libsupc++/new_opa.cc [_GLIBCXX_HAVE_ALIGNED_ALLOC] + (operator new(size_t, align_val_t)): Replace modulus operator with + mask. + +2016-09-16 Jonathan Wakely <jwakely@redhat.com> + + * libsupc++/new_opa.cc [_GLIBCXX_HAVE_POSIX_MEMALIGN] (aligned_alloc): + Increase alignment if less than sizeof(void*). + [_GLIBCXX_HAVE_ALIGNED_ALLOC] (operator new(size_t, align_val_t)): + Increase size if not a multiple of alignment. + +2016-09-15 Jonathan Wakely <jwakely@redhat.com> + + * doc/xml/manual/debug_mode.xml: Minor editorial fixes. + * doc/html/*: Regenerate. + + * testsuite/23_containers/vector/debug/insert6_neg.cc: Remove + -Wno-deprecated. + * testsuite/util/debug/checks.h (generate_unique<bool>): Specialize. + +2016-09-14 Marek Polacek <polacek@redhat.com> + + * testsuite/23_containers/vector/debug/insert6_neg.cc: Use + -Wno-deprecated. + +2016-09-14 Christophe Lyon <christophe.lyon@linaro.org> + + * testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: + Move dg-do directive before dg-skip. + * testsuite/21_strings/debug/iterator_self_move_assign_neg.cc: + Move dg-do directive before dg-require. + * testsuite/21_strings/debug/self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/57779_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/60587_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/assign1_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/assign2_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/assign3_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/insert5_neg.cc: Likewise. + * testsuite/25_algorithms/lower_bound/debug/irreflexive.cc: Likewise. + * testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc: + Likewise. + * testsuite/25_algorithms/pop_heap/empty2_neg.cc: Likewise. + * testsuite/25_algorithms/pop_heap/empty_neg.cc: Likewise. + * testsuite/27_io/objects/char/12048-5.cc: Likewise. + * testsuite/ext/special_functions/conf_hyperg/check_nan.cc: Likewise. + * testsuite/ext/special_functions/hyperg/check_nan.cc: Likewise. + +2016-09-13 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement P0040R3, Extending memory management tools. + * include/bits/stl_uninitialized.h (utility): New include + in C++17 mode. + (uninitialized_default_construct): New. + (uninitialized_default_construct_n): Likewise. + (uninitialized_value_construct): Likewise. + (uninitialized_value_construct_n): Likewise. + (uninitialized_move): Likewise. + (uninitialized_move_n): Likewise. + (destroy_at, destroy, destroy_n): Likewise. + * testsuite/20_util/specialized_algorithms/memory_management_tools/ + 1.cc: New. + +2016-09-12 Jason Merrill <jason@redhat.com> + + * config/abi/pre/gnu.ver: Use [jmy] for size_t. + +2016-09-12 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement P0253R1, Fixing a design mistake in the searchers + interface in Library Fundamentals. + * include/std/functional: (utility): New include in C++17 mode. + (default_searcher): Use a pair as return type, adjust the definition. + (boyer_moore_searcher): Likewise. + (boyer_moore_horspool_searcher): Likewise. + * testsuite/20_util/function_objects/searchers.cc: Adjust. + +2016-09-12 Ville Voutilainen <ville.voutilainen@gmail.com> + + Implement C++17 string searchers. + * include/std/functional: (unordered_map, vector): New includes + in C++17 mode. + (array, bits/stl_algo.h): Likewise. + (default_searcher, __boyer_moore_map_base): New. + (__boyer_moore_array_base, __is_std_equal_to): Likewise. + (__boyer_moore_base_t, boyer_moore_searcher): Likewise. + (boyer_moore_horspool_searcher, make_default_searcher): Likewise. + (make_boyer_moore_searcher): Likewise. + (make_boyer_moore_horspool_searcher): Likewise. + * testsuite/20_util/function_objects/searchers.cc: New. + +2016-09-12 Matthew Wahab <matthew.wahab@arm.com> + + * testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc: + Move dg-do directive before dg-require. + * testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc: Likewise. + * testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc: + Likewise. + * testsuite/22_locale/codecvt/utf8.cc: Likewise. + * testsuite/22_locale/locale/cons/unicode.cc: Likewise. + * testsuite/23_containers/deque/debug/assign1_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/assign2_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/assign3_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/insert5_neg.cc: Likewise. + * testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/deque/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/deque/debug/shrink_to_fit.cc: Likewise. + * testsuite/23_containers/forward_list/debug/60499.cc: Likewise. + * testsuite/23_containers/forward_list/debug/construct1_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/construct2_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/construct3_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after1_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after2_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after3_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after4_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after5_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after6_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after7_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after8_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/erase_after9_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/insert_after1_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/insert_after2_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/insert_after3_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/insert_after4_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after1_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after2_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after3_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after4_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after5_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after6_neg.cc: + Likewise. + * testsuite/23_containers/forward_list/debug/splice_after7_neg.cc: + Likewise. + * testsuite/23_containers/list/debug/assign1_neg.cc: Likewise. + * testsuite/23_containers/list/debug/assign2_neg.cc: Likewise. + * testsuite/23_containers/list/debug/assign3_neg.cc: Likewise. + * testsuite/23_containers/list/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/list/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/list/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/list/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/list/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/list/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/list/debug/insert5_neg.cc: Likewise. + * testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/list/debug/self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/map/debug/60499.cc: Likewise. + * testsuite/23_containers/map/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/map/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/map/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/map/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/map/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/map/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/map/debug/self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/60499.cc: Likewise. + * testsuite/23_containers/multimap/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/multimap/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/multiset/debug/60499.cc: Likewise. + * testsuite/23_containers/multiset/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/multiset/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/set/debug/60499.cc: Likewise. + * testsuite/23_containers/set/debug/construct1_neg.cc: Likewise. + * testsuite/23_containers/set/debug/construct2_neg.cc: Likewise. + * testsuite/23_containers/set/debug/construct3_neg.cc: Likewise. + * testsuite/23_containers/set/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/set/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/set/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/set/debug/self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/60499.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/begin1_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/begin2_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/cbegin_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/cend_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/construct1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/construct2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/construct3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/end1_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/end2_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/ + invalid_local_iterator_compare_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/ + invalid_local_iterator_range_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/unordered_map/debug/ + use_erased_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/ + use_invalid_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_map/debug/ + use_invalid_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/60499.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/cend_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/end1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/end2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + invalid_local_iterator_compare_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + invalid_local_iterator_range_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + max_load_factor_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + use_erased_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + use_invalid_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multimap/debug/ + use_invalid_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/60499.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/cend_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/end1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/end2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + invalid_local_iterator_compare_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + invalid_local_iterator_range_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + max_load_factor_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + use_erased_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + use_invalid_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_multiset/debug/ + use_invalid_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/60499.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/begin1_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/begin2_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc: + Likewise. + * testsuite/23_containers/unordered_set/debug/cbegin_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/cend_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/construct1_neg.cc: + Likewise. + * testsuite/23_containers/unordered_set/debug/construct2_neg.cc: + Likewise. + * testsuite/23_containers/unordered_set/debug/construct3_neg.cc: + Likewise. + * testsuite/23_containers/unordered_set/debug/end1_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/end2_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/insert1_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/insert2_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/insert3_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + invalid_local_iterator_compare_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + invalid_local_iterator_range_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + max_load_factor_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + use_erased_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + use_invalid_iterator_neg.cc: Likewise. + * testsuite/23_containers/unordered_set/debug/ + use_invalid_local_iterator_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/52433.cc: Likewise. + * testsuite/23_containers/vector/debug/60499.cc: Likewise. + * testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc: Likewise. + * testsuite/23_containers/vector/debug/ + iterator_self_move_assign_neg.cc: Likewise. + * testsuite/23_containers/vector/debug/self_move_assign_neg.cc: + Likewise. + * testsuite/23_containers/vector/debug/shrink_to_fit.cc: Likewise. + * testsuite/25_algorithms/pop_heap/complexity.cc: Likewise. + * testsuite/25_algorithms/push_heap/complexity.cc: Likewise. + * testsuite/25_algorithms/sort_heap/complexity.cc: Likewise. + * testsuite/29_atomics/atomic/60658.cc: Likewise. + * testsuite/29_atomics/atomic/60695.cc: Likewise. + * testsuite/29_atomics/atomic/62259.cc: Likewise. + * testsuite/29_atomics/atomic/64658.cc: Likewise. + * testsuite/29_atomics/atomic/cons/49445.cc: Likewise. + * testsuite/29_atomics/atomic/operators/51811.cc: Likewise. + * testsuite/29_atomics/atomic/operators/pointer_partial_void.cc: + Likewise. + +2016-09-11 Jonathan Wakely <jwakely@redhat.com> + + * libsupc++/new_opant.cc: Include exception_defines.h. + * libsupc++/new_opvant.cc: Likewise. + +2016-09-09 Jason Merrill <jason@redhat.com> + + Implement P0035R4, C++17 new of over-aligned types. + * libsupc++/new: Declare aligned new/delete operators. + * config/abi/pre/gnu.ver: Export them. + * configure.ac: Check for aligned_alloc, posix_memalign, memalign, + _aligned_malloc. + * libsupc++/new_opa.cc: New. + * libsupc++/new_opant.cc: New. + * libsupc++/new_opva.cc: New. + * libsupc++/new_opva.cc: New. + * libsupc++/del_opa.cc: New. + * libsupc++/del_opant.cc: New. + * libsupc++/del_opsa.cc: New. + * libsupc++/del_opva.cc: New. + * libsupc++/del_opvant.cc: New. + * libsupc++/del_opvsa.cc: New. + * libsupc++/Makefile.am: Build them. + +2016-09-05 Tim Shen <timshen@google.com> + + * include/std/variant: include bits/move.h for std::addressof. + +2016-09-05 Mikhail Strelnikov <mikhail.strelnikov@gmail.com> + + * include/std/variant (_Variant_storage::_M_storage()): Use + std::addressof instead of operator& to take address. + +2016-09-02 Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> + + * acinclude.m4 (GLIBCXX_CONFIGURE_TESTSUITE): Check for presence of + setrlimit on both native and cross targets. + * configure: Regenerate. + 2016-08-31 Jonathan Wakely <jwakely@redhat.com> * include/bits/shared_ptr.h (_Assignable): New alias template. diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index aaf5adbe62b..6d897bed8b1 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -632,10 +632,10 @@ dnl baseline_dir dnl baseline_subdir_switch dnl AC_DEFUN([GLIBCXX_CONFIGURE_TESTSUITE], [ - if $GLIBCXX_IS_NATIVE ; then - # Do checks for resource limit functions. - GLIBCXX_CHECK_SETRLIMIT + # Do checks for resource limit functions. + GLIBCXX_CHECK_SETRLIMIT + if $GLIBCXX_IS_NATIVE ; then # Look for setenv, so that extended locale tests can be performed. GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_3(setenv) fi diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index 5ac2df4d8a8..2ab6e0d6a49 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -6,6 +6,9 @@ /* Define to 1 if you have the `acosl' function. */ #undef HAVE_ACOSL +/* Define to 1 if you have the `aligned_alloc' function. */ +#undef HAVE_ALIGNED_ALLOC + /* Define to 1 if you have the `asinf' function. */ #undef HAVE_ASINF @@ -285,6 +288,9 @@ /* Define if mbstate_t exists in wchar.h. */ #undef HAVE_MBSTATE_T +/* Define to 1 if you have the `memalign' function. */ +#undef HAVE_MEMALIGN + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -309,6 +315,9 @@ /* Define if poll is available in <poll.h>. */ #undef HAVE_POLL +/* Define to 1 if you have the `posix_memalign' function. */ +#undef HAVE_POSIX_MEMALIGN + /* Define to 1 if you have the `powf' function. */ #undef HAVE_POWF @@ -505,6 +514,9 @@ /* Define to 1 if you have the `_acosl' function. */ #undef HAVE__ACOSL +/* Define to 1 if you have the `_aligned_malloc' function. */ +#undef HAVE__ALIGNED_MALLOC + /* Define to 1 if you have the `_asinf' function. */ #undef HAVE__ASINF diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 0ab4bb10b35..8b0f67bbf87 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -2197,6 +2197,18 @@ CXXABI_1.3.11 { __cxa_init_primary_exception; _ZNSt15__exception_ptr13exception_ptrC1EPv; + # C++17 aligned new/delete + _Znw[jmy]St11align_val_t; + _Znw[jmy]St11align_val_tRKSt9nothrow_t; + _Zna[jmy]St11align_val_t; + _Zna[jmy]St11align_val_tRKSt9nothrow_t; + _ZdlPvSt11align_val_t; + _ZdlPvSt11align_val_tRKSt9nothrow_t; + _ZdlPv[jmy]St11align_val_t; + _ZdaPvSt11align_val_t; + _ZdaPvSt11align_val_tRKSt9nothrow_t; + _ZdaPv[jmy]St11align_val_t; + } CXXABI_1.3.10; # Symbols in the support library (libsupc++) supporting transactional memory. diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index f2a75aaa2f3..6332c4d7f87 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -27972,6 +27972,19 @@ _ACEOF fi done + for ac_func in aligned_alloc posix_memalign memalign _aligned_malloc +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +eval as_val=\$$as_ac_var + if test "x$as_val" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + # For iconv support. @@ -79449,8 +79462,7 @@ $as_echo "$ac_cv_x86_rdrand" >&6; } # This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE. - if $GLIBCXX_IS_NATIVE ; then - # Do checks for resource limit functions. + # Do checks for resource limit functions. setrlimit_have_headers=yes for ac_header in unistd.h sys/time.h sys/resource.h @@ -79679,6 +79691,7 @@ $as_echo "#define _GLIBCXX_RES_LIMITS 1" >>confdefs.h $as_echo "$ac_res_limits" >&6; } + if $GLIBCXX_IS_NATIVE ; then # Look for setenv, so that extended locale tests can be performed. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setenv declaration" >&5 diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac index 9e19e9927fd..5657ecb27dc 100644 --- a/libstdc++-v3/configure.ac +++ b/libstdc++-v3/configure.ac @@ -256,6 +256,7 @@ if $GLIBCXX_IS_NATIVE; then GCC_CHECK_TLS AC_CHECK_FUNCS(__cxa_thread_atexit_impl) + AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) # For iconv support. AM_ICONV diff --git a/libstdc++-v3/doc/html/manual/debug_mode_design.html b/libstdc++-v3/doc/html/manual/debug_mode_design.html index 747f192c47f..3373471d48e 100644 --- a/libstdc++-v3/doc/html/manual/debug_mode_design.html +++ b/libstdc++-v3/doc/html/manual/debug_mode_design.html @@ -352,8 +352,7 @@ test02() declarations disallow specialization. This method fails the <span class="emphasis"><em>correctness</em></span> criteria.</p></li><li class="listitem"><p><span class="emphasis"><em> Use implementation-specific properties of anonymous namespaces. </em></span> - See <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00004.html" target="_top"> this post - </a> + See <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00004.html" target="_top">this post</a>. This method fails the <span class="emphasis"><em>correctness</em></span> criteria.</p></li><li class="listitem"><p><span class="emphasis"><em>Extension: allow reopening on namespaces</em></span>: This would allow the debug mode to effectively alias the namespace <code class="code">std</code> to an internal namespace, such @@ -365,8 +364,8 @@ test02() instance, the program would have two <code class="code">std::cout</code> objects! This solution would fails the <span class="emphasis"><em>minimize recompilation</em></span> requirement, because we would only be able to - support option (1) or (2).</p></li><li class="listitem"><p><span class="emphasis"><em>Extension: use link name</em></span>: This option involves - complicated re-naming between debug-mode and release-mode + support option (1) or (2).</p></li><li class="listitem"><p><span class="emphasis"><em>Extension: use link name</em></span>: This option + involves complicated re-naming between debug-mode and release-mode components at compile time, and then a g++ extension called <span class="emphasis"><em> link name </em></span> to recover the original names at link time. There are two drawbacks to this approach. One, it's very verbose, @@ -375,8 +374,8 @@ test02() functions taking no arguments in mixed-mode settings resulting in equivalent link names, <code class="code"> vector::push_back() </code> being one example. - See <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00177.html" target="_top">link - name</a> </p></li></ul></div><p>Other options may exist for implementing the debug mode, many of + See <a class="link" href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00177.html" target="_top">proof-of-concept using link + name</a>. </p></li></ul></div><p>Other options may exist for implementing the debug mode, many of which have probably been considered and others that may still be lurking. This list may be expanded over time to include other options that we could have implemented, but in all cases the full diff --git a/libstdc++-v3/doc/html/manual/profile_mode_devel.html b/libstdc++-v3/doc/html/manual/profile_mode_devel.html index cb0c9de828b..2521dd66811 100644 --- a/libstdc++-v3/doc/html/manual/profile_mode_devel.html +++ b/libstdc++-v3/doc/html/manual/profile_mode_devel.html @@ -34,7 +34,7 @@ <code class="code">include/profile/impl/profiler.h</code>. Hook names must start with <code class="code">__profcxx_</code>. Make sure they transform - in no code with <code class="code">-D_NO_GLBICXX_PROFILE_MAGIC</code>. + in no code with <code class="code">-D_NO_GLIBCXX_PROFILE_MAGIC</code>. Make sure all calls to any method in namespace <code class="code">__gnu_profile</code> is protected against reentrance using macro <code class="code">_GLIBCXX_PROFILE_REENTRANCE_GUARD</code>. @@ -64,4 +64,4 @@ <code class="code">include/profile/impl/profiler_trace.h</code>. Use <code class="code">__trace_vector_to_list</code> as an example. </p><p>Add documentation in file <code class="code">doc/xml/manual/profile_mode.xml</code>. - </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="profile_mode_impl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="profile_mode.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="profile_mode_diagnostics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Implementation Issues </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Diagnostics</td></tr></table></div></body></html>
\ No newline at end of file + </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="profile_mode_impl.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="profile_mode.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="profile_mode_diagnostics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Implementation Issues </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Diagnostics</td></tr></table></div></body></html> diff --git a/libstdc++-v3/doc/xml/manual/debug_mode.xml b/libstdc++-v3/doc/xml/manual/debug_mode.xml index 8b5380dfeec..ff2f1cced89 100644 --- a/libstdc++-v3/doc/xml/manual/debug_mode.xml +++ b/libstdc++-v3/doc/xml/manual/debug_mode.xml @@ -800,8 +800,7 @@ test02() <listitem><para><emphasis> Use implementation-specific properties of anonymous namespaces. </emphasis> - See <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00004.html"> this post - </link> + See <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00004.html">this post</link>. This method fails the <emphasis>correctness</emphasis> criteria.</para></listitem> <listitem><para><emphasis>Extension: allow reopening on namespaces</emphasis>: This would @@ -817,8 +816,8 @@ test02() recompilation</emphasis> requirement, because we would only be able to support option (1) or (2).</para></listitem> - <listitem><para><emphasis>Extension: use link name</emphasis>: This option involves - complicated re-naming between debug-mode and release-mode + <listitem><para><emphasis>Extension: use link name</emphasis>: This option + involves complicated re-naming between debug-mode and release-mode components at compile time, and then a g++ extension called <emphasis> link name </emphasis> to recover the original names at link time. There are two drawbacks to this approach. One, it's very verbose, @@ -827,8 +826,8 @@ test02() functions taking no arguments in mixed-mode settings resulting in equivalent link names, <code> vector::push_back() </code> being one example. - See <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00177.html">link - name</link> </para></listitem> + See <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/libstdc++/2003-08/msg00177.html">proof-of-concept using link + name</link>. </para></listitem> </itemizedlist> <para>Other options may exist for implementing the debug mode, many of diff --git a/libstdc++-v3/doc/xml/manual/profile_mode.xml b/libstdc++-v3/doc/xml/manual/profile_mode.xml index 0125f55a629..2f5eb6bfe51 100644 --- a/libstdc++-v3/doc/xml/manual/profile_mode.xml +++ b/libstdc++-v3/doc/xml/manual/profile_mode.xml @@ -619,7 +619,7 @@ it helps the user focus on the key problems and ignore the uninteresting ones. <code>include/profile/impl/profiler.h</code>. Hook names must start with <code>__profcxx_</code>. Make sure they transform - in no code with <code>-D_NO_GLBICXX_PROFILE_MAGIC</code>. + in no code with <code>-D_NO_GLIBCXX_PROFILE_MAGIC</code>. Make sure all calls to any method in namespace <code>__gnu_profile</code> is protected against reentrance using macro <code>_GLIBCXX_PROFILE_REENTRANCE_GUARD</code>. diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 6cfba13cb93..c5c81fb2c66 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -56,6 +56,10 @@ #ifndef _STL_UNINITIALIZED_H #define _STL_UNINITIALIZED_H 1 +#if __cplusplus > 201402L +#include <utility> +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -682,6 +686,98 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::__iterator_category(__first)); } #endif +#if __cplusplus > 201402L + template <typename _ForwardIterator> + inline void + uninitialized_default_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + for (; __first != __last; ++__first) + ::new (static_cast<void*>(std::__addressof(*__first))) + typename iterator_traits<_ForwardIterator>::value_type; + } + + template <typename _ForwardIterator, typename _Size> + inline _ForwardIterator + uninitialized_default_construct_n(_ForwardIterator __first, _Size __count) + { + for (; __count > 0; (void)++__first, --__count) + ::new (static_cast<void*>(std::__addressof(*__first))) + typename iterator_traits<_ForwardIterator>::value_type; + return __first; + } + + template <typename _ForwardIterator> + inline void + uninitialized_value_construct(_ForwardIterator __first, + _ForwardIterator __last) + { + for (; __first != __last; ++__first) + ::new (static_cast<void*>(std::__addressof(*__first))) + typename iterator_traits<_ForwardIterator>::value_type(); + } + + template <typename _ForwardIterator, typename _Size> + inline _ForwardIterator + uninitialized_value_construct_n(_ForwardIterator __first, _Size __count) + { + for (; __count > 0; (void)++__first, --__count) + ::new (static_cast<void*>(std::__addressof(*__first))) + typename iterator_traits<_ForwardIterator>::value_type(); + return __first; + } + + template <typename _InputIterator, typename _ForwardIterator> + inline _ForwardIterator + uninitialized_move(_InputIterator __first, _InputIterator __last, + _ForwardIterator __result) + { + for (; __first != __last; (void)++__result, ++__first) + ::new (static_cast<void*>(std::__addressof(*__result))) + typename + iterator_traits<_ForwardIterator>::value_type(std::move(*__first)); + return __result; + } + + template <typename _InputIterator, typename _Size, typename _ForwardIterator> + inline pair<_InputIterator, _ForwardIterator> + uninitialized_move_n(_InputIterator __first, _Size __count, + _ForwardIterator __result) + { + for (; __count > 0; ++__result, (void) ++__first, --__count) + ::new (static_cast<void*>(std::__addressof(*__result))) + typename + iterator_traits<_ForwardIterator>::value_type(std::move(*__first)); + return {__first, __result}; + } + + template <typename _Tp> + inline void + destroy_at(_Tp* __location) + { + __location->~_Tp(); + } + + template <typename _ForwardIterator> + inline void + destroy(_ForwardIterator __first, _ForwardIterator __last) + { + for (; __first != __last; ++__first) + std::destroy_at(std::__addressof(*__first)); + } + + template <typename _ForwardIterator, typename _Size> + inline _ForwardIterator + destroy_n(_ForwardIterator __first, _Size __count) + { + for (; __count > 0; (void)++__first, --__count) + std::destroy_at(std::__addressof(*__first)); + return __first; + } + +#endif + + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 05d4282c8bd..c750a8374bc 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -58,6 +58,14 @@ #include <bits/functional_hash.h> #include <bits/invoke.h> +#if __cplusplus > 201402L +#include <unordered_map> +#include <vector> +#include <array> +#include <utility> +#include <bits/stl_algo.h> +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -2197,6 +2205,315 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) return _Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn)}; } + // Searchers + + template<typename _ForwardIterator1, typename _BinaryPredicate = equal_to<>> + class default_searcher + { + public: + default_searcher(_ForwardIterator1 __pat_first, + _ForwardIterator1 __pat_last, + _BinaryPredicate __pred = _BinaryPredicate()) + : _M_m(__pat_first, __pat_last, std::move(__pred)) + { } + + template<typename _ForwardIterator2> + pair<_ForwardIterator2, _ForwardIterator2> + operator()(_ForwardIterator2 __first, _ForwardIterator2 __last) const + { + _ForwardIterator2 __first_ret = + std::search(__first, __last, + std::get<0>(_M_m), std::get<1>(_M_m), + std::get<2>(_M_m)); + _ForwardIterator2 __second_ret = __first_ret == __last ? + __last : std::next(__first_ret, std::distance(std::get<0>(_M_m), + std::get<1>(_M_m))); + return std::make_pair(__first_ret, __second_ret); + } + + private: + std::tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m; + }; + + template<typename _Key, typename _Tp, typename _Hash, typename _Pred> + struct __boyer_moore_map_base + { + template<typename _RAIter> + __boyer_moore_map_base(_RAIter __pat, size_t __patlen, + _Hash&& __hf, _Pred&& __pred) + : _M_bad_char{ __patlen, std::move(__hf), std::move(__pred) } + { + if (__patlen > 0) + for (__diff_type __i = 0; __i < __patlen - 1; ++__i) + _M_bad_char[__pat[__i]] = __patlen - 1 - __i; + } + + using __diff_type = _Tp; + + __diff_type + _M_lookup(_Key __key, __diff_type __not_found) const + { + auto __iter = _M_bad_char.find(__key); + if (__iter == _M_bad_char.end()) + return __not_found; + return __iter->second; + } + + _Pred + _M_pred() const { return _M_bad_char.key_eq(); } + + std::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char; + }; + + template<typename _Tp, size_t _Len, typename _Pred> + struct __boyer_moore_array_base + { + template<typename _RAIter, typename _Unused> + __boyer_moore_array_base(_RAIter __pat, size_t __patlen, + _Unused&&, _Pred&& __pred) + : _M_bad_char{ std::array<_Tp, _Len>{}, std::move(__pred) } + { + std::get<0>(_M_bad_char).fill(__patlen); + if (__patlen > 0) + for (__diff_type __i = 0; __i < __patlen - 1; ++__i) + { + auto __ch = __pat[__i]; + using _UCh = std::make_unsigned_t<decltype(__ch)>; + auto __uch = static_cast<_UCh>(__ch); + std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i; + } + } + + using __diff_type = _Tp; + + template<typename _Key> + __diff_type + _M_lookup(_Key __key, __diff_type __not_found) const + { + auto __ukey = static_cast<std::make_unsigned_t<_Key>>(__key); + if (__ukey >= _Len) + return __not_found; + return std::get<0>(_M_bad_char)[__ukey]; + } + + const _Pred& + _M_pred() const { return std::get<1>(_M_bad_char); } + + std::tuple<std::array<_Tp, _Len>, _Pred> _M_bad_char; + }; + + template<typename _Pred> + struct __is_std_equal_to : std::false_type { }; + + template<> + struct __is_std_equal_to<std::equal_to<void>> : std::true_type { }; + + // Use __boyer_moore_array_base when pattern consists of narrow characters + // and uses std::equal_to as the predicate. + template<typename _RAIter, typename _Hash, typename _Pred, + typename _Val = typename iterator_traits<_RAIter>::value_type, + typename _Diff = typename iterator_traits<_RAIter>::difference_type> + using __boyer_moore_base_t + = std::conditional_t<sizeof(_Val) == 1 && is_integral<_Val>::value + && __is_std_equal_to<_Pred>::value, + __boyer_moore_array_base<_Diff, 256, _Pred>, + __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>; + + template<typename _RAIter, typename _Hash + = std::hash<typename std::iterator_traits<_RAIter>::value_type>, + typename _BinaryPredicate = std::equal_to<>> + class boyer_moore_searcher + : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> + { + using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; + using typename _Base::__diff_type; + + public: + boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last, + _Hash __hf = _Hash(), + _BinaryPredicate __pred = _BinaryPredicate()); + + template<typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const; + + private: + bool + _M_is_prefix(_RAIter __word, __diff_type __len, + __diff_type __pos) + { + const auto& __pred = this->_M_pred(); + __diff_type __suffixlen = __len - __pos; + for (__diff_type __i = 0; __i < __suffixlen; ++__i) + if (!__pred(__word[__i], __word[__pos + __i])) + return false; + return true; + } + + __diff_type + _M_suffix_length(_RAIter __word, __diff_type __len, + __diff_type __pos) + { + const auto& __pred = this->_M_pred(); + __diff_type __i = 0; + while (__pred(__word[__pos - __i], __word[__len - 1 - __i]) + && __i < __pos) + { + ++__i; + } + return __i; + } + + template<typename _Tp> + __diff_type + _M_bad_char_shift(_Tp __c) const + { return this->_M_lookup(__c, _M_pat_end - _M_pat); } + + _RAIter _M_pat; + _RAIter _M_pat_end; + std::vector<__diff_type> _M_good_suffix; + }; + + template<typename _RAIter, typename _Hash + = std::hash<typename std::iterator_traits<_RAIter>::value_type>, + typename _BinaryPredicate = std::equal_to<>> + class boyer_moore_horspool_searcher + : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> + { + using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; + using typename _Base::__diff_type; + + public: + boyer_moore_horspool_searcher(_RAIter __pat, + _RAIter __pat_end, + _Hash __hf = _Hash(), + _BinaryPredicate __pred + = _BinaryPredicate()) + : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), + _M_pat(__pat), _M_pat_end(__pat_end) + { } + + template<typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const + { + const auto& __pred = this->_M_pred(); + auto __patlen = _M_pat_end - _M_pat; + if (__patlen == 0) + return std::make_pair(__first, __first); + auto __len = __last - __first; + while (__len >= __patlen) + { + for (auto __scan = __patlen - 1; + __pred(__first[__scan], _M_pat[__scan]); --__scan) + if (__scan == 0) + return std::make_pair(__first, + std::next(__first, __patlen)); + auto __shift = _M_bad_char_shift(__first[__patlen - 1]); + __len -= __shift; + __first += __shift; + } + return std::make_pair(__last, __last); + } + + private: + template<typename _Tp> + __diff_type + _M_bad_char_shift(_Tp __c) const + { return this->_M_lookup(__c, _M_pat_end - _M_pat); } + + _RAIter _M_pat; + _RAIter _M_pat_end; + }; + + /// Generator function for default_searcher + template<typename _ForwardIterator, + typename _BinaryPredicate = std::equal_to<>> + inline default_searcher<_ForwardIterator, _BinaryPredicate> + make_default_searcher(_ForwardIterator __pat_first, + _ForwardIterator __pat_last, + _BinaryPredicate __pred = _BinaryPredicate()) + { return { __pat_first, __pat_last, __pred }; } + + /// Generator function for boyer_moore_searcher + template<typename _RAIter, typename _Hash + = std::hash<typename std::iterator_traits<_RAIter>::value_type>, + typename _BinaryPredicate = equal_to<>> + inline boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate> + make_boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last, + _Hash __hf = _Hash(), + _BinaryPredicate __pred = _BinaryPredicate()) + { return { __pat_first, __pat_last, std::move(__hf), std::move(__pred) }; } + + /// Generator function for boyer_moore_horspool_searcher + template<typename _RAIter, typename _Hash + = std::hash<typename std::iterator_traits<_RAIter>::value_type>, + typename _BinaryPredicate = equal_to<>> + inline boyer_moore_horspool_searcher<_RAIter, _Hash, _BinaryPredicate> + make_boyer_moore_horspool_searcher(_RAIter __pat_first, _RAIter __pat_last, + _Hash __hf = _Hash(), + _BinaryPredicate __pred + = _BinaryPredicate()) + { return { __pat_first, __pat_last, std::move(__hf), std::move(__pred) }; } + + template<typename _RAIter, typename _Hash, typename _BinaryPredicate> + boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: + boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end, + _Hash __hf, _BinaryPredicate __pred) + : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), + _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat) + { + auto __patlen = __pat_end - __pat; + if (__patlen == 0) + return; + __diff_type __last_prefix = __patlen - 1; + for (__diff_type __p = __patlen - 1; __p >= 0; --__p) + { + if (_M_is_prefix(__pat, __patlen, __p + 1)) + __last_prefix = __p + 1; + _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p); + } + for (__diff_type __p = 0; __p < __patlen - 1; ++__p) + { + auto __slen = _M_suffix_length(__pat, __patlen, __p); + auto __pos = __patlen - 1 - __slen; + if (!__pred(__pat[__p - __slen], __pat[__pos])) + _M_good_suffix[__pos] = __patlen - 1 - __p + __slen; + } + } + + template<typename _RAIter, typename _Hash, typename _BinaryPredicate> + template<typename _RandomAccessIterator2> + pair<_RandomAccessIterator2, _RandomAccessIterator2> + boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: + operator()(_RandomAccessIterator2 __first, + _RandomAccessIterator2 __last) const + { + auto __patlen = _M_pat_end - _M_pat; + if (__patlen == 0) + return std::make_pair(__first, __first); + const auto& __pred = this->_M_pred(); + __diff_type __i = __patlen - 1; + auto __stringlen = __last - __first; + while (__i < __stringlen) + { + __diff_type __j = __patlen - 1; + while (__j >= 0 && __pred(__first[__i], _M_pat[__j])) + { + --__i; + --__j; + } + if (__j < 0) + return std::make_pair(__first + __i + 1, std::next(__first, + __patlen)); + __i += std::max(_M_bad_char_shift(__first[__i]), + _M_good_suffix[__j]); + } + return std::make_pair(__last, __last); + } + #endif _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index a9b43944770..7dbb533dd83 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -38,6 +38,7 @@ #include <type_traits> #include <utility> #include <bits/enable_special_members.h> +#include <bits/move.h> #include <bits/uses_allocator.h> namespace std _GLIBCXX_VISIBILITY(default) @@ -312,7 +313,7 @@ namespace __variant _M_storage() const { return const_cast<void*>( - static_cast<const void*>(&_M_first._M_storage)); + static_cast<const void*>(std::addressof(_M_first._M_storage))); } union diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index ba4eac1e3f8..2df31ff668e 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -88,6 +88,16 @@ sources = \ new_opnt.cc \ new_opv.cc \ new_opvnt.cc \ + new_opa.cc \ + new_opant.cc \ + new_opva.cc \ + new_opvant.cc \ + del_opa.cc \ + del_opant.cc \ + del_opsa.cc \ + del_opva.cc \ + del_opvant.cc \ + del_opvsa.cc \ pbase_type_info.cc \ pmem_type_info.cc \ pointer_type_info.cc \ @@ -189,6 +199,28 @@ del_opvs.lo: del_opvs.cc del_opvs.o: del_opvs.cc $(CXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $< +# Use special rules for the C++17 sources so that the proper flags are passed. +new_opa.lo: new_opa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opant.lo: new_opant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opva.lo: new_opva.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opvant.lo: new_opvant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opa.lo: del_opa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opant.lo: del_opant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opsa.lo: del_opsa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opva.lo: del_opva.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opvant.lo: del_opvant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opvsa.lo: del_opvsa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< + # AM_CXXFLAGS needs to be in each subdirectory so that it can be # modified in a per-library or per-sub-library way. Need to manually # set this option because CONFIG_CXXFLAGS has to be after diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index 3fb9d16e527..e828ed909ca 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -125,9 +125,11 @@ am__objects_1 = array_type_info.lo atexit_arm.lo atexit_thread.lo \ function_type_info.lo fundamental_type_info.lo guard.lo \ guard_error.lo hash_bytes.lo nested_exception.lo \ new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo \ - pbase_type_info.lo pmem_type_info.lo pointer_type_info.lo \ - pure.lo si_class_type_info.lo tinfo.lo tinfo2.lo vec.lo \ - vmi_class_type_info.lo vterminate.lo + new_opa.lo new_opant.lo new_opva.lo new_opvant.lo del_opa.lo \ + del_opant.lo del_opsa.lo del_opva.lo del_opvant.lo \ + del_opvsa.lo pbase_type_info.lo pmem_type_info.lo \ + pointer_type_info.lo pure.lo si_class_type_info.lo tinfo.lo \ + tinfo2.lo vec.lo vmi_class_type_info.lo vterminate.lo @GLIBCXX_HOSTED_TRUE@am__objects_2 = cp-demangle.lo @ENABLE_VTABLE_VERIFY_TRUE@@VTV_CYGMIN_FALSE@am__objects_3 = \ @ENABLE_VTABLE_VERIFY_TRUE@@VTV_CYGMIN_FALSE@ vtv_stubs.lo @@ -445,6 +447,16 @@ sources = \ new_opnt.cc \ new_opv.cc \ new_opvnt.cc \ + new_opa.cc \ + new_opant.cc \ + new_opva.cc \ + new_opvant.cc \ + del_opa.cc \ + del_opant.cc \ + del_opsa.cc \ + del_opva.cc \ + del_opvant.cc \ + del_opvsa.cc \ pbase_type_info.cc \ pmem_type_info.cc \ pointer_type_info.cc \ @@ -916,6 +928,28 @@ del_opvs.lo: del_opvs.cc del_opvs.o: del_opvs.cc $(CXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $< +# Use special rules for the C++17 sources so that the proper flags are passed. +new_opa.lo: new_opa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opant.lo: new_opant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opva.lo: new_opva.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +new_opvant.lo: new_opvant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opa.lo: del_opa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opant.lo: del_opant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opsa.lo: del_opsa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opva.lo: del_opva.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opvant.lo: del_opvant.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< +del_opvsa.lo: del_opvsa.cc + $(LTCXXCOMPILE) -std=gnu++1z -c $< + install-stdHEADERS: $(std_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(stddir) diff --git a/libstdc++-v3/libsupc++/del_opa.cc b/libstdc++-v3/libsupc++/del_opa.cc new file mode 100644 index 00000000000..889bdb71935 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opa.cc @@ -0,0 +1,54 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> + +#if !_GLIBCXX_HOSTED +// A freestanding C runtime may not provide "free" -- but there is no +// other reasonable way to implement "operator delete". +namespace std +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + extern "C" void free(void*); +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#else +# include <cstdlib> +#endif + +#include "new" + +// The sized deletes are defined in other files. +#pragma GCC diagnostic ignored "-Wsized-deallocation" + +_GLIBCXX_WEAK_DEFINITION void +operator delete(void* ptr, std::align_val_t) _GLIBCXX_USE_NOEXCEPT +{ +#if !_GLIBCXX_HAVE_ALIGNED_ALLOC && _GLIBCXX_HAVE__ALIGNED_MALLOC + _aligned_free (ptr); +#else + std::free(ptr); +#endif +} diff --git a/libstdc++-v3/libsupc++/del_opant.cc b/libstdc++-v3/libsupc++/del_opant.cc new file mode 100644 index 00000000000..1b1919ce927 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opant.cc @@ -0,0 +1,33 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void +operator delete (void *ptr, std::align_val_t al, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +{ + ::operator delete (ptr, al); +} diff --git a/libstdc++-v3/libsupc++/del_opsa.cc b/libstdc++-v3/libsupc++/del_opsa.cc new file mode 100644 index 00000000000..7880efeb279 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opsa.cc @@ -0,0 +1,33 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void +operator delete(void* ptr, std::size_t, std::align_val_t al) _GLIBCXX_USE_NOEXCEPT +{ + ::operator delete (ptr, al); +} diff --git a/libstdc++-v3/libsupc++/del_opva.cc b/libstdc++-v3/libsupc++/del_opva.cc new file mode 100644 index 00000000000..95d2a3f8d24 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opva.cc @@ -0,0 +1,36 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +// The sized deletes are defined in other files. +#pragma GCC diagnostic ignored "-Wsized-deallocation" + +_GLIBCXX_WEAK_DEFINITION void +operator delete[] (void *ptr, std::align_val_t al) _GLIBCXX_USE_NOEXCEPT +{ + ::operator delete (ptr, al); +} diff --git a/libstdc++-v3/libsupc++/del_opvant.cc b/libstdc++-v3/libsupc++/del_opvant.cc new file mode 100644 index 00000000000..5840c8f70e0 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opvant.cc @@ -0,0 +1,33 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void +operator delete[] (void *ptr, std::align_val_t al, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +{ + ::operator delete[] (ptr, al); +} diff --git a/libstdc++-v3/libsupc++/del_opvsa.cc b/libstdc++-v3/libsupc++/del_opvsa.cc new file mode 100644 index 00000000000..61586b06e11 --- /dev/null +++ b/libstdc++-v3/libsupc++/del_opvsa.cc @@ -0,0 +1,33 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void +operator delete[] (void *ptr, std::size_t, std::align_val_t al) _GLIBCXX_USE_NOEXCEPT +{ + ::operator delete[] (ptr, al); +} diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 8e8a3272a8d..477fadc218c 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -79,6 +79,10 @@ namespace std }; #endif +#if __cpp_aligned_new + enum class align_val_t: size_t {}; +#endif + struct nothrow_t { #if __cplusplus >= 201103L @@ -135,6 +139,30 @@ void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +#if __cpp_aligned_new +void* operator new(std::size_t, std::align_val_t) + __attribute__((__externally_visible__)); +void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete(void*, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete(void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void* operator new[](std::size_t, std::align_val_t) + __attribute__((__externally_visible__)); +void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete[](void*, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete[](void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +#if __cpp_sized_deallocation +void operator delete(void*, std::size_t, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +void operator delete[](void*, std::size_t, std::align_val_t) + _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); +#endif // __cpp_sized_deallocation +#endif // __cpp_aligned_new // Default placement versions of operator new. inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc new file mode 100644 index 00000000000..91e53a8b360 --- /dev/null +++ b/libstdc++-v3/libsupc++/new_opa.cc @@ -0,0 +1,85 @@ +// Support routines for the -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include <stdlib.h> +#include <bits/exception_defines.h> +#include "new" + +using std::new_handler; +using std::bad_alloc; + +#if !_GLIBCXX_HAVE_ALIGNED_ALLOC +#if _GLIBCXX_HAVE__ALIGNED_MALLOC +#define aligned_alloc(al,sz) _aligned_malloc(sz,al) +#elif _GLIBCXX_HAVE_POSIX_MEMALIGN +static inline void* +aligned_alloc (std::size_t al, std::size_t sz) +{ + void *ptr; + // The value of alignment shall be a power of two multiple of sizeof(void *). + if (al < sizeof(void*)) + al = sizeof(void*); + int ret = posix_memalign (&ptr, al, sz); + if (ret == 0) + return ptr; + return nullptr; +} +#elif _GLIBCXX_HAVE_MEMALIGN +#include <malloc.h> +#define aligned_alloc memalign +#else +// The C library doesn't provide any aligned allocation functions, declare +// aligned_alloc and get a link failure if aligned new is used. +extern "C" void *aligned_alloc(std::size_t, std::size_t); +#endif +#endif + +_GLIBCXX_WEAK_DEFINITION void * +operator new (std::size_t sz, std::align_val_t al) +{ + void *p; + std::size_t align = (std::size_t)al; + + /* malloc (0) is unpredictable; avoid it. */ + if (sz == 0) + sz = 1; + +#if _GLIBCXX_HAVE_ALIGNED_ALLOC + /* C11: the value of size shall be an integral multiple of alignment. */ + if (std::size_t rem = sz & (align - 1)) + sz += align - rem; +#endif + + while (__builtin_expect ((p = aligned_alloc (align, sz)) == 0, false)) + { + new_handler handler = std::get_new_handler (); + if (! handler) + _GLIBCXX_THROW_OR_ABORT(bad_alloc()); + handler (); + } + + return p; +} diff --git a/libstdc++-v3/libsupc++/new_opant.cc b/libstdc++-v3/libsupc++/new_opant.cc new file mode 100644 index 00000000000..1c6ccab809e --- /dev/null +++ b/libstdc++-v3/libsupc++/new_opant.cc @@ -0,0 +1,42 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include <bits/exception_defines.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void* +operator new(std::size_t sz, std::align_val_t al, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT +{ + __try + { + return operator new(sz, al); + } + __catch(...) + { + return 0; + } +} diff --git a/libstdc++-v3/libsupc++/new_opva.cc b/libstdc++-v3/libsupc++/new_opva.cc new file mode 100644 index 00000000000..7109431b269 --- /dev/null +++ b/libstdc++-v3/libsupc++/new_opva.cc @@ -0,0 +1,33 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void* +operator new[] (std::size_t sz, std::align_val_t al) +{ + return ::operator new(sz, al); +} diff --git a/libstdc++-v3/libsupc++/new_opvant.cc b/libstdc++-v3/libsupc++/new_opvant.cc new file mode 100644 index 00000000000..2b295472120 --- /dev/null +++ b/libstdc++-v3/libsupc++/new_opvant.cc @@ -0,0 +1,42 @@ +// Boilerplate support routines for -*- C++ -*- dynamic memory management. + +// Copyright (C) 1997-2016 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <bits/c++config.h> +#include <bits/exception_defines.h> +#include "new" + +_GLIBCXX_WEAK_DEFINITION void* +operator new[] (std::size_t sz, std::align_val_t al, const std::nothrow_t&) + _GLIBCXX_USE_NOEXCEPT +{ + __try + { + return ::operator new[](sz, al); + } + __catch(...) + { + return 0; + } +} diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 977e63fff47..8c29760e01c 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -920,10 +920,10 @@ class SingleObjContainerPrinter(object): class StdExpAnyPrinter(SingleObjContainerPrinter): - "Print a std::experimental::any" + "Print a std::any or std::experimental::any" def __init__ (self, typename, val): - self.typename = 'std::experimental::any' + self.typename = re.sub('^std::experimental::fundamentals_v\d::', 'std::experimental::', typename, 1) self.val = val self.contained_type = None contained_value = None @@ -932,11 +932,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): if mgr != 0: func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t')))) if not func: - raise ValueError("Invalid function pointer in std::experimental::any") + raise ValueError("Invalid function pointer in %s" % self.typename) rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\({0}::_Op, {0} const\*, {0}::_Arg\*\)""".format(typename) m = re.match(rx, func.function.name) if not m: - raise ValueError("Unknown manager function in std::experimental::any") + raise ValueError("Unknown manager function in %s" % self.typename) # FIXME need to expand 'std::string' so that gdb.lookup_type works mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1)) @@ -948,7 +948,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): elif '::_Manager_external' in mgrname: valptr = self.val['_M_storage']['_M_ptr'] else: - raise ValueError("Unknown manager function in std::experimental::any") + raise ValueError("Unknown manager function in %s" % self.typename) contained_value = valptr.cast(self.contained_type.pointer()).dereference() visualizer = gdb.default_visualizer(contained_value) super(StdExpAnyPrinter, self).__init__ (contained_value, visualizer) @@ -963,11 +963,11 @@ class StdExpAnyPrinter(SingleObjContainerPrinter): return desc + valtype class StdExpOptionalPrinter(SingleObjContainerPrinter): - "Print a std::experimental::optional" + "Print a std::optional or std::experimental::optional" def __init__ (self, typename, val): valtype = self._recognize (val.type.template_argument(0)) - self.typename = "std::experimental::optional<%s>" % valtype + self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % valtype, typename, 1) self.val = val contained_value = val['_M_payload'] if self.val['_M_engaged'] else None visualizer = gdb.default_visualizer (val['_M_payload']) @@ -980,8 +980,44 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter): return self.typename + " containing " + self.visualizer.to_string () return self.typename +class StdVariantPrinter(SingleObjContainerPrinter): + "Print a std::variant" + + def __init__(self, typename, val): + alternatives = self._template_args(val) + self.alts = alternatives + self.typename = "%s<%s>" % (typename, ', '.join([self._recognize(alt) for alt in alternatives])) + self.index = val['_M_index'] + if self.index >= len(alternatives): + self.contained_type = None + contained_value = None + visualizer = None + else: + self.contained_type = alternatives[int(self.index)] + addr = val['_M_first']['_M_storage'].address + contained_value = addr.cast(self.contained_type.pointer()).dereference() + visualizer = gdb.default_visualizer(contained_value) + super (StdVariantPrinter, self).__init__(contained_value, visualizer) + + def _template_args(self, val): + n = 0 + args = () + while True: + try: + args += (val.type.template_argument(n),) + except: + return args + n += 1 + + def to_string(self): + if self.contained_value is None: + return "%s [no value]" % self.typename + if hasattr(self.visualizer, 'children'): + return "%s [alternative %d] %s" % (self.typename, self.index, self.visualizer.to_string()) + return self.typename + class StdExpStringViewPrinter: - "Print a std::experimental::basic_string_view" + "Print a std::basic_string_view or std::experimental::basic_string_view" def __init__ (self, typename, val): self.val = val @@ -1385,7 +1421,7 @@ def build_libstdcxx_dictionary (): libstdcxx_printer.add('std::__debug::unique_ptr', UniquePointerPrinter) libstdcxx_printer.add('std::__debug::vector', StdVectorPrinter) - # These are the TR1 and C++0x printers. + # These are the TR1 and C++11 printers. # For array - the default GDB pretty-printer seems reasonable. libstdcxx_printer.add_version('std::', 'shared_ptr', SharedPointerPrinter) libstdcxx_printer.add_version('std::', 'weak_ptr', SharedPointerPrinter) @@ -1411,7 +1447,7 @@ def build_libstdcxx_dictionary (): libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset', Tr1UnorderedSetPrinter) - # These are the C++0x printer registrations for -D_GLIBCXX_DEBUG cases. + # These are the C++11 printer registrations for -D_GLIBCXX_DEBUG cases. # The tr1 namespace printers do not seem to have any debug # equivalents, so do no register them. libstdcxx_printer.add('std::__debug::unordered_map', @@ -1438,6 +1474,16 @@ def build_libstdcxx_dictionary (): libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11::', 'path', StdExpPathPrinter) + # C++17 components + libstdcxx_printer.add_version('std::', + 'any', StdExpAnyPrinter) + libstdcxx_printer.add_version('std::', + 'optional', StdExpOptionalPrinter) + libstdcxx_printer.add_version('std::', + 'basic_string_view', StdExpStringViewPrinter) + libstdcxx_printer.add_version('std::', + 'variant', StdVariantPrinter) + # Extensions. libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter) diff --git a/libstdc++-v3/testsuite/20_util/function_objects/searchers.cc b/libstdc++-v3/testsuite/20_util/function_objects/searchers.cc new file mode 100644 index 00000000000..1c7276207d9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function_objects/searchers.cc @@ -0,0 +1,138 @@ +// Copyright (C) 2014-2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } + +#include <functional> +#include <cstring> +#ifdef _GLIBCXX_USE_WCHAR_T +# include <cwchar> +#endif +#include <algorithm> +#include <testsuite_hooks.h> + +using std::make_default_searcher; +using std::make_boyer_moore_searcher; +using std::make_boyer_moore_horspool_searcher; + +void +test01() +{ + const char s[] = { 'a', (char)-97, 'a', '\0' }; + const char* needles[] = { + s, "", "a", "aa", "aaa", "ab", "cd", "abcd", "abcdabcd", "abcabcd" + }; + const char* haystacks[] = { + s, "", "a", "aa", "aaa", "ab", "cd", "abcd", "abcdabcd", "abcabcd", + "aaaaaaa", "aabaa", "aaacab", "cdabcdab", "abcdabcd", "xyzabcdxyz" + }; + + for (auto n : needles) + { + auto ne = n + std::strlen(n); + auto d = make_default_searcher(n, ne); + auto bm = make_boyer_moore_searcher(n, ne); + auto bmh = make_boyer_moore_horspool_searcher(n, ne); + for (auto h : haystacks) + { + auto he = h + std::strlen(h); + auto res = std::search(h, he, n, ne); + auto d_res = d(h, he); + VERIFY( d_res.first == res ); + auto bm_res = bm(h, he); + VERIFY( bm_res.first == res ); + auto bmh_res = bmh(h, he); + VERIFY( bmh_res.first == res ); + } + } +} + +void +test02() +{ +#ifdef _GLIBCXX_USE_WCHAR_T + const wchar_t s[] = { L'a', (wchar_t)-97, L'a', L'\0' }; + const wchar_t* needles[] = { + s, L"", L"a", L"aa", L"aaa", L"ab", L"cd", L"abcd", L"abcdabcd", L"abcabcd" + }; + const wchar_t* haystacks[] = { + s, L"", L"a", L"aa", L"aaa", L"ab", L"cd", L"abcd", L"abcdabcd", L"abcabcd", + L"aaaaaaa", L"aabaa", L"aaacab", L"cdabcdab", L"abcdabcd", L"xyzabcdxyz" + }; + + for (auto n : needles) + { + auto ne = n + std::wcslen(n); + auto d = make_default_searcher(n, ne); + auto bm = make_boyer_moore_searcher(n, ne); + auto bmh = make_boyer_moore_horspool_searcher(n, ne); + for (auto h : haystacks) + { + auto he = h + std::wcslen(h); + auto res = std::search(h, he, n, ne); + auto d_res = d(h, he); + VERIFY( d_res.first == res ); + auto bm_res = bm(h, he); + VERIFY( bm_res.first == res ); + auto bmh_res = bmh(h, he); + VERIFY( bmh_res.first == res ); + } + } +#endif +} + +void +test03() +{ + // custom predicate + struct + { + static unsigned char + norm(unsigned char c) { return std::isalnum(c) ? c : '#'; } + + // equality + bool operator()(char l, char r) const { return norm(l) == norm(r); } + + // hash + std::size_t operator()(char c) const { return std::hash<char>{}(norm(c)); } + } eq; + + const char* needle = " foo 123 "; + const char* haystack = "*****foo*123******"; + const char* ne = needle + std::strlen(needle); + const char* he = haystack + std::strlen(haystack); + + auto d = make_default_searcher(needle, ne, eq); + auto bm = make_boyer_moore_searcher(needle, ne, eq, eq); + auto bmh = make_boyer_moore_horspool_searcher(needle, ne, eq, eq); + + auto res = std::search(haystack, he, needle, ne, eq); + auto d_res = d(haystack, he); + VERIFY( d_res.first == res ); + auto bm_res = bm(haystack, he); + VERIFY( bm_res.first == res ); + auto bmh_res = bmh(haystack, he); + VERIFY( bmh_res.first == res ); +} + +int +main() +{ + test01(); + test02(); + test03(); +} diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc new file mode 100644 index 00000000000..ec72b826a53 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc @@ -0,0 +1,132 @@ +// Copyright (C) 2016 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-options "-std=gnu++17" } + +#include <memory> +#include <testsuite_hooks.h> +#include <string> +#include <array> + +int del_count = 0; + +struct DelCount +{ + ~DelCount() { ++del_count; } +}; + +void test01() +{ + char test_data[] = "123456"; + std::uninitialized_default_construct(std::begin(test_data), + std::end(test_data)); + VERIFY(std::string(test_data) == "123456"); +} + +void test02() +{ + char test_data[] = "123456"; + std::uninitialized_value_construct(std::begin(test_data), + std::end(test_data)); + VERIFY(std::string(test_data, 6) == std::string("\0\0\0\0\0\0", 6)); +} + +void test03() +{ + char test_data[] = "123456"; + std::uninitialized_default_construct_n(std::begin(test_data), 6); + VERIFY(std::string(test_data) == "123456"); +} + +void test04() +{ + char test_data[] = "123456"; + std::uninitialized_value_construct_n(std::begin(test_data), 6); + VERIFY(std::string(test_data, 6) == std::string("\0\0\0\0\0\0", 6)); +} + +void test05() +{ + del_count = 0; + DelCount* x = (DelCount*)malloc(sizeof(DelCount)); + new (x) DelCount; + std::destroy_at(&x[0]); + VERIFY(del_count == 1); + del_count = 0; + free(x); +} + +void test06() +{ + del_count = 0; + DelCount* x = (DelCount*)malloc(sizeof(DelCount)*10); + for (int i = 0; i < 10; ++i) new (x+i) DelCount; + std::destroy(x, x+10); + VERIFY(del_count == 10); + del_count = 0; + free(x); +} + +void test07() +{ + del_count = 0; + DelCount* x = (DelCount*)malloc(sizeof(DelCount)*10); + for (int i = 0; i < 10; ++i) new (x+i) DelCount; + std::destroy_n(x, 10); + VERIFY(del_count == 10); + del_count = 0; + free(x); +} + +void test08() +{ + std::vector<std::unique_ptr<int>> source; + for (int i = 0; i < 10; ++i) source.push_back(std::make_unique<int>(i)); + std::unique_ptr<int>* target = + (std::unique_ptr<int>*)malloc(sizeof(std::unique_ptr<int>)*10); + std::uninitialized_move(source.begin(), source.end(), target); + for (const auto& x : source) VERIFY(!x); + for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i))); + std::destroy_n(target, 10); + free(target); +} + +void test09() +{ + std::vector<std::unique_ptr<int>> source; + for (int i = 0; i < 10; ++i) source.push_back(std::make_unique<int>(i)); + std::unique_ptr<int>* target = + (std::unique_ptr<int>*)malloc(sizeof(std::unique_ptr<int>)*10); + std::uninitialized_move_n(source.begin(), 10, target); + for (const auto& x : source) VERIFY(!x); + for (int i = 0; i < 10; ++i) VERIFY(bool(*(target+i))); + std::destroy_n(target, 10); + free(target); +} + +int main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + test06(); + test07(); + test08(); + test09(); +} diff --git a/libstdc++-v3/testsuite/21_strings/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/21_strings/debug/iterator_self_move_assign_neg.cc index 6d10bb19e16..f481115471e 100644 --- a/libstdc++-v3/testsuite/21_strings/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/debug/iterator_self_move_assign_neg.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // +// { dg-do run { xfail *-*-* } } // { dg-require-debug-mode "" } // { dg-options "-std=gnu++11" } -// { dg-do run { xfail *-*-* } } #include <debug/string> diff --git a/libstdc++-v3/testsuite/21_strings/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/21_strings/debug/self_move_assign_neg.cc index 360f0776637..a72cb871f86 100644 --- a/libstdc++-v3/testsuite/21_strings/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/21_strings/debug/self_move_assign_neg.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // +// { dg-do run { xfail *-*-* } } // { dg-require-debug-mode "" } // { dg-options "-std=gnu++11" } -// { dg-do run { xfail *-*-* } } #include <debug/string> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc index a0000956b24..78ddb5cb61f 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf16/requirements/1.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-cstdint "" } // { dg-do compile { target c++11 } } +// { dg-require-cstdint "" } #include <codecvt> #include <type_traits> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc index 12ac516637e..a9c50efa282 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8/requirements/1.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-cstdint "" } // { dg-do compile { target c++11 } } +// { dg-require-cstdint "" } #include <codecvt> #include <type_traits> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc index 4ebb6a424e0..0d569786ce5 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/codecvt_utf8_utf16/requirements/1.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-cstdint "" } // { dg-do compile { target c++11 } } +// { dg-require-cstdint "" } #include <codecvt> #include <type_traits> diff --git a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc index a20feb5ce94..86fdf0d391a 100644 --- a/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc +++ b/libstdc++-v3/testsuite/22_locale/codecvt/utf8.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-cstdint "" } // { dg-do run { target c++11 } } +// { dg-require-cstdint "" } #include <locale> #include <iterator> diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/unicode.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/unicode.cc index 76f730ab875..906ddf199a6 100644 --- a/libstdc++-v3/testsuite/22_locale/locale/cons/unicode.cc +++ b/libstdc++-v3/testsuite/22_locale/locale/cons/unicode.cc @@ -1,5 +1,5 @@ -// { dg-require-iconv "ISO-8859-1" } // { dg-do run { target c++11 } } +// { dg-require-iconv "ISO-8859-1" } // Copyright (C) 2006-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc index c866464a566..dc3442dae7f 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc index 92fc1e7bcab..5deed88f2c2 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc index a52eb4194ce..761e8e99505 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/assign3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc index 2443b0d6ce5..637882fabb7 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc index c73adb736b5..46b0ee1a18d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc index 297d9b312ab..7b52b3d523e 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc index 5636fd4581b..2b28689eef1 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc index 956f696797f..7e2696e4d2e 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc index 9ad8493093b..1c038167b3d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc index 7fdf443b52a..a74d292c2ea 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/insert5_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc index 28e2e64fec5..64bc35a9c3a 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc index b378cd2aec5..576c726de92 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc index 51e0cb182f1..71819bb217a 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/debug/shrink_to_fit.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc index ed5caceef98..d127fb0c964 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct1_neg.cc index cd0864f003a..9a970943793 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <forward_list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct2_neg.cc index a9d4bda766f..7a47cd23b58 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <forward_list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct3_neg.cc index b62204402e7..63b489109d1 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <forward_list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc index 59e03be4a91..ae90415d5d8 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after1_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc index a5a274380bc..6234de0df4d 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after2_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc index dc14635415e..813fbede964 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after3_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc index 156db150647..3ef323329c6 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after4_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc index 68f7fe82d42..376ac3727c6 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after5_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc index 5fd14962e4c..ec0186d8624 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after6_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc index ecf60ffdba1..b7f0323a70f 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after7_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc index 3cfa7dc5d59..81fe1428899 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after8_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc index ee7db912e90..11fbca0f1be 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/erase_after9_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc index ae2f39940cc..1e9f245bf38 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after1_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc index f1fce3b744d..d2ea77ddf85 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after2_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc index 35706b809ba..ca94bfec19c 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after3_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc index 2898090c49a..78495313c04 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/insert_after4_neg.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // +// { dg-do run { target c++11 xfail *-*-* } } // { dg-require-debug-mode "" } // { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } -// { dg-do run { target c++11 xfail *-*-* } } #include <forward_list> #include <iterator> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc index bc197a57c41..37f395728a6 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <forward_list> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc index e50d37f0e9e..505d654121e 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <forward_list> diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc index 5f74f9cf23e..0222e1446b3 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after1_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc index 1416d616c15..87a467149ee 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after2_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc index 96b8290d87a..0735789ccc6 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after3_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc index cfcc1b26dfa..15888983ce4 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after4_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2010-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc index 5bcf38d27a2..14217b21c5d 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc index bf49d4337bf..ca5a3567872 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc index 6e8b067c266..d7c670ce9d5 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc @@ -1,5 +1,5 @@ -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc index cde326f780a..1eee86fc317 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc index 19fbbdecd80..41eb33ed6c5 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc index cc9d9ee3755..e0a4fc15aa9 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc index ee4c237a107..fa60f5fc8e9 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc index 650cee48915..a56ebcb6d6d 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc index 1e5408c2072..bffb701b371 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc index 57ce024b312..54bd5cb8086 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc index 58628a47e3e..4428aae7ab2 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc index f62bd3c2acf..0d93f5ac851 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc index 21f2781534d..cec84d02655 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert5_neg.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // +// { dg-do run { xfail *-*-* } } // { dg-require-debug-mode "" } // { dg-options "-D_GLIBCXX_DEBUG_PEDANTIC" } -// { dg-do run { xfail *-*-* } } #include <list> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc index 8b0639bacdb..31f4f370c5c 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc index 7ab40ba6d15..833e95711f5 100644 --- a/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc index ad4fb4499a6..ef12b3406bc 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc index b584060f5eb..e2589e85f2f 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc index e55c6665a68..f948438ff8f 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc index 2f7d8eb34f7..6732d18007d 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc index f8ef1d2c5d1..351d9377de7 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc index 582ef2e844e..46e1e078858 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc index 39fda63971c..58549e61fdd 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc index cc3e0e6c164..fa30d1bd1a6 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc index 4eb690d71d0..82233453691 100644 --- a/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/map/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc index bda4b5ca278..a226e392bd9 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc index 2f37742bdaa..d73daa96dcd 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc index 9643e7fc379..89b9432d7c0 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc index 747cae43375..998846025e1 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc index 2fdb8383c15..e0dc28dbfae 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc index ed0509c8e98..edecbad6fe2 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc index 3ccd5e2bcd7..1c860b439fe 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc index 8062a986eb9..6160a572410 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> diff --git a/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc index 4f3c5f30be5..301c8844359 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <map> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc index b543590aecd..9b0f95db60b 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc index dcc5c84de43..bf167e25a5f 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc index 2592f1e8e6c..87ed3ae95a0 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc index 025df918443..743024050a0 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc index df2f9c55da7..275703ee1f0 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc index 7731c4bc638..ee92d388776 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc index 7c3ff360675..3182dfccd41 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc index 92ea5df3bdb..3f3cacd8179 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> diff --git a/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc index 4c5ed569dd9..e6b6fbc64b1 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc index de7cfb6267f..01dae77720a 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc index b10afb94f89..0c6504d08ef 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc index dffab017364..366d9bd84ab 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc index e8b2b5cf4f4..3038ebbfddd 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc index 35819e53785..81eaaf55ff4 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc index 2186b628b0f..699e5562915 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc index 26ba95318b5..6df317da578 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc index 4ce33c74734..171cbc72752 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> diff --git a/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc index 5d644301863..b2f022c6d14 100644 --- a/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/set/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc index e77cc008172..6b00c818a91 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc index 3529123744c..ca9e7d242bf 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc index 3d3a8822d94..26880d0d740 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/begin2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc index efe3f41d134..a8d856ff5bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/bucket_size_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc index 4da34e4ce4a..016ae3e93c4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cbegin_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc index ef59af60716..318f4e925cc 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/cend_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc index 44a8ac9d4a6..280773029f9 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc index a83ffbd790e..3bca414fb49 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc index d7be31fff70..db865ee0ba2 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc index 0425c3c1e03..cc0e37fd33e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc index 630da5118aa..9f129ce3dfd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/end2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc index b1831fc7514..dde90d1eb0e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc index f162cf5ac21..e053ec81b3e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc index 282f4681982..974e55d417e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc index 8cf90df6164..1bbbaa38d37 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc index 053ae09ad04..3965d8379bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc index 916245b2bcd..252fb655c61 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc index e28d180b1f7..7044bc66c33 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/max_load_factor_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc index 5e50f8e6fc5..0e53680da3e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc index 13c8798e48e..73c433ec5fd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc index e092db9f26a..d532f5a6e68 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc index ebc33564f11..9dad84f4a65 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc index 5bba00e046a..d22651e51f6 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc index 761ec975309..51fb6c6824e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc index 3d3a8822d94..26880d0d740 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/begin2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc index efe3f41d134..a8d856ff5bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/bucket_size_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc index 4da34e4ce4a..016ae3e93c4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cbegin_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc index ef59af60716..318f4e925cc 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/cend_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc index f1f1f730285..348f89a073d 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc index 52b31cc5cc0..1a11da2e93f 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc index a6da25341fe..ff7708d4d46 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc index 0425c3c1e03..cc0e37fd33e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc index 630da5118aa..9f129ce3dfd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/end2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc index 7e3e66f0440..80619e135e3 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc index d00b90d0337..f9dfa53ac69 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc index ed26dfe6f83..673a19190ac 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc index 39ae989961e..fccaa7790ea 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc index aa6afde837a..33c4e5d1a73 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc index eb56977395c..c4dff78fcbb 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc index eeba90938a5..45715d49efb 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/max_load_factor_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc index 146ba9af7c0..e4294ccd44f 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc index 87a15bbcfd3..38720349e59 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc index 65a8d0a15eb..bd5ff47b2e2 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc index f4b52749b22..f9eae0e90bb 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_map> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc index c0be76ed974..aa7f818379f 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc index 61e1b2b1411..96a0df277a4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc index e619e92d9a0..bf2019dc489 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/begin2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc index f59b8b8162d..ed2b990d065 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/bucket_size_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc index 30f7161111a..b7b38256c8b 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cbegin_neg.cc @@ -15,8 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } + #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc index f335e0a4a60..f566ec3e8ac 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/cend_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc index 58c9e52b500..2ad5ff1c09a 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc index f00c3e35fe6..a8b2b64cca4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc index df49bf7ac44..206876aa3bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc index c31100123b0..69393d23897 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc index beeb3567f63..eea80eda3dd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/end2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc index 9f9437d0821..28daab54dc3 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc index 5c95a90f8ab..5dec12dc7ab 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc index 970b1285aad..b10b59dc5f6 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc index eb84e0f83c5..cb500a0413c 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc index 37d7e86a0fb..cb678ddffef 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc index 0255fbf3681..dbcecc809ee 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc index 9db1f40a601..d7e31e63a38 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/max_load_factor_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc index 053357efbbb..4750d080c0e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc index c5264e3a815..d5e0a8e6612 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc index b3ba7365541..66670469e2a 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc index 44f236fb6cf..927ee3b2ae8 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc index 82cda7ff430..305585859ba 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc index d30e9c2244e..ed0519fce21 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc index c308f9b1f96..c0741356b48 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/begin2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc index faaeffc8874..25436014e34 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/bucket_size_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc index d71399a3206..161c29c4741 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cbegin_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc index b1f22a95c7d..f1fa407ba7a 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/cend_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc index 6df1e2fa4c1..6eb11cdfea1 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc index 14582ff206e..01a4479fff8 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc index 6c025789c00..4be9f40cebd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc index b4e0f471f3a..a57d4a96b6e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc index 20c8f5aa909..05a9fcb60be 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/end2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc index 07de84c56b0..6c9de873ddf 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc index 2b61e9f539c..68b1a89dae4 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc index f51d2305235..402b5e6c6de 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc index efef04a09a3..15debce5525 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc index 8f66931e720..21ee9415499 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc index 70a3e26fa29..ee516d81162 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc index 22e3ffcc160..bf5a09bfe07 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/max_load_factor_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc index 2f973a650d3..f48d7ee0113 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc index 3a70fe6aea3..5d45df2d680 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc index bf784d135a3..171dbbf3fb9 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc index 212e9087d31..04e8c52b0ae 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <unordered_set> #include <debug/unordered_checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc index bcd548c8283..fd94c78407a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc @@ -17,8 +17,8 @@ // 23.2.5 class vector<bool> [lib.vector.bool] -// { dg-skip-if "" { powerpc64-*-freebsd* } { "*" } { "" } } // { dg-do run { xfail *-*-darwin8.[0-4].* } } +// { dg-skip-if "" { powerpc64-*-freebsd* } { "*" } { "" } } #include <vector> #include <stdexcept> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc index 462ad0e1a8a..6f5390e7d6e 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/52433.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/52433 diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc index d0fb7fc180f..bb9b35e8ad8 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/57779_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc index ab8e7f65a2e..788ce2e20f0 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/60499.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile { target c++11 } } +// { dg-require-debug-mode "" } // PR libstdc++/60499 diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc index ae205be41d5..51ebc84041e 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/60587_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } // PR libstdc++/60587 diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc index 9b0866d57cd..9ee2067ed1a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc index aca8657d31a..974c80a16b4 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc index a6c36bb2c92..ac4aabd553d 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/assign3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc index 195dbce98ee..e8f791825ce 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/bool/shrink_to_fit.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc index 723cce0c63e..0e51ca32514 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc index 24e659f662e..5c91dadf00a 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc index 245c6bfd7b0..63b3e1adf88 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/construct3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc index c43e3add476..9d09983d040 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert1_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc index 80b8e171ea5..4d8632c8e9e 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert2_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc index 000643d2ee5..6514cca3ef5 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert3_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc index ee65e6f64a8..1cb29ecf8f3 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/insert5_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> #include <debug/checks.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc index bc293b2624c..c6f238976ed 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc index b843ed5077e..d82b6b73d27 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/self_move_assign_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc b/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc index d41145e9203..0bd161ac587 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/debug/shrink_to_fit.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { target c++11 xfail *-*-* } } +// { dg-require-debug-mode "" } #include <vector> diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc index 1554df0d97f..08a3170ee58 100644 --- a/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/debug/irreflexive.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do compile } +// { dg-require-debug-mode "" } #include <algorithm> diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc index 1ebc3bde87e..52076aaf4b8 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. // -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <algorithm> diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/complexity.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/complexity.cc index 39999468b1d..d7e658a86c0 100644 --- a/libstdc++-v3/testsuite/25_algorithms/pop_heap/complexity.cc +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/complexity.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. +// { dg-do run { target c++11 } } // { dg-require-normal-mode "" } // { dg-require-cmath "" } -// { dg-do run { target c++11 } } #include <cmath> #include <random> diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc index e30533f7629..5bc2d99dd03 100644 --- a/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc @@ -17,8 +17,8 @@ // 25.3.6 Heap operations [lib.alg.heap.operations] -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <algorithm> #include <functional> diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty_neg.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty_neg.cc index 358fb90f415..96c1ab97327 100644 --- a/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty_neg.cc +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty_neg.cc @@ -17,8 +17,8 @@ // 25.3.6 Heap operations [lib.alg.heap.operations] -// { dg-require-debug-mode "" } // { dg-do run { xfail *-*-* } } +// { dg-require-debug-mode "" } #include <algorithm> diff --git a/libstdc++-v3/testsuite/25_algorithms/push_heap/complexity.cc b/libstdc++-v3/testsuite/25_algorithms/push_heap/complexity.cc index c7c049c81c9..089512b1472 100644 --- a/libstdc++-v3/testsuite/25_algorithms/push_heap/complexity.cc +++ b/libstdc++-v3/testsuite/25_algorithms/push_heap/complexity.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. +// { dg-do run { target c++11 } } // { dg-require-normal-mode "" } // { dg-require-cmath "" } -// { dg-do run { target c++11 } } #include <cmath> #include <random> diff --git a/libstdc++-v3/testsuite/25_algorithms/sort_heap/complexity.cc b/libstdc++-v3/testsuite/25_algorithms/sort_heap/complexity.cc index bb93780ffd0..cfcaae9606a 100644 --- a/libstdc++-v3/testsuite/25_algorithms/sort_heap/complexity.cc +++ b/libstdc++-v3/testsuite/25_algorithms/sort_heap/complexity.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-cmath "" } // { dg-do run { target c++11 } } +// { dg-require-cmath "" } #include <cmath> #include <random> diff --git a/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc index 40cf7529c03..582ba35528f 100644 --- a/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc +++ b/libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc @@ -22,9 +22,8 @@ // equivalent and interchangable. Currently however, cin.rdbuf()->sungetc() // only returns characters that were read with cin.rdbuf()->sbumpc() -// { dg-require-fileio "" } - // { dg-do run { xfail *-*-* } } +// { dg-require-fileio "" } #include <iostream> #include <cstdio> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/60658.cc b/libstdc++-v3/testsuite/29_atomics/atomic/60658.cc index 1524a570242..2daa2dcf0ff 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/60658.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/60658.cc @@ -1,5 +1,5 @@ -// { dg-require-atomic-builtins "" } // { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } // Copyright (C) 2014-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc index 06749a4d1ba..d4913282eac 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc @@ -1,6 +1,6 @@ +// { dg-do compile { target c++11 } } // { dg-require-atomic-builtins "" } // { dg-options "-Wno-pedantic" } -// { dg-do compile { target c++11 } } // Copyright (C) 2014-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/62259.cc b/libstdc++-v3/testsuite/29_atomics/atomic/62259.cc index a98b332c177..37d84adaf43 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/62259.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/62259.cc @@ -15,9 +15,9 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. +// { dg-do compile { target c++11 } } // { dg-require-atomic-builtins "" } // { dg-require-cstdint "" } -// { dg-do compile { target c++11 } } #include <atomic> #include <cstdint> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc b/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc index 7895b15d644..4a8369da474 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/64658.cc @@ -15,8 +15,8 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-require-atomic-builtins "" } // { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } #include <atomic> #include <testsuite_hooks.h> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/49445.cc b/libstdc++-v3/testsuite/29_atomics/atomic/cons/49445.cc index 556bd0b09f1..f4445dee22f 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/49445.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/49445.cc @@ -1,5 +1,5 @@ -// { dg-require-atomic-builtins "" } // { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/operators/51811.cc b/libstdc++-v3/testsuite/29_atomics/atomic/operators/51811.cc index a1ec8ecf401..9aa7cb054f3 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/operators/51811.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/operators/51811.cc @@ -1,5 +1,5 @@ -// { dg-require-atomic-builtins "" } // { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc index e73c1bb31cc..1535454fc26 100644 --- a/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc +++ b/libstdc++-v3/testsuite/29_atomics/atomic/operators/pointer_partial_void.cc @@ -1,5 +1,5 @@ -// { dg-require-atomic-builtins "" } // { dg-do run { target c++11 } } +// { dg-require-atomic-builtins "" } // Copyright (C) 2012-2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/ext/special_functions/conf_hyperg/check_nan.cc b/libstdc++-v3/testsuite/ext/special_functions/conf_hyperg/check_nan.cc index d6108d5fd4b..6c4f8faad92 100644 --- a/libstdc++-v3/testsuite/ext/special_functions/conf_hyperg/check_nan.cc +++ b/libstdc++-v3/testsuite/ext/special_functions/conf_hyperg/check_nan.cc @@ -1,7 +1,7 @@ +// { dg-do run { target c++11 } } // { dg-require-c-std "" } // { dg-add-options ieee } // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } -// { dg-do run { target c++11 } } // Copyright (C) 2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_nan.cc b/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_nan.cc index 8806a3c2b1d..31b81a69381 100644 --- a/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_nan.cc +++ b/libstdc++-v3/testsuite/ext/special_functions/hyperg/check_nan.cc @@ -1,7 +1,7 @@ +// { dg-do run { target c++11 } } // { dg-require-c-std "" } // { dg-add-options ieee } // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" } -// { dg-do run { target c++11 } } // Copyright (C) 2016 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/util/debug/checks.h b/libstdc++-v3/testsuite/util/debug/checks.h index 5a40608acaa..872fa1a5fe4 100644 --- a/libstdc++-v3/testsuite/util/debug/checks.h +++ b/libstdc++-v3/testsuite/util/debug/checks.h @@ -53,6 +53,19 @@ namespace __gnu_test } }; + template<> + struct generate_unique<bool> + { + typedef bool value_type; + + value_type build() + { + static value_type _S_; + _S_ = !_S_; + return _S_; + } + }; + template<typename _Tp1, typename _Tp2> struct generate_unique<std::pair<_Tp1, _Tp2> > { diff --git a/maintainer-scripts/ChangeLog b/maintainer-scripts/ChangeLog index efbba22f2df..c3182466ee9 100644 --- a/maintainer-scripts/ChangeLog +++ b/maintainer-scripts/ChangeLog @@ -1,3 +1,9 @@ +2016-09-04 Gerald Pfeifer <gerald@pfeifer.com> + + PR documentation/50642 + * update_web_docs_svn (CSS): Introduce. + Have generated files refer to it. + 2016-08-17 Martin Liska <mliska@suse.cz> * branch_changer.py: Describe the script. Add sample usage diff --git a/maintainer-scripts/update_web_docs_svn b/maintainer-scripts/update_web_docs_svn index 46e34d10fe4..0107851dcdd 100755 --- a/maintainer-scripts/update_web_docs_svn +++ b/maintainer-scripts/update_web_docs_svn @@ -28,6 +28,8 @@ MANUALS="cpp libiberty porting" +CSS=/gcc.css + WWWBASE=/www/gcc/htdocs WWWBASE_PREFORMATTED=/www/gcc/htdocs-preformatted WWWPREPROCESS='/www/gcc/bin/preprocess -r' @@ -156,7 +158,7 @@ for file in $MANUALS; do if [ "$file" = "gnat_ugn" ]; then includes="$includes -I gcc/gcc/ada -I gcc/gcc/ada/doc/gnat_ugn" fi - makeinfo --html $includes -o ${file} ${filename} + makeinfo --html --css-ref $CSS $includes -o ${file} ${filename} tar cf ${file}-html.tar ${file}/*.html texi2dvi $includes -o ${file}.dvi ${filename} </dev/null >/dev/null && dvips -o ${file}.ps ${file}.dvi texi2pdf $includes -o ${file}.pdf ${filename} </dev/null |