Commit Graph

179324 Commits

Author SHA1 Message Date
Marek Polacek
b1c59b31ef c++: Allow new char[4]{"foo"} [PR77841]
Currently, we allow new char[]{"foo"}, but not new char[4]{"foo"}.
We should accept the latter too: [dcl.init.list]p3.3 says to treat
this as [dcl.init.string].

We were rejecting this code because we never called reshape_init before
the digest_init in build_new_1.  reshape_init handles [dcl.init.string]
by unwrapping the STRING_CST from its enclosing { }, and digest_init
assumes that reshape_init has been called for aggregates anyway, and an
array is an aggregate.

gcc/cp/ChangeLog:

	PR c++/77841
	* init.c (build_new_1): Call reshape_init.

gcc/testsuite/ChangeLog:

	PR c++/77841
	* g++.dg/cpp0x/initlist-new4.C: New test.
2020-09-01 17:49:20 -04:00
Jonathan Wakely
10f51543bb libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
This change evaluates __glibcxx_assert checks unconditionally when a
function is being constant evaluated (when std::is_constant_evaluated()
is true). If the check fails, compilation will fail with an error.

If the function isn't being constant evaluated, the normal runtime check
will be done if enabled by _GLIBCXX_ASSERTIONS or _GLIBCXX_DEBUG, the
same as before.

Tangentially, the __glibcxx_assert and _GLIBCXX_PARALLEL_ASSERT macros
are changed to expand to 'do { } while (false)' when assertions are
disabled, instead of expanding to nothing. This avoids -Wempty-body
warnings when a disabled assertion is used in an 'if' or 'else'
statement e.g.

  if constexpr (/* precondition is testable */)
    __glibcxx_assert(precondition);

a.C:9:27: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
    9 |     __glibcxx_assert(precondition);
      |                                  ^

libstdc++-v3/ChangeLog:

	PR libstdc++/71960
	* include/bits/c++config (__glibcxx_assert_impl): Remove
	do-while so that uses of the macro need to add it.
	(__glibcxx_assert): Rename macro for runtime assertions
	to __glibcxx_assert_2.
	(__glibcxx_assert_1): Define macro for constexpr assertions.
	(__glibcxx_assert): Define macro for constexpr and runtime
	assertions.
	* include/bits/range_access.h (ranges::advance): Remove
	redundant precondition checks during constant evaluation.
	* include/parallel/base.h (_GLIBCXX_PARALLEL_ASSERT): Always
	use do-while in macro expansion.
	* include/std/ranges (iota_view::iota_view(W, B)): Remove
	redundant braces.
2020-09-01 20:52:26 +01:00
Peter Bergner
8bc0f24d7a rs6000: MMA built-in dies with incorrect sharing of tree nodes error
When we expand our MMA built-ins into gimple, we erroneously reused the
accumulator memory reference for both the source input value as well as
the destination output value.  This led to a tree sharing error.
The solution is to create separate memory references for the input
and output values.

2020-09-01  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/96808
	* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin): Do not
	reuse accumulator memory reference for source and destination accesses.

gcc/testsuite/
	PR target/96808
	* gcc.target/powerpc/pr96808.c: New test.
2020-09-01 13:49:40 -05:00
Jonathan Wakely
b1850c617b libstdc++: Constrain chrono::duration conversions [LWG 2094]
The chrono::duration constructor that converts from another duration
type is meant to be constrained so that it doesn't participate in
overload resolution if the ratio of the periods cannot be represented as
a std::ratio.

Because our std::ratio_divide is not SFINAE-friendly the evaluation of
__is_harmonic results in an error outside the immediate context when an
overflow occurs. I intend to make ratio_divide (and ratio_multiply)
SFINAE-friendly in a future patch, but for now this patch just
introduces a new SFINAE-friendly alias template for the division.

The standard doesn't require it, but it also seems right to constrain
the constructor with std::is_convertible_v<_Rep2, rep>.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd(intmax_t, intmax_t)):
	New helper function for finding GCD of two positive intmax_t
	values.
	(duration::__divide): New helper alias for dividing one period
	by another.
	(duration::__is_harmonic): Use __divide not ratio_divide.
	(duration(const duration<R2, P2>&)): Require the duration rep
	types to be convertible.
	* testsuite/20_util/duration/cons/dr2094.cc: New test.
	* testsuite/20_util/duration/requirements/reduced_period.cc:
	Fix definition of unused member functions in test type.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
	Adjust expected errors.
2020-09-01 18:18:26 +01:00
David Malcolm
49bfbf18c0 analyzer: fix false NULL deref warning after previous deref [PR96792]
gcc/analyzer/ChangeLog:
	PR analyzer/96792
	* region-model.cc (region_model::deref_rvalue): Add the constraint
	that PTR_SVAL is non-NULL.

gcc/testsuite/ChangeLog:
	PR analyzer/96792
	* gcc.dg/analyzer/pr96792.c: New test.
