1. 20 Jun, 2019 28 commits
  2. 19 Jun, 2019 12 commits
    • Fix non-standard behaviour of std::istream_iterator · 638ad333
      The current implementation of istream_iterator allows the iterator to be
      reused after reaching end-of-stream, so that subsequent reads from the
      stream can succeed (e.g. if the stream state has been cleared and stream
      position changed from EOF). The P0738R2 paper clarified that the
      expected behaviour is to set the stream pointer to null after reaching
      end-of-stream, preventing further reads.
      
      This implements that requirement, and adds the new default constructor
      to std::ostream_iterator.
      
      	* include/bits/stream_iterator.h (istream_iterator::_M_equal()): Make
      	private.
      	(istream_iterator::_M_read()): Do not check stream state before
      	attempting extraction. Set stream pointer to null when extraction
      	fails (P0738R2).
      	(operator==(const istream_iterator&, const istream_iterator&)): Change
      	to be a hidden friend of istream_iterator.
      	(operator!=(const istream_iterator&, const istream_iterator&)):
      	Likewise.
      	(ostream_iterator::ostream_iterator()): Add default constructor.
      	(ostream_iterator::ostream_iterator(ostream_type*, const C*)): Use
      	addressof.
      	* testsuite/24_iterators/istream_iterator/1.cc: New test.
      	* testsuite/24_iterators/ostream_iterator/1.cc: New test.
      	* testsuite/24_iterators/ostream_iterator/70766.cc: Also check
      	constructor taking a string.
      	* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
      	New test.
      
      From-SVN: r272491
      Jonathan Wakely committed
    • Have std::vector printer's iterator return bool for vector<bool> · 36d0dada
      Have the pretty-printer for 'std::vector<bool>' return a
      value of type 'bool' rather than an 'int'.
      
      This way, the type is clear and that can be used for better
      display and a 'gdb.Value' constructed from the returned value
      will have type 'bool' again, not e.g. 'long long' as happened
      previously (at least with GDB 8.2.1 on amd64).
      
      2019-06-19  Michael Weghorn  <m.weghorn@posteo.de>
      	    Jonathan Wakely  <jwakely@redhat.com>
      
      	PR libstdc++/90945
      	* python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Use
      	values of type bool for vector<bool> elements.
      	* testsuite/libstdc++-prettyprinters/simple.cc: Test vector<bool>.
      	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
      
      Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>
      
      From-SVN: r272490
      Michael Weghorn committed
    • PR libstdc++/90920 restore previous checks for empty ranges · 0fd9e848
      The change in r263433 broke the contract of the __rotate functions, by no
      longer accepting empty ranges. That means that callers which inlined the
      old version of std::rotate (without checks) that end up linking to a new
      definition of std::__rotate (also without checks) could perform a divide
      by zero and crash.
      
      This restores the old contract of the __rotate overloads.
      
      	PR libstdc++/90920 partially revert r263433
      	* include/bits/stl_algo.h (__rotate): Restore checks for empty ranges.
      	(rotate): Remove checks.
      	* testsuite/25_algorithms/rotate/90920.cc: New test.
      
      From-SVN: r272489
      Jonathan Wakely committed
    • re PR tree-optimization/90626 (fold strcmp(a, b) == 0 to zero when one string… · c6f0626b
      re PR tree-optimization/90626 (fold strcmp(a, b) == 0 to zero when one string length is exact and the other is unequal)
      
      PR tree-optimization/90626
      
      gcc/ChangeLog:
      	* tree-ssa-strlen.c (strxcmp_unequal): Fix typos.
      
      From-SVN: r272487
      Martin Sebor committed
    • PR c++/60364 - noreturn after first decl not diagnosed. · 1bf32c11
      	* attribs.c (get_attribute_namespace): No longer static.
      	(decl_attributes): Avoid shadowing.  Preserve the C++11 form for C++11
      	attributes.
      	(attr_noreturn_exclusions): Make it extern.
      	* attribs.h (get_attribute_namespace): Declare.
      	* tree-inline.c (function_attribute_inlinable_p): Use
      	get_attribute_name.
      
      	* c-attribs.c (handle_noreturn_attribute): No longer static.
      	* c-common.h (handle_noreturn_attribute, attr_noreturn_exclusions):
      	Declare.
      	* c-format.c (check_function_format): Use get_attribute_name.
      
      	* decl.c (duplicate_decls): Give an error when a function is
      	declared [[noreturn]] after its first declaration.
      	* parser.c (cp_parser_std_attribute): Don't treat C++11 noreturn
      	attribute as equivalent to GNU's.
      	* tree.c (std_attribute_table): Add noreturn.
      
      	* g++.dg/warn/noreturn-8.C: New test.
      	* g++.dg/warn/noreturn-9.C: New test.
      	* g++.dg/warn/noreturn-10.C: New test.
      	* g++.dg/warn/noreturn-11.C: New test.
      
      From-SVN: r272486
      Marek Polacek committed
    • PR tree-optimization/90626 - fold strcmp(a, b) == 0 to zero when one string… · 4b4a2673
      PR tree-optimization/90626 - fold strcmp(a, b) == 0 to zero when one string length is exact and the other is unequal
      
      gcc/ChangeLog:
      
      	PR tree-optimization/90626
      	* tree-ssa-strlen.c (strxcmp_unequal): New function.
      	(handle_builtin_string_cmp): Call it.
      
      gcc/testsuite/ChangeLog:
      
      	PR tree-optimization/90626
      	* gcc.dg/strlenopt-65.c: New test.
      	* gcc.dg/strlenopt-66.c: New test.
      	* gcc.dg/strlenopt.h (strcmp, strncmp): Declare.
      
      From-SVN: r272485
      Martin Sebor committed
    • [Darwin, specs] Tidy some more linker options. · 14fef000
      pie, no-pie and rdynamic are driver options, we can process them in the
      relevant place and drop them once dealt with.  There's no need to generate
      a new header to process the "no_compact_unwind" which is applied on the
      basis of the target system.
      
      Support for the -pie, -no_pie and -no_compact_unwind options should ideally
      be checked at configure time, however the status quo is to assert that linkers
      capable of targeting the relevant systems support these options (i.e. we trust
      that the user doesn't attempt to configure inappropriately).
      
      TODO: check the availability of the linker opts in configure rather than
      trusting to the user.
      
      This will fix the fail of pie-7.c, which is a result of failing to handle the
      no-pie driver option.
      
      2019-06-19  Iain Sandoe  <iain@sandoe.co.uk>
      
      	* config/darwin.h (DRIVER_SELF_SPECS): Add RDYNAMIC, DARWIN_PIE_SPEC
      	and DARWIN_NOPIE_SPEC.
      	(RDYNAMIC): New, modified from DARWIN_EXPORT_DYNAMIC.
      	(DARWIN_PIE_SPEC): Collate from darwin.h and darwin9.h.
      	(DARWIN_NOPIE_SPEC): Collate from darwin10.h.
      	(DARWIN_NOCOMPACT_UNWIND): New from darwin10.h
      	(DARWIN_EXPORT_DYNAMIC): Delete.
      	* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move no_compact_unwind
      	and pie options processing to  darwin.h.
      	* config/darwin9.h (DARWIN_PIE_SPEC): Move pie processing to darwin.h
      
      From-SVN: r272484
      Iain Sandoe committed
    • PR translation/90156 - add linter check suggesting to replace %<%s%> with %qs · a04c0734
      gcc/c-family/ChangeLog:
      
      	PR translation/90156
      	* c-format.c (function_format_info::format_type): Adjust type.
      	(function_format_info::is_raw): New member.
      	(decode_format_type): Adjust signature.  Handle "raw" diag attributes.
      	(decode_format_attr): Adjust call to decode_format_type.
      	Avoid a redundant call to convert_format_name_to_system_name.
      	Avoid abbreviating the word "arguments" in a diagnostic.
      	(format_warning_substr): New function.
      	(avoid_dollar_number): Quote dollar sign in a diagnostic.
      	(finish_dollar_format_checking): Same.
      	(check_format_info): Same.
      	(struct baltoks_t): New.
      	(c_opers, c_keywords, cxx_keywords, badwords, contrs): New arrays.
      	(maybe_diag_unbalanced_tokens, check_tokens, check_plain): New
      	functions.
      	(check_format_info_main): Call check_plain.  Use baltoks_t.  Call
      	maybe_diag_unbalanced_tokens.
      	(handle_format_attribute): Spell out the word "arguments" in
      	a diagnostic.
      
      gcc/testsuite/ChangeLog:
      
      	PR translation/90156
      	* gcc.dg/format/gcc_diag-11.c: Enable.
      
      From-SVN: r272483
      Martin Sebor committed
    • re PR fortran/69499 ([F03] ICE-on-invalid on combining select type with wrong statement) · ef3e6aa3
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/69499
      	* match.c (gfc_match_select_type):  SELECT TYPE is an executable 
      	statement, and cannot appear in MODULE or SUBMODULE scope.
      
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/69499
      	* gfortran.dg/pr69499.f90: New test.
      	* gfortran.dg/module_error_1.f90: Update dg-error string.
      
      From-SVN: r272482
      Steven G. Kargl committed
    • re PR fortran/69398 ([OOP] ICE on class with duplicate dimension attribute specified) · c9935123
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/69398
      	* decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
      	CLASS entity.
      
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/69398
      	* gfortran.dg/pr69398.f90: New test.
      
      From-SVN: r272481
      Steven G. Kargl committed
    • re PR fortran/87907 (ICE in resolve_contained_fntype, at fortran/resolve.c:587) · ee3aab68
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/87907
      	* resolve.c (resolve_contained_fntype): Do not dereference a NULL
      	pointer.
      
      2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
      
      	PR fortran/87907
      	* gfortran.dg/pr87907.f90: New testcase.
      
      From-SVN: r272480
      Steven G. Kargl committed
    • [Darwin] Fix two off-by-one errors in the driver. · 33f0ad50
      2019-06-19  Iain Sandoe  <iain@sandoe.co.uk>
      
              * config/darwin-driver.c (darwin_driver_init): Fix off-by-one errors
              in computing the number of options to be moved.
      
      From-SVN: r272479
      Iain Sandoe committed