* src/filesystem/dir.cc (recursive_directory_iterator::increment):
Reset state on error.
* testsuite/experimental/filesystem/iterators/
recursive_directory_iterator.cc: Check state after increment error.
From-SVN: r241552
PR tree-optimization/78060
PR tree-optimization/78061
PR tree-optimization/78088
* tree-ssa-loop-split.c (easy_exit_values): New function.
(tree_ssa_split_loops): Use it.
(compute_new_first_bound): Change order of operations,
fix invalid use of types.
testsuite/
* g++.dg/pr78060.C: New test.
* gfortran.dg/pr78061.f: New test.
* g++.dg/pr78088.C: New test.
From-SVN: r241551
gen-pass-instances.awk is sensitive to the order in which
passes are added; passes that appear later have to be added first.
PR target/71676
PR target/71678
* config/avr/avr-passes.def: Swap order of directives for
gen-pass-instances.awk.
From-SVN: r241547
2016-10-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/45516
* class.c (gfc_find_derived_vtab): Detect recursive allocatable
derived type components. If present, add '_deallocate' field to
the vtable and build the '__deallocate' function.
* decl.c (build_struct): Allow recursive allocatable derived
type components for -std=f2008 or more.
(gfc_match_data_decl): Accept these derived types.
* expr.c (gfc_has_default_initializer): Ditto.
* resolve.c (resolve_component): Make sure that the vtable is
built for these derived types.
* trans-array.c(structure_alloc_comps) : Use the '__deallocate'
function for the automatic deallocation of these types.
* trans-expr.c : Generate the deallocate accessor.
* trans.h : Add its prototype.
* trans-types.c (gfc_get_derived_type): Treat the recursive
allocatable components in the same way as the corresponding
pointer components.
2016-10-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/45516
* gfortran.dg/class_2.f03: Set -std=f2003.
* gfortran.dg/finalize_21.f90: Modify tree-dump.
* gfortran.dg/recursive_alloc_comp_1.f08: New test.
* gfortran.dg/recursive_alloc_comp_2.f08: New test.
* gfortran.dg/recursive_alloc_comp_3.f08: New test.
* gfortran.dg/recursive_alloc_comp_4.f08: New test.
From-SVN: r241539
Running "make selftest-valgrind" showed various leaks of the form:
408 bytes in 24 blocks are definitely lost in loss record 572 of 679
at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x1B0D057: xmalloc (xmalloc.c:148)
by 0x1ACCAA1: append_file_to_dir(char const*, cpp_dir*) [clone .isra.3] (files.c:1567)
by 0x1ACD56F: _cpp_find_file (files.c:390)
by 0x1ACF8FB: cpp_read_main_file(cpp_reader*, char const*) (init.c:632)
by 0x1AB3D97: selftest::lexer_test::lexer_test(selftest::line_table_case const&, char const*, selftest::lexer_test_options*) (input.c:2014)
by 0x1AB792B: selftest::test_lexer_string_locations_u8(selftest::line_table_case const&) (input.c:2713)
by 0x1ABA22A: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.c:3227)
by 0x1ABA381: selftest::input_c_tests() (input.c:3260)
by 0x1A295F1: selftest::run_tests() (selftest-run-tests.c:62)
by 0xF20DC4: toplev::run_self_tests() (toplev.c:2076)
by 0xF20FCD: toplev::main(int, char**) (toplev.c:2153)
Fix the leak by freeing the file->path in destroy_cpp_file.
However, doing so would lead to a use-after-free in input.c's file cache
since the filenames in this cache are the libcpp file->path buffers.
Hence we need to ensure that any references to the file in the input.c
cache are purged before cleaning up file->path. This is normally done
by the temp_source_file dtor. Hence we need to reorder things to that
the temp_source_file dtor runs before cleaning up the cpp_parser. The
patch does this by introducing a wrapper class around cpp_parser *, so
that the dtor can run after the dtor for temp_source_file.
gcc/ChangeLog:
* input.c (fcache::file_patch): Add comment about lifetime.
(selftest::cpp_reader_ptr): New class.
(selftest::lexer_test): Convert m_parser from cpp_reader *
to a cpp_reader_ptr, and move m_tempfile to after it.
(selftest::lexer_test::lexer_test): Update for above reordering.
(lexer_test::~lexer_test): Move cleanup of m_parser to
cpp_reader_ptr's dtor.
libcpp/ChangeLog:
* files.c (destroy_cpp_file): Free file->path.
From-SVN: r241536
line_maps instances such as the global line_table are
GC-managed, but the htab within location_adhoc_data_map.htab
is not GC-managed.
Previously this was deleted manually by a call to
location_adhoc_data_fini within toplev::main.
However, on adding a call to forcibly_ggc_collect after the
selftests, all of the htabs for the various line_tables
created during the selftests start showing up as leaks
in "make selftest-valgrind", e.g.:
13,536 (1,344 direct, 12,192 indirect) bytes in 12 blocks are definitely lost in loss record 1,065 of 1,086
at 0x4A081D4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x16DB3B0: xcalloc (xmalloc.c:163)
by 0x16D8D34: htab_create_typed_alloc (hashtab.c:358)
by 0x16D8DBD: htab_create_alloc (hashtab.c:286)
by 0x16A2CCC: linemap_init(line_maps*, unsigned int) (line-map.c:353)
by 0x1685605: selftest::line_table_test::line_table_test(selftest::line_table_case const&) (input.c:1624)
by 0x167D09C: selftest::test_applying_fixits_modernize_named_init(selftest::line_table_case const&) (edit-context.c:1430)
by 0x1686827: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.c:3227)
by 0x167F067: selftest::edit_context_c_tests() (edit-context.c:1658)
by 0x1616E67: selftest::run_tests() (selftest-run-tests.c:71)
by 0xC0DB25: toplev::run_self_tests() (toplev.c:2076)
by 0x618EB4: toplev::main(int, char**) (toplev.c:2153)
This patch removes the manual one-time cleanup in favor of
adding a destructor to class line_maps, which cleans up
the non-GC-managed htab.
Doing so improves "make selftest-valgrind" from:
==61118== LEAK SUMMARY:
==61118== definitely lost: 121,248 bytes in 1,515 blocks
==61118== indirectly lost: 974,344 bytes in 959 blocks
==61118== possibly lost: 0 bytes in 0 blocks
==61118== still reachable: 1,332,599 bytes in 3,684 blocks
==61118== suppressed: 0 bytes in 0 blocks
to:
==57182== LEAK SUMMARY:
==57182== definitely lost: 13,840 bytes in 556 blocks
==57182== indirectly lost: 0 bytes in 0 blocks
==57182== possibly lost: 0 bytes in 0 blocks
==57182== still reachable: 1,355,703 bytes in 3,684 blocks
==57182== suppressed: 0 bytes in 0 blocks
gcc/ChangeLog:
* toplev.c (toplev::main): Remove call to
location_adhoc_data_fini.
libcpp/ChangeLog:
* include/line-map.h (line_maps::~line_maps): New dtor.
(location_adhoc_data_fini): Delete decl.
* line-map.c (line_maps::~line_maps): New dtor.
(location_adhoc_data_fini): Delete.
From-SVN: r241533
gcc/testsuite/ChangeLog:
2016-10-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/72770
* gfortran.dg/alloc_comp_class_5.f03: Added test again that caused
this pr.
gcc/fortran/ChangeLog:
2016-10-25 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/72770
* class.c (find_intrinsic_vtab): No longer encode the string length
into vtype's name and use the char's kind for the size instead of
the string_length time the size.
* trans-array.c (gfc_conv_ss_descriptor): For deferred length char
arrays the dynamically sized type needs to be declared.
(build_class_array_ref): Address the i-th array element by multiplying
it with the _vptr->_size and the _len to make sure char arrays are
addressed correctly.
* trans-expr.c (gfc_conv_intrinsic_to_class): Made comment more
precise.
From-SVN: r241528
* src/filesystem/ops.cc (do_copy_file): Report an error if source or
destination is not a regular file (LWG 2712).
(equivalent): Fix error handling and result when only one file exists.
* testsuite/experimental/filesystem/operations/copy.cc: Remove files
created by tests. Test copying directories.
* testsuite/experimental/filesystem/operations/copy_file.cc: Remove
files created by tests.
* testsuite/experimental/filesystem/operations/equivalent.cc: New.
* testsuite/experimental/filesystem/operations/is_empty.cc: New.
* testsuite/experimental/filesystem/operations/read_symlink.cc: Remove
file created by test.
* testsuite/experimental/filesystem/operations/remove_all.cc: New.
* testsuite/util/testsuite_fs.h (~scoped_file): Only try to remove
file if path is non-empty, to support removal by other means.
From-SVN: r241521
gcc/fortran/
* primary.c (gfc_match_rvalue): Match %LOC as LOC with -std=legacy.
* gfortran.texi: Document.
gcc/testsuite/gfortran.dg/
* dec_loc_rval_1.f90: New test.
* dec_loc_rval_2.f90: New test.
* dec_loc_rval_3.f90: New test.
From-SVN: r241519
gcc/go/ChangeLog:
* go-lang.c (go_langhook_type_for_mode): Remove redundant cast
from result of GET_MODE_CLASS. Minor formatting fixes.
From-SVN: r241514
PR sanitizer/78106
* sanopt.c (imm_dom_path_with_freeing_call): Handle gasm
statements as they can also contain possibly a freeing call.
PR sanitizer/78106
* gcc.dg/asan/pr78106.c: New test.
From-SVN: r241511
With -fpu=neon DI mode shifts are expanded after reload. DI mode registers can
either fully or partially overlap on both ARM and Thumb-2. However the shift
expansion code can only deal with the full overlap case, and generates incorrect
code for partial overlaps. The fix is to add new variants that support either
full overlap or no overlap.
gcc/
PR target/78041
* config/arm/neon.md (ashldi3_neon): Add "r 0 i" and "&r r i" variants.
Remove partial overlap check for shift by 1.
(ashldi3_neon): Likewise.
testsuite/
* gcc.target/arm/pr78041.c: New test.
From-SVN: r241508
2016-10-25 Thomas Preud'homme <thomas.preudhomme@arm.com>
gcc/
* config/arm/constraints.md (Q constraint): Document its use for
Thumb-1.
(Pf constraint): New constraint for relaxed, consume or relaxed memory
models.
* config/arm/sync.md (atomic_load<mode>): Add new ARMv8-M Baseline only
alternatives to allow any register when memory model matches Pf and
thus lda is used, but only low registers otherwise. Use unpredicated
output template for Thumb-1 targets.
(atomic_store<mode>): Likewise for stl.
(arm_load_exclusive<mode>): Add new ARMv8-M Baseline only alternative
whose output template does not have predication.
(arm_load_acquire_exclusive<mode>): Likewise.
(arm_load_exclusivesi): Likewise.
(arm_load_acquire_exclusivesi): Likewise.
(arm_store_release_exclusive<mode>): Likewise.
(arm_store_exclusive<mode>): Use unpredicated output template for
Thumb-1 targets.
From-SVN: r241507
gcc/
New avt target pass to work around performance loss by PR fix.
PR target/71676
PR target/71678
* config/avr/avr.md (casesi_<mode>_sequence) [qi,hi]: New insn.
(*cmp<mode>) [qi,qq,uqq,hi,hq,uhq,ha,uha]: Rename to cmp<mode>3.
* config/avr/predicates.md (extend_operator): New.
* config/avr/avr-passes.def (avr_pass_casesi): Register new pass.
* config/avr/avr-protos.h (avr_casei_sequence_check_operands)
(make_avr_pass_casesi): New prototypes.
* config/avr/avr.c (print-rtl.h): Include it.
(pass_data avr_pass_data_casesi): Data for new pass.
(avr_pass_casesi): New class implementing rtl_opt_pass .avr-casesi.
(make_avr_pass_casesi, avr_parallel_insn_from_insns)
(avr_is_casesi_sequence, avr_casei_sequence_check_operands)
(avr_optimize_casesi): New functions.
gcc/testsuite/
PR target/71676
PR target/71678
* gcc.target/avr/pr71676-2.c: New test.
From-SVN: r241504
gcc/testsuite/ChangeLog:
2016-10-24 Kugan Vivekanandarajah <kuganvi@linaro.org>
* gcc.target/aarch64/test_frame_common.h: Add noclone attribute
such that cloned verions of tested functions are not created.
From-SVN: r241499
2016-10-24 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/77828
* io/io.h (st_parameter_dt): Reorder for readability and sanity.
* io/transfer.c (data_transfer_init): Remove TODO and enable the
runtime error message, rec= specifier not allowed in STREAM
access.
* libtool-version: Bump major version of libgfortran to 4.
* ioparm.def: Reorder dt parameters to match libgfortran.
* libgfortran.h: Swap definitions of GFC_INTERNAL_UNIT and
GFC_INTERNAL_UNIT4.
From-SVN: r241497
2016-10-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71895
* interface.c (gfc_compare_derived_types): Convert gcc_assert()
to a gfc_internal_error() to prevent an ICE.
2016-10-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/71895
* gfortran.dg/pr71895.f90: New test.
From-SVN: r241493
gcc/ChangeLog:
PR middle-end/77735
* builtins.c (string_length): New function.
(c_strlen): Use string_length. Correctly handle wide strings.
* gimple-ssa-sprintf.c (target_max_value, target_size_max): New
functions.
(target_int_max): Call target_max_value.
(format_result::knownrange): New data member.
(fmtresult::fmtresult): Define default constructor.
(format_integer): Use it and set format_result::knownrange.
Handle global constants.
(format_floating_max): Add third argument.
(format_floating): Recompute maximum value for %a for each argument.
(get_string_length): Use fmtresult default ctor.
(format_string): Set format_result::knownrange.
(format_directive): Check format_result::knownrange.
(add_bytes): Same. Correct caret placement in diagnostics.
(pass_sprintf_length::compute_format_length): Set
format_result::knownrange.
(pass_sprintf_length::handle_gimple_call): Use target_size_max.
gcc/testsuite/ChangeLog:
PR middle-end/77735
* gcc.dg/tree-ssa/builtin-sprintf-2.c: Add test cases.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: Same.
* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Adjust/relax.
* gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: Add test cases.
* gcc.dg/tree-ssa/builtin-sprintf-warn-6.c: XFAIL for LP64 only.
* gcc.dg/tree-ssa/builtin-sprintf.c: Add test cases.
From-SVN: r241489