2020-09-01 10:56:34 -04:00
Martin Liska
a292e31dac vec: use inexact growth where possible.
gcc/ChangeLog:

	* cfgrtl.c (rtl_create_basic_block): Use default value for
	growth vector function.
	* gimple.c (gimple_set_bb): Likewise.
	* symbol-summary.h: Likewise.
	* tree-cfg.c (init_empty_tree_cfg_for_function): Likewise.
	(build_gimple_cfg): Likewise.
	(create_bb): Likewise.
	(move_block_to_fn): Likewise.
2020-09-01 14:25:52 +02:00
Martin Liska
8aa04a189b vec: default exect = false in grow functions.
gcc/ChangeLog:

	* vec.h (vec_safe_grow): Change default of exact to false.
	(vec_safe_grow_cleared): Likewise.
2020-09-01 14:25:51 +02:00
Roger Sayle
b61eaa25b0 PR middle-end/90597: gcc_assert ICE in layout_type
This patch fixes the default implementation of TARGET_VECTOR_ALIGNMENT,
known as default_vector_alignment, using the same logic as my earlier
nvptx patch, as the ICE caused by TYPE_SIZE(type) being zero during
error handling in gcc.dg/attr-vector_size.c is common among backends,
and is known in bugzilla as PR middle-end/90597, apparently a recent
regression.

2020-09-01  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog:
	PR middle-end/90597
	* targhooks.c (default_vector_alignment): Return at least the
	GET_MODE_ALIGNMENT for the type's mode.
2020-09-01 12:03:21 +01:00
Mark Eggleston
3d137b75fe Fortran : ICE on invalid code PR95398
The CLASS_DATA macro is used to shorten the code accessing the derived
components of an expressions type specification.  If the type is not
BT_CLASS the derived pointer is NULL resulting in an ICE.  To avoid
dereferencing a NULL pointer the type should be BT_CLASS.

2020-09-01  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran

	PR fortran/95398
	* resolve.c (resolve_select_type): Add check for BT_CLASS
	type before using the CLASS_DATA macro which will have a
	NULL pointer to derive components if it isn't BT_CLASS.

2020-09-01  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite

	PR fortran/95398
	* gfortran.dg/pr95398.f90: New test.
2020-09-01 10:57:05 +01:00
Richard Biener
d6a05b494b rtl-optimization/96812 - remap dependence info on RTL loop unrolling
This carries over the PR87609 fix also to RTL loop unrolling.  The
gcc.dg/torture/pr90328.c testcase otherwise is miscompiled with
the tree-ssa-address.c hunk (or alternatively with -fno-ivopts
on master).  I've tried to find the correct abstraction and
adjusted two other duplicate_insn_chain users for which I do not
have testcases.  There may be other insn-chain copying routines
that could be affected but hopefully most appropriately go through
CFG hooks.

2020-08-27  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/96812
	* tree-ssa-address.c (copy_ref_info): Also copy dependence info.
	* cfgrtl.h (duplicate_insn_chain): Adjust prototype.
	* cfgrtl.c (duplicate_insn_chain): Remap dependence info
	if requested.
	(cfg_layout_duplicate_bb): Make sure we remap dependence info.
	* modulo-sched.c (duplicate_insns_of_cycles): Remap dependence
	info.
	(generate_prolog_epilog): Adjust.
	* config/c6x/c6x.c (hwloop_optimize): Remap dependence info.
2020-09-01 11:52:10 +02:00
Jakub Jelinek
a37b0cccf4 openmp: Check for PARM_DECL before using C_ARRAY_PARAMETER or DECL_ARRAY_PARAMETER_P [PR96867]
The C++ macro performs a PARM_DECL_CHECK, so will ICE if not tested on a PARM_DECL,
C_ARRAY_PARAMETER doesn't, but probably should, otherwise it is testing e.g.
C_DECL_VARIABLE_SIZE on VAR_DECLs.

2020-09-01  Jakub Jelinek  <jakub@redhat.com>

	PR c++/96867
	* c-typeck.c (handle_omp_array_sections_1): Test C_ARRAY_PARAMETER
	only on PARM_DECLs.

	* semantics.c (handle_omp_array_sections_1): Test
	DECL_ARRAY_PARAMETER_P only on PARM_DECLs.

	* c-c++-common/gomp/pr96867.c: New test.
2020-09-01 09:17:58 +02:00
Feng Xue
ef688fdfc6 Correct Changelog for fix to PR96806 2020-09-01 10:43:16 +08:00
Kewen Lin
be7ad7dfdb test/rs6000: Add Power9 and up as vect_len target
Power9 supports vector with length in bytes load/store, this patch
is to teach check_effective_target_vect_len_load_store to take it
and its laters as effective vector with length targets.

Also supplement the documents for has_arch_pwr*.

Bootstrapped/regtested on powerpc64le-linux-gnu P8, also on
powerpc64le-linux-gnu P9 with explicit usage setting.

gcc/ChangeLog:

	* doc/sourcebuild.texi (has_arch_pwr5, has_arch_pwr6, has_arch_pwr7,
	has_arch_pwr8, has_arch_pwr9): Document.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp
	(check_effective_target_vect_len_load_store): Call check function
	check_effective_target_has_arch_pwr9.
2020-09-01 02:37:41 +00:00
GCC Administrator
13e4ba28f3 Daily bump. 2020-09-01 00:16:25 +00:00
Carl Love
1da918e153 rs6000, remove improperly defined and unsupported builtins.
gcc/ChangeLog

