c-family/
* c-ada-spec.c (is_float128): New predicate extracted from...
(dump_ada_node) <COMPLEX_TYPE>: Use it to recognize __cfloat128.
<REAL_TYPE>: ...here. Call it.
ada/
* libgnat/i-cexten.ads (CFloat_128): New type.
From-SVN: r270188
2019-04-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/89981
* resolve.c (resolve_global_procedure): If the global symbol is an
ENTRY, also look up its name among the entries.
2019-04-06 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/89981
* gfortran.dg/entry_22.f90: New test.
From-SVN: r270182
* pt.c (convert_nontype_argument): Don't call
build_converted_constant_expr if it could involve calling a conversion
function with a instantiation-dependent constructor as its argument.
* g++.dg/cpp0x/constexpr-conv3.C: New test.
* g++.dg/cpp0x/constexpr-conv4.C: New test.
From-SVN: r270178
The equality operators for directory iterators are not explicitly
specified in the standard, they're only required to meet the iterator
requirements. This means we don't need to declare them at namespace
scope and can implement them as hidden friends.
Also add 'noexcept' to directory_iterator's dereference operators.
* include/bits/fs_dir.h (directory_iterator::operator*)
(directory_iterator::operator->): Add noexcept.
(operator==, operator!=): Replace namespace-scope equality operators
for directory iterators with hidden friends.
From-SVN: r270175
Implement the proposed resolution of LWG 2708 by moving the _M_options
and _M_pending members out of the recursive_directory_iterator into the
shared _Dir_stack object. Because _Dir_stack is an opaque type, the
member functions that access the _M_options and _M_pending variables
cannot be inline. Move them into the library.
As a drive-by fix, add noexcept to the non-throwing member functions of
recursive_directory_iterator.
* config/abi/pre/gnu.ver: Export new symbols.
* include/bits/fs_dir.h (recursive_directory_iterator::options())
(recursive_directory_iterator::recursion_pending())
(recursive_directory_iterator::disable_recursion_pending()): Remove
inline definitions. Make noexcept.
(recursive_directory_iterator::depth())
(recursive_directory_iterator::operator*())
(recursive_directory_iterator::operator->()): Make noexcept.
(recursive_directory_iterator::_M_options)
(recursive_directory_iterator::_M_pending): Remove data members.
* src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members.
(recursive_directory_iterator::recursive_directory_iterator): Remove
ctor-initializer. Use new constructor for _Dir_stack.
(recursive_directory_iterator::options())
(recursive_directory_iterator::recursion_pending())
(recursive_directory_iterator::disable_recursion_pending()): Add
non-inline definitions.
(recursive_directory_iterator::depth()): Make noexcept.
(recursive_directory_iterator::increment(error_code&))
(recursive_directory_iterator::pop(error_code&)): Adjust to new
location of options and recursion_pending members.
* testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test.
* testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add
user-declared move constructor and assignment operator, to make the
type move-only.
From-SVN: r270173
We need to handle DT_UNKNOWN earlier, not only during directory
recursion, so that the cached file_type value in the directory_entry
won't be used.
* src/c++17/fs_dir.cc (_Dir::advance(bool, error_code&)): Handle
d_type == DT_UNKNOWN immediately.
(_Dir::should_recurse(bool, error_code&)): Remove file_type::unknown
handling here.
* testsuite/27_io/filesystem/iterators/caching.cc: New test.
From-SVN: r270172
The standard says "If *this and p are the same object, has no effect."
Previously we ended up clearing the path.
* include/bits/fs_path.h (path::operator=(path&&)): Check for self
assignment.
* src/c++17/fs_path.cc (path::operator=(const path&)): Likewise.
* testsuite/27_io/filesystem/path/assign/copy.cc: Test self
assignment.
From-SVN: r270171
Avoid creating arbitrarily large objects on the stack when emplacing
trivially copyable objects into a variant. Currently we provide the
strong exception-safety guarantee for all trivially copyable types, by
constructing a second variant and then doing a non-throwing move
assignment from the temporary. This patch restricts that behaviour to
trivially copyable types that are no larger than 256 bytes. For larger
types the object will be emplaced directly into the variant, and if its
initialization throws then the variant becomes valueless.
Also implement Antony Polukhin's suggestion to whitelist specific types
that are not trivially copyable but can be efficiently move-assigned.
Emplacing those types will never cause a variant to become valueless.
The whitelisted types are: std::shared_ptr, std::weak_ptr,
std::unique_ptr, std::function, and std::any. Additionally,
std::basic_string, std::vector, and __gnu_debug::vector are whitelisted
if their allocator traits give them a non-throwing move assignment
operator. Specifically, this means std::string is whitelisted, but
std::pmr::string is not.
As part of this patch, additional if-constexpr branches are added for
the cases where the initialization is known to be non-throwing (so the
overhead of the try-catch block can be avoided) and where a scalar is
being produced by a potentially-throwing conversion operator (so that
the overhead of constructing and move-assigning a variant is avoided).
These changes should have no semantic effect, just better codegen.
PR libstdc++/87431 (again)
* include/bits/basic_string.h (__variant::_Never_valueless_alt):
Define partial specialization for basic_string.
* include/bits/shared_ptr.h (_Never_valueless_alt): Likewise for
shared_ptr and weak_ptr.
* include/bits/std_function.h (_Never_valueless_alt): Likewise for
function.
* include/bits/stl_vector.h (_Never_valueless_alt): Likewise for
vector.
* include/bits/unique_ptr.h (_Never_valueless_alt): Likewise for
unique_ptr.
* include/debug/vector (_Never_valueless_alt): Likewise for debug
vector.
* include/std/any (_Never_valueless_alt): Define explicit
specialization for any.
* include/std/variant (_Never_valueless_alt): Define primary template.
(__never_valueless): Use _Never_valueless_alt instead of
is_trivially_copyable.
(variant::emplace<N>(Args&&...)): Add special case for non-throwing
initializations to avoid try-catch overhead. Add special case for
scalars produced by potentially-throwing conversions. Use
_Never_valueless_alt instead of is_trivially_copyable for the
remaining strong exception-safety cases.
(variant::emplace<N>(initializer_list<U>, Args&&...)): Likewise.
* testsuite/20_util/variant/87431.cc: Run both test functions.
* testsuite/20_util/variant/exception_safety.cc: New test.
* testsuite/20_util/variant/run.cc: Use pmr::string instead of string,
so the variant becomes valueless.
From-SVN: r270170
PR c++/89973 - -Waddress-of-packed-member ICE with invalid conversion.
* c-warn.c (check_address_or_pointer_of_packed_member): Check the type
of RHS.
* g++.dg/warn/Waddress-of-packed-member2.C: New test.
From-SVN: r270166
2019-04-05 Richard Biener <rguenther@suse.de>
PR debug/89892
PR debug/89905
* tree-cfgcleanup.c (remove_forwarder_block): Always move
debug bind stmts but reset them if they are not valid at the
destination.
* gcc.dg/guality/pr89892.c: New testcase.
* gcc.dg/guality/pr89905.c: Likewise.
* gcc.dg/guality/loop-1.c: Likewise.
From-SVN: r270165
This patch fixes a case in which, due to forced missed optimisations
in earlier passes, we have:
_1 = a * b
_2 = -_1
_3 = -_1
_4 = _2 + _3
and treated _4 as two FNMA candidates, once via _2 and once via _3.
2019-04-05 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR tree-optimization/89956
* tree-ssa-math-opts.c (convert_mult_to_fma): Protect against
multiple negates of the same value.
gcc/testsuite/
PR tree-optimization/89956
* gfortran.dg/pr89956.f90: New test.
From-SVN: r270162
My patch for PR 86932 broke this testcase by passing tf_partial to
coerce_template_template_parms, which prevented do_auto_deduction from
actually replacing the auto.
* pt.c (do_auto_deduction): Clear tf_partial.
From-SVN: r270160
Three separate issues were breaking this testcase. One, we were trying to
look at the type of a template template parameter to see if it's a valid
non-type template parameter. Two, we were treating a parameter pack named
in the type of a template parameter pack of a TTP pack as being one of the
packs expanded by the outer pack. Three, we weren't supplying all the
necessary levels of template arguments when TTP matching.
* pt.c (coerce_template_parameter_pack): Only look at the type of a
non-type parameter pack.
(fixed_parameter_pack_p_1): Don't recurse into the type of a
non-type parameter pack.
(coerce_template_template_parms): Call add_outermost_template_args.
From-SVN: r270159
PR c++/89974 - ICE on a definition of a non-type specialization on a struct object with pointer to member function
PR c++/89878 - same specializations on a zero-initialized struct object as a non-type parameter treated as distinct
PR c++/89833 - sorry, unimplemented: string literal in function template signature
PR c++/47488 - sorry, unimplemented: string literal in function template signature
gcc/cp/ChangeLog:
PR c++/89974
PR c++/89878
PR c++/89833
PR c++/47488
* decl.c (reshape_init_array_1): Strip trailing zero-initializers
from arrays of trivial type and known size.
* mangle.c (write_expression): Convert braced initializer lists
to STRING_CSTs.
(write_expression): Trim trailing zero-initializers from arrays
of trivial type.
(write_template_arg_literal): Mangle strings the same as braced
initializer lists.
gcc/testsuite/ChangeLog:
PR c++/89974
PR c++/89878
PR c++/89833
PR c++/47488
* gcc/testsuite/g++.dg/abi/mangle69.C: New test.
* gcc/testsuite/g++.dg/abi/mangle70.C: New test.
* gcc/testsuite/g++.dg/abi/mangle71.C: New test.
* gcc/testsuite/g++.dg/abi/mangle72.C: New test.
* gcc/testsuite/g++.dg/cpp0x/constexpr-array19.C: New test.
* gcc/testsuite/g++.dg/cpp2a/nontype-class15.C: New test.
* gcc/testsuite/g++.dg/cpp2a/nontype-class16.C: New test.
* gcc/testsuite/g++.dg/init/array51.C: New test.
From-SVN: r270155
PR middle-end/89957 - ICE calling strnlen with an int128_t bound in a known range
PR middle-end/89911 - [9 Regression] ICE in get_attr_nonstring_decl
gcc/ChangeLog:
PR middle-end/89957
PR middle-end/89911
* builtins.c (expand_builtin_strnlen): Make sure wi::ltu_p operands
have the same precision since the function crashes otherwise.
* calls.c (maybe_warn_nonstring_arg): Avoid assuming strnlen() call
has non-zero arguments.
gcc/testsuite/ChangeLog:
PR middle-end/89957
PR middle-end/89911
* gcc.dg/Wstringop-overflow-13.c: New test.
From-SVN: r270154
gcc/ChangeLog:
PR middle-end/89934
* gimple-ssa-warn-restrict.c (builtin_access::builtin_access): Bail
out if the number of arguments is less than expected.
gcc/testsuite/ChangeLog:
PR middle-end/89934
* gcc.dg/Wrestrict-19.c: New test.
* gcc.dg/Wrestrict-5.c: Add comment. Remove unused code.
From-SVN: r270152
PR rtl-optimization/89399
* ree.c (combine_set_extension): Use single_set rather than
digging into PATTERN for items on the candidate list.
(combine_reaching_defs): Likewise.
PR rtl-optimization/89399
* gcc.c-torture/compile/pr89399.c: New test.
From-SVN: r270151
2019-04-04 Harald Anlauf <anlauf@gmx.de>
PR fortran/89004
* check.c (gfc_check_transfer): Reject procedures as actual
arguments for SOURCE and MOLD of TRANSFER intrinsic.
PR fortran/89004
* gfortran.dg/pr85797.f90: Adjust testcase.
From-SVN: r270150
- df_live is already present at -O2, so we only need to add it and
mark all blocks dirty for -O
- df_process_deferred_rescans should be enough to force a rescan of
blocks affected by moving invariants, but calling it in find_defs
means that we don't do any rescans for the final loop
2019-04-04 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR rtl-optimization/46590
* loop-invariant.c (find_defs): Move df_remove_problem and
df_process_deferred_rescans to move_invariants.
Move df_live_add_problem and df_live_set_all_dirty calls
to move_invariants.
(move_invariants): Likewise.
(move_loop_invariants): Likewise, making the df_live calls
conditional on -O. Remove the problem again if we added it
locally.
From-SVN: r270142
This testcase manages to find a way to look up the partial instantiation of
B for the default argument of C before we've created the partial
instantiation of B as part of the normal instantiation of the members of A.
Which we can deal with, but we were getting confused because the partial
instantiation was stored with a RECORD_TYPE specialization rather than
TEMPLATE_DECL.
* pt.c (tsubst_template_decl): Handle getting a type from
retrieve_specialization.
From-SVN: r270138
This patch limits constexpr folding for -Wsign-compare to only cases that we
would warn for without considering constant values, avoiding the folding in
the testcase in question.
gcc/c-family/
* c-warn.c (warn_for_sign_compare): Call fold_for_warn.
gcc/cp/
* typeck.c (cp_build_binary_op): Don't fold for -Wsign-compare.
From-SVN: r270136
We were aborting when build_base_path returned an error because of the
derived class not being complete yet, which wasn't considered by the assert.
Fixed by checking for complete type first. The semantics.c change avoids
a duplicate error message.
* semantics.c (finish_offsetof): Handle error_mark_node.
* typeck.c (build_class_member_access_expr): Call
complete_type_or_maybe_complain before converting to base.
From-SVN: r270135
2019-04-03 qing zhao <qing.zhao@oracle.com>
PR tree-optimization/89730
* ipa-inline.c (can_inline_edge_p): Delete the checking for
-flive-patching=inline-only-static.
(can_inline_edge_by_limits_p): Add the checking for
-flive-patching=inline-only-static and grant always_inline
even when -flive-patching=inline-only-static is specified.
* gcc.dg/live-patching-4.c: New test.
From-SVN: r270134