2020-08-31  Carl Love  <cel@us.ibm.com>

	PR target/85830
	* config/rs6000/altivec.h (vec_popcntb, vec_popcnth, vec_popcntw,
	vec_popcntd): Remove defines.
2020-08-31 18:24:23 -05:00
David Malcolm
bc62bfb0f4 analyzer: handle __builtin___memset_chk [PR96798]
gcc/analyzer/ChangeLog:
	PR analyzer/96798
	* region-model.cc (region_model::on_call_pre): Handle
	BUILT_IN_MEMSET_CHK.

gcc/testsuite/ChangeLog:
	PR analyzer/96798
	* gcc.dg/analyzer/memset-1.c (test_5a): New.
2020-08-31 18:31:49 -04:00
David Malcolm
ee7bfbe5eb analyzer: gather builtin/internal fn handling into switch statements
Clean up this code in preparation for fixing PR analyzer/96798.

gcc/analyzer/ChangeLog:
	* region-model.cc (region_model::on_call_pre): Gather handling of
	builtins and of internal fns into switch statements.  Handle
	"alloca" and BUILT_IN_ALLOCA_WITH_ALIGN.
2020-08-31 18:31:14 -04:00
David Malcolm
18056e45db analyzer: fix ICE on unknown index in CONSTRUCTOR [PR96860]
PR analyzer/96860 reports an ICE inside CONSTRUCTOR-handling with
--param analyzer-max-svalue-depth=0 when attempting to build a
binding_map for the CONSTRUCTOR's values.

The issue is that when handling (index, value) pairs for initializing
an array, the index values for the elements exceeds the svalue
complexity limit, and the index is thus treated as unknown, leading to
a symbolic rather than concrete offset for each array element.

This patch updates the CONSTRUCTOR-handling code so that it can
fail, returning an unknown value for the overall value of the
constructor for this case, fixing the ICE.

gcc/analyzer/ChangeLog:
	PR analyzer/96860
	* region.cc (decl_region::get_svalue_for_constructor): Support
	apply_ctor_to_region failing.
	* store.cc (binding_map::apply_ctor_to_region): Add failure
	handling.
	(binding_map::apply_ctor_val_to_range): Likewise.
	(binding_map::apply_ctor_pair_to_child_region): Likewise.  Replace
	assertion that child_base_offset is not symbolic with error
	handling.
	* store.h (binding_map::apply_ctor_to_region): Convert return type
	from void to bool.
	(binding_map::apply_ctor_val_to_range): Likewise.
	(binding_map::apply_ctor_pair_to_child_region): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/96860
	* gcc.dg/analyzer/pr96860-1.c: New test.
	* gcc.dg/analyzer/pr96860-2.c: New test.
2020-08-31 18:28:59 -04:00
Marek Polacek
73a2b8dd17 c++: Implement P1009: Array size deduction in new-expressions.
This patch implements C++20 P1009, allowing code like

  new double[]{1,2,3}; // array bound will be deduced

Since this proposal makes the initialization rules more consistent, it is
applied to all previous versions of C++ (thus, effectively, all the way back
to C++11).

My patch is based on Jason's patch that handled the basic case.  I've
extended it to work with ()-init and also the string literal case.
Further testing revealed that to handle stuff like

  new int[]{t...};

in a template, we have to consider such a NEW_EXPR type-dependent.
Obviously, we first have to expand the pack to be able to deduce the
number of elements in the array.

Curiously, while implementing this proposal, I noticed that we fail
to accept

  new char[4]{"abc"};

so I've assigned 77841 to self.  I think the fix will depend on the
build_new_1 hunk in this patch.

The new tree.c function build_constructor_from_vec helps us morph
a vector into a CONSTRUCTOR more efficiently.

gcc/cp/ChangeLog:

	PR c++/93529
	* call.c (build_new_method_call_1): Use build_constructor_from_vec
	instead of build_tree_list_vec + build_constructor_from_list.
	* init.c (build_new_1): Handle new char[]{"foo"}.  Use
	build_constructor_from_vec instead of build_tree_list_vec +
	build_constructor_from_list.
	(build_new): Deduce the array size in new-expression if not
	present.  Handle ()-init.  Handle initializing an array from
	a string literal.
	* parser.c (cp_parser_new_type_id): Leave [] alone.
	(cp_parser_direct_new_declarator): Allow [].
	* pt.c (type_dependent_expression_p): In a NEW_EXPR, consider
	array types whose dimension has to be deduced type-dependent.

gcc/ChangeLog:

	PR c++/93529
	* tree.c (build_constructor_from_vec): New.
	* tree.h (build_constructor_from_vec): Declare.

gcc/testsuite/ChangeLog:

	PR c++/93529
	* g++.dg/cpp0x/sfinae4.C: Adjust expected result after P1009.
	* g++.dg/cpp2a/new-array1.C: New test.
	* g++.dg/cpp2a/new-array2.C: New test.
	* g++.dg/cpp2a/new-array3.C: New test.
	* g++.dg/cpp2a/new-array4.C: New test.

Co-authored-by: Jason Merrill <jason@redhat.com>
2020-08-31 16:09:10 -04:00
David Malcolm
0d1b4edc5f analyzer: fix ICE on RANGE_EXPR in CONSTRUCTORs [PR96763]
gcc/analyzer/ChangeLog:
	PR analyzer/96763
	* store.cc (binding_map::apply_ctor_to_region): Handle RANGE_EXPR
	by calling a new binding_map::apply_ctor_val_to_range subroutine.
	Split out the existing non-CONSTRUCTOR-handling code to a new
	apply_ctor_pair_to_child_region subroutine.
	(binding_map::apply_ctor_val_to_range): New.
	(binding_map::apply_ctor_pair_to_child_region): New, split out
	from binding_map::apply_ctor_to_region as noted above.
	* store.h (binding_map::apply_ctor_val_to_range): New decl.
	(binding_map::apply_ctor_pair_to_child_region): New decl.

gcc/testsuite/ChangeLog:
	PR analyzer/96763
	* g++.dg/analyzer/pr96763.C: New test.
2020-08-31 16:07:46 -04:00
David Malcolm
ecdb93224c analyzer: fix ICE on casting float to pointer [PR96764]
gcc/analyzer/ChangeLog:
	PR analyzer/96764
	* region-model-manager.cc
	(region_model_manager::maybe_fold_unaryop): Handle VIEW_CONVERT_EXPR.
	(region_model_manager::get_or_create_cast): Move logic for
	real->integer casting to...
	(get_code_for_cast): ...this new function, and add logic for
	real->non-integer casts.
	(region_model_manager::maybe_fold_sub_svalue): Handle
	VIEW_CONVERT_EXPR.
	* region-model.cc
	(region_model::add_any_constraints_from_gassign): Likewise.
	* svalue.cc (svalue::maybe_undo_cast): Likewise.
	(unaryop_svalue::dump_to_pp): Likewise.

gcc/testsuite/ChangeLog:
	PR analyzer/96764
	* gcc.dg/analyzer/pr96764.c: New test.
2020-08-31 16:06:50 -04:00
Aldy Hernandez
d503cd9871 PR tree-optimization/96818 - cast label range to type of switch operand
PR tree-optimization/96818
	* tree-vrp.c (find_case_label_range): Cast label range to
	type of switch operand.
2020-08-31 16:55:16 +02:00
Iain Buclaw
6940c20bbb d: Fix ICEs in the front-end when pointer size is 16-bit.
In the lowering of `bt*' intrinsics, some integer constants had
mismatched types, and bitsize was set to the wrong value.

In base_vtable_offset, the base offset value was calculated incorrectly.
The TypeInfo_Class object is comprised of 18 pointers and 1 uint field,
so now the internal classinfo type size is used instead.

gcc/d/ChangeLog:

	* d-target.cc (Target::_init): Don't set classinfosize.
	* d-tree.h (base_vtable_offset): Move under typeinfo.cc section.
	* decl.cc (base_vtable_offset): Move to...
	* typeinfo.cc (base_vtable_offset): ...here.  Get base offset from
	internal TypeInfo_Class type.
	* intrinsics.cc (expand_intrinsic_bt): Use pointer TYPE_SIZE for
	setting bitsize value.  Build integer constants of correct type.
2020-08-31 15:53:44 +02:00
Richard Biener
f089569851 tree-optimization/96854 - testcase for SLP reduction of two-operator
This adds the testcase for the already fixed PR.

2020-08-31  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/96854
	* gcc.dg/vect/pr96854.c: New testcase.
2020-08-31 13:42:31 +02:00
Christophe Lyon
371fa005ae testsuite: Fix aarch64/strcmpopt_6.c for -Wstringop-overread
2020-08-31  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/testsuite/
	* gcc.target/aarch64/strcmpopt_6.c: Suppress -Wstringop-overread.
2020-08-31 10:42:12 +00:00
liuhongt
1aa71af093 Refine expander vec_unpacku_float_hi_v16si/vec_unpacku_float_lo_v16si
gcc/
	PR target/96551
	* config/i386/sse.md (vec_unpacku_float_hi_v16si): For vector
	compare to integer mask, don't use gen_rtx_LT, use
	ix86_expand_mask_vec_cmp instead.
	(vec_unpacku_float_hi_v16si): Ditto.

gcc/testsuite
	* gcc.target/i386/avx512f-pr96551-1.c: New test.
	* gcc.target/i386/avx512f-pr96551-2.c: New test.
2020-08-31 17:43:59 +08:00
Jakub Jelinek
39f5b72484 tree-cfg: Improve gimple switch verification
When looking at the verification, I have noticed a bug in it.

The verification that CASE_HIGH (if present) has the same type as CASE_LOW
is only performed for the case label 2 and higher, case label 1 (the first
one after the default label) isn't checked.

The following patch fixes that, it will uselessly also compare
TREE_TYPE (CASE_LOW (elt)) != elt_type for the case label 1, but I think
that isn't that expensive and helps readability of the code.

2020-08-31  Jakub Jelinek  <jakub@redhat.com>

	* tree-cfg.c (verify_gimple_switch): If the first non-default case
	label has CASE_HIGH, verify it has the same type as CASE_LOW.
2020-08-31 10:51:02 +02:00
Feng Xue
e11c4b7f83 ipa/96806 - Fix ICE in ipa-cp due to integer addition overflow
2020-08-31  Feng Xue  <fxue@os.amperecomputing.com>

gcc/
	PR tree-optimization/96806
	* ipa-cp.c (decide_about_value): Use safe_add to avoid cost addition
	overflow.

gcc/testsuite/
	PR tree-optimization/96806
	* g++.dg/ipa/pr96806.C: New test.
2020-08-31 16:34:56 +08:00
Jakub Jelinek
0106300f6c varasm: Optimize memory broadcast for constant vector under AVX512 [PR54201]
I meant something like the following, which on e.g. a dumb:

typedef float V __attribute__((vector_size (4 * sizeof (float))));

void
foo (V *p, float *q)
{
  p[0] += (V) { 1.0f, 2.0f, 3.0f, 4.0f };
  q[0] += 4.0f;
  q[1] -= 3.0f;
  q[17] -= 2.0f;
  q[31] += 1.0f;
}

testcase merges all the 4 scalar constant pool entries into the CONST_VECTOR
one.

I'm punting for section anchors and not doing it in the per-function (i.e.
non-shared) constant pools simply because I don't know them well enough,
don't know whether backends use the offsets for something etc.
For section anchors, I guess it would need to be done before (re)computing the
offsets and arrange for the desc->mark < 0 entries not to be considered as
objects in the object block, for non-shared pools, perhaps it would be
enough to call the new function from output_constant_pool before calling
recompute_pool_offsets and adjust recompute_pool_offsets to ignore
desc->mark < 0.

Here is an adjusted patch that ought to merge even the same sized different
mode vectors with the same byte representation, etc.
It won't really help with avoiding the multiple reads of the constant in the
same function, but as you found, your patch doesn't help with that either.
Your patch isn't really incompatible with what the patch below does, though
I wonder whether a) it wouldn't be better to always canonicalize to an
integral mode with as few elts as possible even e.g. for floats b) whether
asserting that it simplify_rtx succeeds is safe, whether it shouldn't just
canonicalize if the canonicalization works and just do what it previously
did otherwise.

The following patch puts all pool entries which can be natively encoded
into a vector, sorts it by decreasing size, determines minimum size
of a pool entry and adds hash elts for each (aligned) min_size or wider
power of two-ish portion of the pool constant in addition to the whole pool
constant byte representation.

This is the version that passed bootstrap/regtest on both x86_64-linux and
i686-linux.  In both bootstraps/regtests together, it saved (from the
statistics I've gathered) 63104 .rodata bytes (before constant merging),
in 6814 hits of the data->desc->mark = ~(*slot)->desc->labelno;.

2020-08-31  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/54201
	* varasm.c: Include alloc-pool.h.
	(output_constant_pool_contents): Emit desc->mark < 0 entries as
	aliases.
	(struct constant_descriptor_rtx_data): New type.
	(constant_descriptor_rtx_data_cmp): New function.
	(struct const_rtx_data_hasher): New type.
	(const_rtx_data_hasher::hash, const_rtx_data_hasher::equal): New
	methods.
	(optimize_constant_pool): New function.
	(output_shared_constant_pool): Call it if TARGET_SUPPORTS_ALIASES.
2020-08-31 10:27:00 +02:00
Kewen Lin
d0939f42dd testsuite: Update some vect cases for partial vectors
This patch is to adjust some existing vectorization test cases
to work well with the newly introduced partial vector usages.

Bootstrapped/regtested on aarch64-linux-gnu and powerpc64le-linux-gnu
P9 (with explicit param vect-partial-vector-usage=1 and enablement on
check_effective_target_vect_partial_vectors_usage_1 check).

gcc/ChangeLog:

	* doc/sourcebuild.texi (vect_len_load_store,
	vect_partial_vectors_usage_1, vect_partial_vectors_usage_2,
	vect_partial_vectors): Document.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/bb-slp-pr69907.c: Adjust for partial vector usages.
	* gcc.dg/vect/slp-3.c: Likewise.
	* gcc.dg/vect/slp-multitypes-11.c: Likewise.
	* gcc.dg/vect/slp-perm-1.c: Likewise.
	* gcc.dg/vect/slp-perm-5.c: Likewise.
	* gcc.dg/vect/slp-perm-6.c: Likewise.
	* gcc.dg/vect/slp-perm-7.c: Likewise.
	* gcc.dg/vect/slp-perm-8.c: Likewise.
	* gcc.dg/vect/slp-perm-9.c: Likewise.
	* gcc.dg/vect/vect-version-2.c: Likewise.
	* lib/target-supports.exp (check_vect_partial_vector_usage): New
	function.
	(check_effective_target_vect_len_load_store): Likewise.
	(check_effective_target_vect_partial_vectors_usage_1): Likewise.
	(check_effective_target_vect_partial_vectors_usage_2): Likewise.
	(check_effective_target_vect_partial_vectors): Likewise.
2020-08-30 19:52:03 -05:00
GCC Administrator
cf2bc8617a Daily bump. 2020-08-31 00:16:22 +00:00
Martin Sebor
6ccadc4c04 Use get_size_range instead of get_range to obtain range of valid sizes.
gcc/ChangeLog:

	* builtins.c (access_ref::access_ref): Call get_size_range instead
	of get_range.

gcc/testsuite/ChangeLog:

	* gcc.dg/Wstringop-overread-3.c: New test.
2020-08-30 15:11:48 -06:00
José Rui Faustino de Sousa
a240e83ce9 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
gcc/fortran/ChangeLog:

	PR fortran/96728
	* module.c (module_peek_char): Peek ahead function.
	(parse_integer): Add code for parsing signed integers.
	(parse_atom): Add code to handle signed integers.
	(peek_atom): Add code to handle signed integers.

gcc/testsuite/ChangeLog:

	PR fortran/96728
	* gfortran.dg/PR96728.f90: New test.
2020-08-30 18:10:15 +00:00
José Rui Faustino de Sousa
3a7a95a220 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
gcc/fortran/ChangeLog:

	PR fortran/96727
	* expr.c (gfc_check_init_expr): Add default error message for the AS_ASSUMED_RANK case.

gcc/testsuite/ChangeLog:

	PR fortran/96727
	* gfortran.dg/PR96727.f90: New test.
2020-08-30 18:03:13 +00:00
José Rui Faustino de Sousa
8f7d99acf6 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
gcc/fortran/ChangeLog:

	PR fortran/96726
	* expr.c (check_references): Change different relational operator
	to less-than operator to avoid infinite loop.

gcc/testsuite/ChangeLog:

	PR fortran/96726
	* gfortran.dg/PR96726.f90: New test.
2020-08-30 17:58:13 +00:00
Steve Kargl
cd49b70678 2020-8-21 Steve Kargl <sgk@troutmask.apl.washington.edu>
gcc/fortran/ChangeLog:

	PR fortran/95352
	* simplify.c (simplify_bound_dim): Add check for NULL pointer
	before trying to access structure member.

	    José Rui Faustino de Sousa  <jrfsousa@gmail.com>

gcc/testsuite/ChangeLog:

	* gfortran.dg/PR95352.f90: New test.
2020-08-30 17:49:25 +00:00
José Rui Faustino de Sousa
8e1be7efcb 2020-8-20 José Rui Faustino de Sousa <jrfsousa@gmail.com>
gcc/fortran/ChangeLog:

	PR fortran/94110
	* interface.c (gfc_compare_actual_formal): Add code to also raise
	the actual argument cannot be an assumed-size array error when the
	dummy arguments are deferred-shape or assumed-rank pointer.

gcc/testsuite/ChangeLog:

	PR fortran/94110
	* gfortran.dg/PR94110.f90: New test.
2020-08-30 17:28:08 +00:00
Jakub Jelinek
44c677d1eb x86: Fix up ssse3_pshufbv8qi splitter
The constant pool size optimization I was testing resulted in various ICEs
in gcc.target/i386/ testsuite, the problem is that the ssse3_pshufbv8qi
splitter emits invalid RTL, in V4SImode 0xf7f7f7f7 CONST_INTs shouldn't
appear, instead they should have been -0x8080809 (0xf7f7f7f7 sign extended
into 64 bits).

2020-08-30  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/sse.md (ssse3_pshufbv8qi): Use gen_int_mode instead of
	GEN_INT, and ix86_build_const_vector instead of gen_rtvec and
	gen_rtx_CONT_VECTOR.
2020-08-30 14:15:45 +02:00
GCC Administrator
daba4a713e Daily bump. 2020-08-30 00:16:20 +00:00
Jonathan Wakely
0789600c59 libstdc++: Fix deleted overload of __absu(bool)
libstdc++-v3/ChangeLog:

	* include/std/numeric (__detail::__absu(bool)): Make deleted
	function a function template, so it will be chosen for calls
	with an explicit template argument list.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Add dg-prune-output.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
2020-08-29 18:24:08 +01:00
Bill Schmidt
cd0233527a rs6000: Remove ALTIVEC_BUILTIN_MASK_FOR_STORE
It turns out that the target hook that this is supposed to satisfy
disappeared in 2004.  Probably time to retire it.

2020-08-28  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin.def (MASK_FOR_STORE): Remove.
	* config/rs6000/rs6000-call.c (rs6000_expand_builtin): Remove
	all logic for ALTIVEC_BUILTIN_MASK_FOR_STORE.
2020-08-28 20:05:58 -05:00
GCC Administrator
8f7ea26ae3 Daily bump. 2020-08-29 00:16:21 +00:00
Jonathan Wakely
f2f48b68a6 libstdc++: Fix common_type specializations for duration
My recent change to implement P0548 ("common_type and duration") was not
correct. The result of common_type_t<duration<R,P>, duration<R,P>>
should be duration<common_type_t<R>, P::type>, not duration<R, P::type>.
The common_type specialization for two different duration types was
correct, but the specializations for a single duration type (which only
exist to optimize compilation time) were wrong.

This fixes the partial specializations of common_type for a single
duration type, and also the return types of duration::operator+ and
duration::operator- which are supposed to use common_type_t<duration>.

libstdc++-v3/ChangeLog:

	* include/std/chrono (common_type): Fix partial specializations
	for a single duration type to use the common_type of the rep.
	(duration::operator+, duration::operator-): Fix return types
	to also use the common_type of the rep.
	* testsuite/20_util/duration/requirements/reduced_period.cc:
	Check duration using a rep that has common_type specialized.
2020-08-28 23:41:13 +01:00
Jonathan Wakely
82db1a42e9 libstdc++: Fix std::gcd and std::lcm for unsigned integers [PR 92978]
This fixes a bug with mixed signed and unsigned types, where converting
a negative value to the unsigned result type alters the value. The
solution is to obtain the absolute values of the arguments immediately
and to perform the actual GCD or LCM algorithm on two arguments of the
same type.

In order to operate on the most negative number without overflow when
taking its absolute, use an unsigned type for the result of the abs
operation. For example, -INT_MIN will overflow, but -(unsigned)INT_MIN
is (unsigned)INT_MAX+1U which is the correct value.

libstdc++-v3/ChangeLog:

	PR libstdc++/92978
	* include/std/numeric (__abs_integral): Replace with ...
	(__detail::__absu): New function template that returns an
	unsigned type, guaranteeing it can represent the most
	negative signed value.
	(__detail::__gcd, __detail::__lcm): Require arguments to
	be unsigned and therefore already non-negative.
	(gcd, lcm): Convert arguments to absolute value as unsigned
	type before calling __detail::__gcd or __detail::__lcm.
	* include/experimental/numeric (gcd, lcm): Likewise.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust expected
	errors.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/26_numerics/gcd/92978.cc: New test.
	* testsuite/26_numerics/lcm/92978.cc: New test.
	* testsuite/experimental/numeric/92978.cc: New test.
2020-08-28 23:03:28 +01:00
Martin Sebor
d14c547abd Add -Wstringop-overread for reading past the end by string functions.
gcc/ChangeLog:

	* attribs.c (init_attr_rdwr_indices): Use global access_mode.
	* attribs.h (struct attr_access): Same.
	* builtins.c (fold_builtin_strlen): Add argument.
	(compute_objsize): Declare.
	(get_range): Declare.
	(check_read_access): New function.
	(access_ref::access_ref): Define ctor.
	(warn_string_no_nul): Add arguments.  Handle -Wstrintop-overread.
	(check_nul_terminated_array): Handle source strings of different
	ranges of sizes.
	(expand_builtin_strlen): Remove warning code, call check_read_access
	instead.  Declare locals closer to their initialization.
	(expand_builtin_strnlen): Same.
	(maybe_warn_for_bound): New function.
	(warn_for_access): Remove argument.  Handle -Wstrintop-overread.
	(inform_access): Change argument type.
	(get_size_range): New function.
	(check_access): Remove unused arguments.  Add new arguments.  Handle
	-Wstrintop-overread.  Move warning code to helpers and call them.
	Call check_nul_terminated_array.
	(check_memop_access): Remove unnecessary and provide additional
	arguments in calls.
	(expand_builtin_memchr): Call check_read_access.
	(expand_builtin_strcat): Remove unnecessary and provide additional
	arguments in calls.
	(expand_builtin_strcpy): Same.
	(expand_builtin_strcpy_args): Same.  Avoid testing no-warning bit.
	(expand_builtin_stpcpy_1): Remove unnecessary and provide additional
	arguments in calls.
	(expand_builtin_stpncpy): Same.
	(check_strncat_sizes): Same.
	(expand_builtin_strncat): Remove unnecessary and provide additional
	arguments in calls.  Adjust comments.
	(expand_builtin_strncpy): Remove unnecessary and provide additional
	arguments in calls.
	(expand_builtin_memcmp): Remove warning code.  Call check_access.
	(expand_builtin_strcmp): Call check_access instead of
	check_nul_terminated_array.
	(expand_builtin_strncmp): Handle -Wstrintop-overread.
	(expand_builtin_fork_or_exec): Call check_access instead of
	check_nul_terminated_array.
	(expand_builtin): Same.
	(fold_builtin_1): Pass additional argument.
	(fold_builtin_n): Same.
	(fold_builtin_strpbrk): Remove calls to check_nul_terminated_array.
	(expand_builtin_memory_chk): Add comments.
	(maybe_emit_chk_warning): Remove unnecessary and provide additional
	arguments in calls.
	(maybe_emit_sprintf_chk_warning): Same.  Adjust comments.
	* builtins.h (warn_string_no_nul): Add arguments.
	(struct access_ref): Add member and ctor argument.
	(struct access_data): Add members and ctor.
	(check_access): Adjust signature.
	* calls.c (maybe_warn_nonstring_arg): Return an indication of
	whether a warning was issued.  Issue -Wstrintop-overread instead
	of -Wstringop-overflow.
	(append_attrname): Adjust to naming changes.
	(maybe_warn_rdwr_sizes): Same.  Remove unnecessary and provide
	additional arguments in calls.
	* calls.h (maybe_warn_nonstring_arg): Return bool.
	* doc/invoke.texi (-Wstringop-overread): Document new option.
	* gimple-fold.c (gimple_fold_builtin_strcpy): Provide an additional
	argument in call.
	(gimple_fold_builtin_stpcpy): Same.
	* tree-ssa-uninit.c (maybe_warn_pass_by_reference): Adjust to naming
	changes.
	* tree.h (enum access_mode): New type.

gcc/c-family/ChangeLog:

	* c.opt (Wstringop-overread): New option.

gcc/testsuite/ChangeLog:

	* c-c++-common/Warray-bounds-7.c: Adjust expected warnings.
	* c-c++-common/Wrestrict.c: Remove xfail.
	* c-c++-common/attr-nonstring-3.c: Adjust text of expected warnings.
	* c-c++-common/attr-nonstring-6.c: Suppress -Wstringop-overread
	instead of -Wstringop-overflow.
	* c-c++-common/attr-nonstring-8.c: Adjust text of expected warnings.
	* g++.dg/torture/Wsizeof-pointer-memaccess1.C: Also suppress
	 -Wstringop-overread.
	* g++.dg/torture/Wsizeof-pointer-memaccess2.C: Same.
	* gcc.dg/Warray-bounds-39.c: Adjust expected warnings.
	* gcc.dg/Warray-bounds-40.c: Also suppress -Wstringop-overread.
	* gcc.dg/Warray-bounds-58.c: Remove xfail.  Also expect
	-Wstringop-overread.  Adjust text of expected warnings.
	* gcc.dg/Wsizeof-pointer-memaccess1.c: Also suppress
	 -Wstringop-overread.
	* gcc.dg/Wstringop-overflow-22.c: Adjust text of expected warnings.
	* gcc.dg/Wstringop-overflow-33.c: Expect -Wstringop-overread.
	* gcc.dg/Wstringop-overflow-9.c: Expect -Wstringop-overread.
	* gcc.dg/attr-nonstring-2.c: Adjust text of expected warnings.
	* gcc.dg/attr-nonstring-3.c: Same.
	* gcc.dg/attr-nonstring-4.c: Same.
	* gcc.dg/attr-nonstring.c: Expect -Wstringop-overread.
	* gcc.dg/builtin-stringop-chk-5.c: Adjust comment.
	* gcc.dg/builtin-stringop-chk-8.c: Enable -Wstringop-overread instead
	of -Wstringop-overflow.
	* gcc.dg/pr78902.c: Also expect -Wstringop-overread.
	* gcc.dg/pr79214.c: Adjust text of expected warnings.
	* gcc.dg/strcmpopt_10.c: Suppress valid -Wno-stringop-overread.
	* gcc.dg/strlenopt-57.c: Also expect -Wstringop-overread.
	* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Also suppress valid
	-Wno-stringop-overread.
	* gcc.dg/tree-ssa/builtins-folding-gimple-ub.c: Same.
	* gcc.dg/uninit-33.c: Same.
	* gcc.dg/warn-strnlen-no-nul-2.c: Adjust text of expected warning.
	* gcc.dg/warn-strnlen-no-nul.c: Same.
	* gcc.target/i386/strcmpopt_6.c: Suppress -Wstringop-overread.
	* gcc.dg/Wstringop-overread-2.c: New test.
	* gcc.dg/Wstringop-overread.c: New test.
2020-08-28 13:18:28 -06:00
Bill Schmidt
26c24398d3 rs6000: r12 copy cleanup
Remove unnecessary tests before copying function address to r12.

2020-08-28  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000.c (rs6000_call_aix): Remove test for r12.
	(rs6000_sibcall_aix): Likewise.
2020-08-28 11:47:01 -05:00
Andrew Stubbs
1c1e41b065 amdgcn: Update vec_safe_grow_cleared usage
An API change broke the amdgcn build.

gcc/ChangeLog:

	* config/gcn/gcn-tree.c (gcn_goacc_get_worker_red_decl): Add "true"
	parameter to vec_safe_grow_cleared.
2020-08-28 15:43:06 +01:00
Martin Sebor
1ad755dcbb Correct calls to vec::safe_grow in conditionally compiled code.
gcc/ChangeLog:

	* ggc-common.c (gt_pch_save): Add argument to a call.

gcc/jit/ChangeLog:

	* jit-recording.c (recording::switch_::make_debug_string): Add argument
	to a call.
2020-08-28 08:31:50 -06:00
Martin Sebor
ba6373a397 PR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with invalid array argument
gcc/c/ChangeLog:

	PR c/96596
	* c-decl.c (match_builtin_function_types): Avoid dealing with erroneous
	argument type.

gcc/testsuite/ChangeLog:

	PR c/96596
	* gcc.dg/Wbuiltin-declaration-mismatch-16.c: New test.
2020-08-28 08:26:32 -06:00
Tobias Burnus
cb3c3d6331 Fortran: Fix absent-optional handling for nondescriptor arrays (PR94672)
gcc/fortran/ChangeLog:

	PR fortran/94672
	* trans-array.c (gfc_trans_g77_array): Check against the parm decl and
	set the nonparm decl used for the is-present check to NULL if absent.

gcc/testsuite/ChangeLog:

	PR fortran/94672
	* gfortran.dg/optional_assumed_charlen_2.f90: New test.
2020-08-28 13:54:10 +02:00