Commit Graph

192476 Commits

Author SHA1 Message Date
Xi Ruoyao 6e34507862
loongarch: testsuite: skip builtin-apply2.c
On LoongArch, variadic functions use different arugment passing
conventions so this test is not valid (see the section named "Variadic
argument" in the [ELF ABI][1]) and should be skipped.

[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

gcc/testsuite/

	* gcc.dg/builtin-apply2.c (dg-skip-if): Add loongarch*-*-*.
2022-04-09 19:41:53 +08:00
Jason Merrill 4822108e61 c++: constexpr non-trivial aggregate init [PR105191]
My patch for PR92385 made us use VEC_INIT_EXPR for aggregate initialization
of an array where some elements are not explicitly initialized.  Constexpr
handling of that was treating initialization from {} as equivalent to
value-initialization, which is problematic for classes with default member
initializers that make the default constructor non-trivial; in older
standard modes, not initializing all members makes a constructor
non-constexpr, but aggregate initialization is fine.

	PR c++/105191
	PR c++/92385

gcc/cp/ChangeLog:

	* tree.cc (build_vec_init_elt): Do {}-init for aggregates.
	* constexpr.cc (cxx_eval_vec_init): Only treat {} as value-init
	for non-aggregate types.
	(build_vec_init_expr): Also check constancy of explicit
	initializer elements.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-array28.C: New test.
2022-04-08 23:25:54 -04:00
Jason Merrill 58586721c7 c++: friend implicit template instantiation [PR91618]
This rule that for a friend with a qualified name we try to find a
matching template was already in C++98, but it seems we never implemented
it, and nobody reported it until 2019.

This patch sets DECL_IMPLICIT_INSTANTIATION to signal to
check_explicit_specialization that we want to find a template, like
grokfndecl already did for explicit template args.  check_classfn also needs
to call it, as check_classfn is called after the call to
check_explicit_specialization in grokfndecl, whereas the call to
set_decl_namespace comes sooner.  This inconsistency is inelegant, but safer
at this point in the release cycle; I'll unify them in stage 1.

	PR c++/91618
	PR c++/96604

gcc/cp/ChangeLog:

	* name-lookup.cc (set_decl_namespace): Set
	DECL_IMPLICIT_INSTANTIATION if no non-template match.
	* pt.cc (check_explicit_specialization): Check it.
	* decl2.cc (check_classfn): Call it.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/friend7.C: Remove xfail.
	* g++.dg/template/friend72.C: New test.
	* g++.dg/template/friend72a.C: New test.
	* g++.dg/template/friend73.C: New test.
2022-04-08 21:50:46 -04:00
GCC Administrator 405eda0d34 Daily bump. 2022-04-09 00:16:56 +00:00
Jonathan Wakely 7b4495d3c4 libstdc++: Fix constraints on std::expected<void, E> constructor [PR105153]
libstdc++-v3/ChangeLog:

	PR libstdc++/105153
	* include/std/expected
	(expected<void,E>::expected(expected<U,G>&&)): Fix constraints.
	* testsuite/20_util/expected/cons.cc: Check constructor.
2022-04-08 18:30:07 +01:00
Jonathan Wakely 0dfaf56252 libstdc++: Fix std::expected<void, E>::swap(expected&) [PR105154]
libstdc++-v3/ChangeLog:

	PR libstdc++/105154
	* include/std/expected (expected<void, E>::swap): Set
	_M_has_value to false for objects that previously had a value.
	* testsuite/20_util/expected/swap.cc: Fix test to check void
	specialization.
2022-04-08 18:30:06 +01:00
Jonathan Wakely 29e355d0d6 libstdc++: Fix std::bad_expected_access constructor [PR105146]
libstdc++-v3/ChangeLog:

	PR libstdc++/105146
	* include/std/expected (bad_expected_access): Move constructor
	parameter.
	* testsuite/20_util/expected/bad.cc: New test.
2022-04-08 18:30:06 +01:00
Andre Vieira 5522dec054 aarch64: PR target/105157 Increase number of cores TARGET_CPU_DEFAULT can encode
This addresses the compile-time increase seen in the PR target/105157. This was
being caused by selecting the wrong core tuning, as when we added the latest
AArch64 the TARGET_CPU_generic tuning was pushed beyond the 0x3f mask we used
to encode both target cpu and attributes into TARGET_CPU_DEFAULT.

gcc/ChangeLog:

	PR target/105157
	* config.gcc: Shift ext_mask by TARGET_CPU_NBITS.
	* config/aarch64/aarch64.h (TARGET_CPU_NBITS): New macro.
	(TARGET_CPU_MASK): Likewise.
	(TARGET_CPU_DEFAULT): Use TARGET_CPU_NBITS.
	* config/aarch64/aarch64.cc (aarch64_get_tune_cpu): Use TARGET_CPU_MASK.
	(aarch64_get_arch): Likewise.
	(aarch64_override_options): Use TARGET_CPU_NBITS.
2022-04-08 15:12:23 +01:00
Richard Biener e5453bcc21 tree-optimization/105198 - wrong code with predictive commoning
When predictive commoning looks for a looparound PHI it tries
to match the entry value definition (a load) up with the appropriate
member of the chain.  But it fails to consider stmts clobbering
the very same memory location inbetween the load and loop entry.

In theory we could be more clever on must aliases that would be
also picked up from a load (so not exactly stmt_kills_ref_p) and
use the stored value from that if it is an exact match.  But we
currently have no way to propagate this information inside predcom.

2022-04-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105198
	* tree-predcom.cc (find_looparound_phi): Check whether
	the found memory location of the entry value is clobbered
	inbetween the value we want to use and loop entry.

	* gcc.dg/torture/pr105198.c: New testcase.
2022-04-08 14:18:31 +02:00
Jakub Jelinek 04ecadbeae testsuite: Fix up 20050113-1.c test for i686-linux [PR105187]
The test FAILs on i686-linux if neither MMX isn't enabled, can be also
reproduced with
make check-gcc check-g++ RUNTESTFLAGS='--target_board=unix/-m32/-mno-mmx/-mno-sse dg-torture.exp=20050113-1.c'
on x86_64-linux.  Previously the test was in gcc.c-torture/compile/
where -w is added by default.

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

	PR c++/105187
	* c-c++-common/torture/20050113-1.c: Add dg-additional-options
	-Wno-psabi.
2022-04-08 09:51:02 +02:00
Jakub Jelinek 6e27436872 c: Error on va_arg with function type [PR105149]
In the PR Joseph said that the C standard for va_arg talks about
pointers to object type and as a function type is not object type,
it is invalid.

The following patch diagnoses it in the FE, instead of ICEing later on
when optimizations are turned on (and with -O0 doing something weird
at runtime).

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

	PR c/105149
	* c-typeck.cc (c_build_va_arg): Reject function types.

	* gcc.dg/pr105149.c: New test.
2022-04-08 09:16:30 +02:00
Jakub Jelinek 5e6597064b fold-const: Fix up make_range_step [PR105189]
The following testcase is miscompiled, because fold_truth_andor
incorrectly folds
(unsigned) foo () >= 0U && 1
into
foo () >= 0
For the unsigned comparison (which is useless in this case,
as >= 0U is always true, but hasn't been folded yet), previous
make_range_step derives exp (unsigned) foo () and +[0U, -]
range for it.  Next we process the NOP_EXPR.  We have special code
for unsigned to signed casts, already earlier punt if low or high
aren't representable in arg0_type or if it is a narrowing conversion.
For the signed to unsigned casts, I think if high is specified we
are still fine, as we punt for non-representable values in arg0_type,
n_high is then still representable and so was smaller or equal to
signed maximum and either low is not present (equivalent to 0U), or
low must be smaller or equal to high and so for unsigned exp
+[low, high] the signed exp +[n_low, n_high] will be correct.
Similarly, if both low and high aren't specified (always true or
always false), it is ok too.
But if we have for unsigned exp +[low, -] or -[low, -], using
+[n_low, -] or -[n_high, -] is incorrect.  Because low is smaller
or equal to signed maximum and high is unspecified (i.e. unsigned
maximum), when signed that range is a union of +[n_low, -] and
+[-, -1] which is equivalent to -[0, n_low-1], unless low
is 0, in that case we can treat it as [-, -].

2022-04-08  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105189
	* fold-const.cc (make_range_step): Fix up handling of
	(unsigned) x +[low, -] ranges for signed x if low fits into
	typeof (x).

	* g++.dg/torture/pr105189.C: New test.
2022-04-08 09:14:44 +02:00
Sergei Trofimovich cef0372823 libgcc: IA64: don't compile glibc-based unwinder without libc headers
In --without-headers mode gcc fails to bootstrap on libgcc as:

    /build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c fde-glibc.c
    ../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10:
        fatal error: stdlib.h: No such file or directory

Most other linux targets are able to build the --without-headers
compiler without additional effort. This change adds IA64 to the fold.

The change drops part of the code that relies on DYNAMIC glibc
section traversal for backtraces.

Tested bootstrap of ia64-unknown-linux-gnu with and without libc
headers present.

libgcc/
	* config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode.
2022-04-08 08:01:06 +01:00
Richard Biener b789c44c64 tree-optimization/105175 - avoid -Wvector-operation-performance
This avoids -Wvector-operation-performance diagnostics for vectorizer
produced code.  It's unfortunate the warning_at code in
tree-vect-generic.cc needs adjustments but the diagnostic suppression
code doesn't magically suppress those otherwise.

2022-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105175
	* tree-vect-stmts.cc (vectorizable_operation): Suppress
	-Wvector-operation-performance if using emulated vectors.
	* tree-vect-generic.cc (expand_vector_piecewise): Do not diagnose
	-Wvector-operation-performance when suppressed.
	(expand_vector_parallel): Likewise.
	(expand_vector_comparison): Likewise.
	(expand_vector_condition): Likewise.
	(lower_vec_perm): Likewise.
	(expand_vector_conversion): Likewise.

	* gcc.dg/pr105175.c: New testcase.
2022-04-08 08:34:06 +02:00
GCC Administrator df00d10320 Daily bump. 2022-04-08 00:16:21 +00:00
Michael Meissner 45fb78c9c4 Disable float128 tests on VxWorks, PR target/104253.
In PR target/104253, it was pointed out the that test case added as part
of fixing the PR does not work on VxWorks because float128 is not
supported on that system.  I have modified the three tests for float128 so
that they are manually excluded on VxWorks systems.  In looking at the
code, I also added checks in check_effective_target_ppc_ieee128_ok to
disable the systems that will never support VSX instructions which are
required for float128 support (eabi, eabispe, darwin).

2022-04-07   Michael Meissner  <meissner@linux.ibm.com>

gcc/testsuite/
	PR target/104253
	* lib/target-supports.exp (check_ppc_float128_sw_available): Do
	not run float128 tests on VxWorks.
	(check_ppc_float128_hw_available): Likewise.
	(check_effective_target_ppc_ieee128_ok): Likewise.
2022-04-07 18:25:17 -04:00
Patrick Palka 7e7a96f774 c++: use after free during name lookup w/ modules [PR99479]
name_lookup::search_unqualified uses a statically allocated vector
in order to avoid repeated reallocation, under the assumption that
the function can't be called recursively.  With modules however,
this assumption turns out to be false, and search_unqualified can
be called recursively as demonstrated by the testcase in comment #19
of PR99479[1] where the recursive call causes the vector to get
reallocated which invalidates the reference to queue[ix] held by the
parent call.

This patch makes search_unqualified instead use an auto_vec with 16
elements of internal storage.  In turn we can simplify the API of some
member functions to take the vector by reference and return void.

[1]: https://gcc.gnu.org/PR99479#c19

	PR c++/99479

gcc/cp/ChangeLog:

	* name-lookup.cc (name_lookup::using_queue): Change to an
	auto_vec (with 16 elements of internal storage).
	(name_lookup::queue_namespace): Change return type to void,
	take queue parameter by reference and adjust function body
	accordingly.
	(name_lookup::do_queue_usings): Inline into ...
	(name_lookup::queue_usings): ... here.  As in queue_namespace.
	(name_lookup::search_unqualified): Don't make queue static,
	remove length variable, and adjust function body accordingly.
2022-04-07 16:09:52 -04:00
Tamar Christina 68163cc2de testsuite: delete slp scan from loop vect test.
I accidentally left in an slp1 check in the vect test which showed up as
UNRESOLVED and had missed it in the sum file.  This deletes that line.

gcc/testsuite/ChangeLog:

	PR testsuite/105196
	* gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c: Remove slp1 check.
2022-04-07 19:53:43 +01:00
Tamar Christina af3cadb59f AArch64: fix ls64 intrinsics expansion [PR104409]
The LS64 intrinsics used a machinery that's not safe to use unless being
called from a pragma instantiation.

This moves the initialization code to a new pragma for arm_acle.h.

gcc/ChangeLog:

	PR target/104409
	* config/aarch64/aarch64-builtins.cc (handle_arm_acle_h): New.
	(aarch64_general_init_builtins): Move LS64 code.
	* config/aarch64/aarch64-c.cc (aarch64_pragma_aarch64): Support
	arm_acle.h
	* config/aarch64/aarch64-protos.h (handle_arm_acle_h): New.
	* config/aarch64/arm_acle.h: Add pragma GCC aarch64 "arm_acle.h".
2022-04-07 16:48:05 +01:00
Richard Biener 8c0ebaf9f5 ipa/104303 - miscompilation of gnatmake
Modref attempts to track memory accesses relative to the base pointers
which are parameters of functions.
If it fails, it still makes difference between unknown memory access and
global memory access.  The second makes it possible to disambiguate with
memory that is not accessible from outside world (i.e. everything that does
not escape from the caller function).  This is useful so we do not punt
when unknown function is called.

The added ref_may_access_global_memory_p ends up using
ptr_deref_may_alias_global_p which does not consider escaped automatic
variables as global.  For modref those are still global since they
can be accessed from functions called.

The following adds a flag to the *_global_p APIs indicating whether
escaped local memory should be considered as global or not and
removes ref_may_access_global_memory_p in favor of using
ref_may_alias_global_p with the flag set to true.

2022-04-07  Richard Biener  <rguenther@suse.de>
	    Jan Hubicka  <hubicka@ucw.cz>

	PR ipa/104303
	* tree-ssa-alias.h (ptr_deref_may_alias_global_p,
	ref_may_alias_global_p, ref_may_alias_global_p,
	stmt_may_clobber_global_p, pt_solution_includes_global): Add
	bool parameters indicating whether escaped locals should be
	considered global.
	* tree-ssa-structalias.cc (pt_solution_includes_global):
	When the new escaped_nonlocal_p flag is true also consider
	pt->vars_contains_escaped.
	* tree-ssa-alias.cc (ptr_deref_may_alias_global_p):
	Pass down new escaped_nonlocal_p flag.
	(ref_may_alias_global_p): Likewise.
	(stmt_may_clobber_global_p): Likewise.
	(ref_may_alias_global_p_1): Likewise.  For decls also
	query the escaped solution if true.
	(ref_may_access_global_memory_p): Remove.
	(modref_may_conflict): Use ref_may_alias_global_p with
	escaped locals considered global.
	(ref_maybe_used_by_stmt_p): Adjust.
	* ipa-fnsummary.cc (points_to_local_or_readonly_memory_p):
	Likewise.
	* tree-ssa-dse.cc (dse_classify_store): Likewise.
	* trans-mem.cc (thread_private_new_memory): Likewise, but
	consider escaped locals global.
	* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Likewise.

	* gnat.dg/concat5.adb: New.
	* gnat.dg/concat5_pkg1.adb: Likewise.
	* gnat.dg/concat5_pkg1.ads: Likewise.
	* gnat.dg/concat5_pkg2.adb: Likewise.
	* gnat.dg/concat5_pkg2.ads: Likewise.
2022-04-07 15:03:36 +02:00
David Malcolm 88b939b19a analyzer: fix leak false +ve with symbolic writes [PR102208]
PR analyzer/102208 reports false positives from -Wanalyzer-malloc-leak.
The root cause is the analyzer getting confused about symbolic writes
that could alias a pointer referencing a malloced buffer.

struct st
{
  void *ptr;
  int arr[10];
};

struct st test (int idx)
{
  struct st s;
  s.ptr = __builtin_malloc (1024);  /* (1) */
  s.arr[idx] = 42;                  /* (2) */
  return s;
}

When removing overlapping bindings at (2),
store::remove_overlapping_bindings was failing to pass on the
uncertainty_t *, and thus when clobbering the binding of s.ptr, the
heap-allocated pointer was not being added to the set of maybe-bound
svalues, and thus being treated as leaking.

This patch fixes this, so that s.ptr from (1) is treated as maybe-bound
after the write at (2), fixing the leak false postive.

Doing so requires the store to be smarter about how clobbering happens
with various combinations of concrete keys and symbolic keys within
concrete clusters and symbolic clusters, so that we don't lose warnings
about definite leaks.

gcc/analyzer/ChangeLog:
	PR analyzer/102208
	* store.cc (binding_map::remove_overlapping_bindings): Add
	"always_overlap" param, using it to generalize to the case where
	we want to remove all bindings.  Update "uncertainty" logic to
	only record maybe-bound values for cases where there is a symbolic
	write involved.
	(binding_cluster::mark_region_as_unknown): Split param "reg" into
	"reg_to_bind" and "reg_for_overlap".
	(binding_cluster::maybe_get_compound_binding): Pass "false" to
	binding_map::remove_overlapping_bindings new "always_overlap" param.
	(binding_cluster::remove_overlapping_bindings): Determine
	"always_overlap" and pass it to
	binding_map::remove_overlapping_bindings.
	(store::set_value): Pass uncertainty to remove_overlapping_bindings
	call.  Update for new param of
	binding_cluster::mark_region_as_unknown, passing both the base
	region of the iter_cluster, and the lhs_reg.
	(store::mark_region_as_unknown): Update for new param of
	binding_cluster::mark_region_as_unknown, passing "reg" for both.
	(store::remove_overlapping_bindings): Add param "uncertainty", and
	pass it on to call to
	binding_cluster::remove_overlapping_bindings.
	* store.h (binding_map::remove_overlapping_bindings): Add
	"always_overlap" param.
	(binding_cluster::mark_region_as_unknown): Split param "reg" into
	"reg_to_bind" and "reg_for_overlap".
	(store::remove_overlapping_bindings): Add param "uncertainty".

gcc/testsuite/ChangeLog:
	PR analyzer/102208
	* gcc.dg/analyzer/symbolic-9.c: New test.
	* gcc.dg/analyzer/torture/leak-pr102308-1.c: New test.
	* gcc.dg/analyzer/torture/leak-pr102308-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-04-07 08:33:26 -04:00
Richard Biener 27bfd13437 tree-optimization/105185 - simplify modref query in SCCVN
This simplifies the modref query for calls in SCCVN again after
r12-8019-g4be08315124281, avoiding an ICE when the modref
analyzed access lacks an actual argument on the caller side.
It effectively reverts r12-7531-gdc46350d44c294.

2022-04-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105185
	* tree-ssa-sccvn.cc (visit_reference_op_call): Simplify
	modref query again.

	* gcc.dg/torture/pr105185.c: New testcase.
2022-04-07 10:12:55 +02:00
Tamar Christina 024edf0895 AArch64: Fix left fold sum reduction RTL patterns [PR104049]
As the discussion in the PR pointed out the RTL we have for the REDUC_PLUS
patterns are wrong.  The UNSPECs are modelled as returning a vector and then
in an expand pattern we emit a vec_select of the 0th element to get the scalar.

This is incorrect as the instruction itself already only returns a single scalar
and by declaring it returns a vector it allows combine to push in a subreg into
the pattern, which causes reload to make duplicate moves.

This patch corrects this by removing the weird indirection and making the RTL
pattern model the correct semantics of the instruction immediately.

gcc/ChangeLog:

	PR target/104049
	* config/aarch64/aarch64-simd.md
	(aarch64_reduc_plus_internal<mode>): Fix RTL and rename to...
	(reduc_plus_scal_<mode>): ... This.
	(reduc_plus_scal_v4sf): Moved.
	(aarch64_reduc_plus_internalv2si): Fix RTL and rename to...
	(reduc_plus_scal_v2si): ... This.

gcc/testsuite/ChangeLog:

	PR target/104049
	* gcc.target/aarch64/vadd_reduc-1.c: New test.
	* gcc.target/aarch64/vadd_reduc-2.c: New test.
2022-04-07 08:27:53 +01:00
Tamar Christina fdd81afcf1 testsuite: enable fast-math-complex-* testcases.
As pointed out in PR105095 these tests weren't running, mainly because the .exp
file contains a filter on the first character so it can distinguish between
fast-math-bb-slp-* and fast-math-*, my test started with `c` and so didn't get
found.

This patch adds `c` to the list of filters and also updates the output and
required guards for the testcases now that they run.

gcc/testsuite/ChangeLog:

	PR testsuite/105095
	* gcc.dg/vect/complex/fast-math-complex-add-double.c: Update for codegen.
	* gcc.dg/vect/complex/fast-math-complex-add-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-half-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-pattern-double.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-pattern-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-add-pattern-half-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mls-double.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mls-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mul-double.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mul-float.c: Likewise.
	* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c: Likewise.
	* gcc.dg/vect/vect.exp: Add extra letter to filter.
2022-04-07 08:26:36 +01:00
Tamar Christina 897b080e6d testsuite: skip PR103350 tests on big-endian
These tests are reduced from a C program and use gcc vector extensions and so
aren't endianness agnostic. As such skip them on BE.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/pr103350-1.c: Skip on BE.
	* gcc.target/aarch64/pr103350-2.c: Likewise.
2022-04-07 08:26:02 +01:00
Jakub Jelinek 46c739d40c c++: Handle __builtin_clear_padding on non-trivially-copyable types [PR102586]
On Fri, Feb 11, 2022 at 07:55:50PM +0100, Jakub Jelinek via Gcc-patches wrote:
> Something like the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c16
> will still be needed with adjusted testcase from
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c15 such that
> __builtin_clear_padding is called directly on var addresses rather than
> in separate functions.

Here is an updated version of the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102586#c15
patch which uses FIELD_DECL in the langhook instead of its TREE_TYPE,
and the testcases have been adjusted for the builtin accepting
pointers to non-trivially-copyable types only if it is address of a
declaration.

2022-04-07  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/102586
gcc/
	* langhooks.h (struct lang_hooks_for_types): Add classtype_as_base
	langhook.
	* langhooks-def.h (LANG_HOOKS_CLASSTYPE_AS_BASE): Define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add it.
	* gimple-fold.cc (clear_padding_type): Use ftype instead of
	TREE_TYPE (field) some more.  For artificial FIELD_DECLs without
	name try the lang_hooks.types.classtype_as_base langhook and
	if it returns non-NULL, use that instead of ftype for recursive call.
gcc/cp/
	* cp-objcp-common.h (cp_classtype_as_base): Declare.
	(LANG_HOOKS_CLASSTYPE_AS_BASE): Redefine.
	* cp-objcp-common.cc (cp_classtype_as_base): New function.
gcc/testsuite/
	* g++.dg/torture/builtin-clear-padding-5.C: New test.
	* g++.dg/cpp2a/builtin-clear-padding1.C (bar): Uncomment one
	call that is now accepted.
2022-04-07 09:14:07 +02:00
Jakub Jelinek 973a2ce71f tree.cc: Add tree_builtin_call_types_compatible_p [PR105150]
And here is the follow-up patch that does the argument checking
on GENERIC.  It ensures TYPE_MAIN_VARIANT == TYPE_MAIN_VARIANT
compatibility on the arguments, except for pointer arguments
where both builtin's prototype and actual arguments have to be
pointers and satisfy tree_nop_conversion_p, and for promoted
char/short arguments where argument need to have integral
signed type tree_nop_conversion_p compatible with integer_type_node.

2022-04-07  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105150
	* tree.cc (tree_builtin_call_types_compatible_p): New function.
	(get_call_combined_fn): Use it.

	* gcc.dg/pr105150.c: New test.
2022-04-07 09:10:58 +02:00
Richard Biener 54ed6563d2 middle-end/105165 - sorry instead of ICE for _Complex asm goto
Complex lowering cannot currently deal with asm gotos with _Complex
output operands.  Emit a sorry instead of ICEing, those should not
appear in practice.

2022-04-06  Richard Biener  <rguenther@suse.de>

	PR middle-end/105165
	* tree-complex.cc (expand_complex_asm): Sorry for asm goto
	_Complex outputs.

	* gcc.dg/pr105165.c: New testcase.
2022-04-07 08:17:05 +02:00
Andreas Krebbel 176df4ccb5 IBM zSystems/testsuite: PR105147: Skip pr105140.c
pr105140.c fails on IBM zSystems with "vector argument passed to
unprototyped function".  s390_invalid_arg_for_unprototyped_fn in
s390.cc is triggered by that.

gcc/testsuite/ChangeLog:

	PR target/105147
	* gcc.dg/pr105140.c: Skip for s390*-*-*.
2022-04-07 07:29:21 +02:00
liuhongt 83e4f0a776 Refine and/ior/xor/andn masked patterns for V*HFmode.
There's no masked vpandw or vpandb, similar for vpxor/vpor/vpandn.

gcc/ChangeLog:

	* config/i386/sse.md (<sse2_avx2>_andnot<mode>3_mask):
	Removed.
	(<sse>_andnot<mode>3<mask_name>): Disable V*HFmode patterns
	for mask_applied.
	(<code><mode>3<mask_name>): Ditto.
	(*<code><mode>3<mask_name>): Ditto.
	(VFB_128_256): Adjust condition of V8HF/V16HFmode according to
	real instruction.
	(VFB_512): Ditto.
	(VFB): Ditto.
2022-04-07 11:53:43 +08:00
Jason Merrill f44a5c700f c++: conversion with trailing return type [PR101051]
We've had a diagnostic for this, but since r10-6571 added an assert to
splice_late_return_type, we need to diagnose before we call it.

	PR c++/101051

gcc/cp/ChangeLog:

	* decl.cc (grokdeclarator): Reject conversion with trailing return
	sooner.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/trailing15.C: New test.
2022-04-06 23:26:08 -04:00
Jason Merrill 8e4339f502 c++: nested generic lambda in DMI [PR101717]
We were already checking COMPLETE_TYPE_P to recognize instantiation of a
generic lambda, but didn't consider that we might be nested in a non-generic
lambda.

	PR c++/101717

gcc/cp/ChangeLog:

	* lambda.cc (lambda_expr_this_capture): Check all enclosing
	lambdas for completeness.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/lambda-generic-this4.C: New test.
2022-04-06 23:25:56 -04:00
Hans-Peter Nilsson 2dda1094a7 libstdc++-v3 expected: Correct minimal-size test in requirements.cc
Without this, for a target where alignment and structure-sizes are by
default byte-aligned, such as cris-elf, you'll see, in libstdc++.log:

/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: error: static assertion failed
/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: note: the comparison reduces to '(5 == 2)'
compiler exited with status 1
FAIL: 20_util/expected/requirements.cc (test for excess errors)
Excess errors:
/X/gcc/libstdc++-v3/testsuite/20_util/expected/requirements.cc:127: error: static assertion failed

The intent of that line is to check that the object is not larger than
necessary.

libstdc++-v3/:
	* testsuite/20_util/expected/requirements.cc: Correct minimal-size
	test.
2022-04-07 04:19:21 +02:00
Jason Merrill d942178498 c++: vector compound literal [PR105187]
My cleanup in r12-296 cleared TREE_HAS_CONSTRUCTOR on digested class
initializers, but we leave it set for vectors, since we can't wrap them in
TARGET_EXPR.

	PR c++/105187

gcc/cp/ChangeLog:

	* typeck2.cc (store_init_value): Allow TREE_HAS_CONSTRUCTOR for
	vectors.

gcc/testsuite/ChangeLog:

	* gcc.c-torture/compile/20050113-1.c: Moved to...
	* c-c++-common/torture/20050113-1.c: ...here.
2022-04-06 21:27:27 -04:00
GCC Administrator 80eb8ec672 Daily bump. 2022-04-07 00:16:45 +00:00
Thomas Schwinge 5e431ae4cc Move 'libgomp/plugin/cuda/cuda.h' to 'include/cuda/cuda.h'
... so that it may be used by other projects that inherit GCC's 'include'
directory.

	include/
	* cuda/cuda.h: New file.
	libgomp/
	* plugin/cuda/cuda.h: Remove file.
	* plugin/plugin-nvptx.c [PLUGIN_NVPTX_DYNAMIC]: Include
	"cuda/cuda.h" instead of <cuda.h>.
	* plugin/configfrag.ac <PLUGIN_NVPTX_DYNAMIC>: Don't set
	'PLUGIN_NVPTX_CPPFLAGS'.
	* configure: Regenerate.
2022-04-06 22:30:14 +02:00
David Malcolm 790e981445 jit: fix location of .png files for "make jit.pdf" [PR102824]
"make jit.pdf" seems to be looking in
  gcc/jit/docs/_build/texinfo/libgccjit-figures
for the .png files, but they were in the source tree in:
  gcc/jit/docs/_build/texinfo

Fix "make jit.pdf" via:
  git mv \
    gcc/jit/docs/_build/texinfo/*.png \
    gcc/jit/docs/_build/texinfo/libgccjit-figures

gcc/jit/ChangeLog:
	PR jit/102824
	* docs/_build/texinfo/factorial.png: Move to...
	* docs/_build/texinfo/libgccjit-figures/factorial.png: ...here.
	* docs/_build/texinfo/factorial1.png: Move to...
	* docs/_build/texinfo/libgccjit-figures/factorial1.png: ...here.
	* docs/_build/texinfo/sum-of-squares.png: Move to...
	* docs/_build/texinfo/libgccjit-figures/sum-of-squares.png: ...here.
	* docs/_build/texinfo/sum-of-squares1.png: Move to...
	* docs/_build/texinfo/libgccjit-figures/sum-of-squares1.png: ...here.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-04-06 16:20:10 -04:00
Jakub Jelinek 61bee6aed2 combine: Don't record for UNDO_MODE pointers into regno_reg_rtx array [PR104985]
The testcase in the PR fails under valgrind on mips64 (but only Martin
can reproduce, I couldn't).
But the problem reported there is that SUBST_MODE remembers addresses
into the regno_reg_rtx array, then some splitter needs a new pseudo
and calls gen_reg_rtx, which reallocates the regno_reg_rtx array
and finally undo operation is done and dereferences the old regno_reg_rtx
entry.
The rtx values stored in regno_reg_rtx array seems to be created
by gen_reg_rtx only and since then aren't modified, all we do for it
is adjusting its fields (e.g. adjust_reg_mode that SUBST_MODE does).

So, I think it is useless to use where.r for UNDO_MODE and store
&regno_reg_rtx[regno] in struct undo, we can store just
regno_reg_rtx[regno] (i.e. pointer to the REG itself instead of
pointer to pointer to REG) or could also store just the regno.

The following patch does the latter, and because SUBST_MODE no longer
needs to be a macro, changes all SUBST_MODE uses to subst_mode.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/104985
	* combine.cc (struct undo): Add where.regno member.
	(do_SUBST_MODE): Rename to ...
	(subst_mode): ... this.  Change first argument from rtx * into int,
	operate on regno_reg_rtx[regno] and save regno into where.regno.
	(SUBST_MODE): Remove.
	(try_combine): Use subst_mode instead of SUBST_MODE, change first
	argument from regno_reg_rtx[whatever] to whatever.  For UNDO_MODE, use
	regno_reg_rtx[undo->where.regno] instead of *undo->where.r.
	(undo_to_marker): For UNDO_MODE, use regno_reg_rtx[undo->where.regno]
	instead of *undo->where.r.
	(simplify_set): Use subst_mode instead of SUBST_MODE, change first
	argument from regno_reg_rtx[whatever] to whatever.
2022-04-06 18:42:52 +02:00
Jakub Jelinek 9fd377a747 c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]
cplus_decl_attributes can be called with attributes equal to
error_mark_node, there are some spots in the function that test
it or decl_attributes it calls starts with:
  if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node)
    return NULL_TREE;
But the recent PR104245 change broke this when processing_template_decl
is true.

The patch returns early for attributes error_mark_node from
cplus_decl_attributes.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR c++/104668
	* decl2.cc (splice_template_attributes): Return NULL if *p is
	error_mark_node.
	(cplus_decl_attributes): Return early if attributes is
	error_mark_node.  Don't check that later.

	* g++.dg/cpp0x/pr104668.C: New test.
2022-04-06 17:53:41 +02:00
Patrick Palka e58484a019 c++: make -Wctad-maybe-unsupported respect complain [PR105143]
We were attempting to issue a -Wctad-maybe-unsupported warning even when
complain=tf_none, which led to a crash in the first testcase below and a
bogus error during overload resolution in the second testcase.

	PR c++/105143

gcc/cp/ChangeLog:

	* pt.cc (do_class_deduction): Check complain before attempting
	to issue a -Wctad-maybe-unsupported warning.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/nodiscard1.C: New test.
	* g++.dg/warn/Wctad-maybe-unsupported4.C: New test.
2022-04-06 11:46:25 -04:00
Jakub Jelinek 6283d5ad47 sh: Fix up __attribute__((optimize ("Os"))) handling on SH [PR105069]
As mentioned in the PR, various tests on sh-elf ICE like:
make check-gcc RUNTESTFLAGS="compile.exp='pr104327.c pr58332.c pr81360.c pr84425.c'"
FAIL: gcc.c-torture/compile/pr104327.c   -O0  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr104327.c   -O0  (test for excess errors)
FAIL: gcc.c-torture/compile/pr104327.c   -O1  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr104327.c   -O1  (test for excess errors)
FAIL: gcc.c-torture/compile/pr104327.c   -O2  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr104327.c   -O2  (test for excess errors)
FAIL: gcc.c-torture/compile/pr104327.c   -O3 -g  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr104327.c   -O3 -g  (test for excess errors)
FAIL: gcc.c-torture/compile/pr104327.c   -Os  (test for excess errors)
FAIL: gcc.c-torture/compile/pr58332.c   -O0  (test for excess errors)
FAIL: gcc.c-torture/compile/pr58332.c   -O1  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr58332.c   -O1  (test for excess errors)
FAIL: gcc.c-torture/compile/pr58332.c   -O2  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr58332.c   -O2  (test for excess errors)
FAIL: gcc.c-torture/compile/pr58332.c   -O3 -g  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr58332.c   -O3 -g  (test for excess errors)
FAIL: gcc.c-torture/compile/pr58332.c   -Os  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr58332.c   -Os  (test for excess errors)
FAIL: gcc.c-torture/compile/pr81360.c   -O0  (test for excess errors)
FAIL: gcc.c-torture/compile/pr81360.c   -O1  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr81360.c   -O1  (test for excess errors)
FAIL: gcc.c-torture/compile/pr81360.c   -O2  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr81360.c   -O2  (test for excess errors)
FAIL: gcc.c-torture/compile/pr81360.c   -O3 -g  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr81360.c   -O3 -g  (test for excess errors)
FAIL: gcc.c-torture/compile/pr81360.c   -Os  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr81360.c   -Os  (test for excess errors)
FAIL: gcc.c-torture/compile/pr84425.c   -O0  (test for excess errors)
FAIL: gcc.c-torture/compile/pr84425.c   -O1  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr84425.c   -O1  (test for excess errors)
FAIL: gcc.c-torture/compile/pr84425.c   -O2  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr84425.c   -O2  (test for excess errors)
FAIL: gcc.c-torture/compile/pr84425.c   -O3 -g  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr84425.c   -O3 -g  (test for excess errors)
FAIL: gcc.c-torture/compile/pr84425.c   -Os  (internal compiler error: 'global_options' are modified in local context)
FAIL: gcc.c-torture/compile/pr84425.c   -Os  (test for excess errors)
With the following patch, none of those tests ICE anymore, though
pr104327.c still FAILs with:
Excess errors:
/usr/src/gcc/gcc/testsuite/gcc.c-torture/compile/pr104327.c:6:1: error: inlining failed in call to 'always_inline' 'bar': target specific option mismatch
I think that would be fixable by overriding TARGET_CAN_INLINE_P
hook and allowing at least for always_inline changes in sh_div_str.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR target/105069
	* config/sh/sh.opt (mdiv=): Add Save.
2022-04-06 17:42:07 +02:00
Martin Liska 717b2d4191 --target-help: align with --help=target
PR driver/105096

gcc/ChangeLog:

	* common.opt: Document properly based on what it does.
	* gcc.cc (display_help): Unify with what we have in common.opt.
	* opts.cc (common_handle_option): Do not print undocumented
	options.
2022-04-06 17:38:15 +02:00
Segher Boessenkool c65d15d407 rs6000/testsuite: Skip pr105140.c
This test fails with error "AltiVec argument passed to unprototyped
function", but the code (in rs6000.c:invalid_arg_for_unprototyped_fn,
from 2005) actually tests for any vector type argument.  It also does
not fail on Darwin, not reflected here though.

2022-04-06  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/testsuite/
	PR target/105147
	* gcc.dg/pr105140.c: Skip for powerpc*-*-*.
2022-04-06 15:36:18 +00:00
Jason Merrill cc76c502a7 c++: -Wunused-value and array init [PR104702]
Here, because of problems with the new warning-control code and expressions
that change location, the suppress_warning on the INDIRECT_REF didn't work.
Those problems still need to be worked out, but it's simple to avoid needing
to use suppress_warning in the first place by using a reference instead.

	PR c++/104702

gcc/cp/ChangeLog:

	* init.cc (build_vec_init): Use a reference for the result.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wunused-19.C: New test.
2022-04-06 11:33:31 -04:00
Xi Ruoyao eac5c12c18
mips: Fix C++14 vs. C++17 ABI incompatibility on mips64
This fixes tmpdir-g++.dg-struct-layout-1/{t032,t059} failure.  Clang++
also ignores C++17 empty bases in return values.

gcc/
	* config/mips/mips.cc (mips_fpr_return_fields): Ignore
	cxx17_empty_base_field_p fields and set an indicator.
	(mips_return_in_msb): Adjust for mips_fpr_return_fields change.
	(mips_function_value_1): Inform psABI change about C++17 empty
	bases.

gcc/testsuite/
	* g++.target/mips/cxx17_empty_base.C: New test.
2022-04-06 22:55:36 +08:00
Jakub Jelinek 5df29fe79d gimple.cc: Follow-up to adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150]
On Wed, Apr 06, 2022 at 09:41:44AM +0100, Richard Sandiford wrote:
> But it seems like the magic incantation to detect “real” built-in
> function calls is getting longer and longer.  Can we not abstract this
> in a single place rather than have to repeat the same long sequence in
> multiple places?

I've already committed it, so it can be only dealt with an incremental
patch.
Here is a patch that adjusts instead gimple_builtin_call_types_compatible_p,
after the assert:
  if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
    if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)))
      fndecl = decl;
but we then lose the theoretical possibility of comparing against the
actual user declaration.  Though I guess in the
gimple-fold.cc
gimple-low.cc
gimple-match-head.cc
calls to that function we also want this rather than what they do currently.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105150
	* gimple.cc (gimple_builtin_call_types_compatible_p): Use
	builtin_decl_explicit here...
	(gimple_call_builtin_p, gimple_call_combined_fn): ... rather than
	here.
2022-04-06 16:47:47 +02:00
Jason Merrill fd0024e48e c++: -Wshadow=compatible-local type vs var [PR100608]
The patch for PR92024 changed -Wshadow=compatible-local to warn if either
new or old decl was a type, but the rationale only talked about the case
where both are types.  If only one is, they aren't compatible.

	PR c++/100608

gcc/cp/ChangeLog:

	* name-lookup.cc (check_local_shadow): Use -Wshadow=local
	if exactly one of 'old' and 'decl' is a type.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wshadow-compatible-local-3.C: New test.
2022-04-06 10:30:12 -04:00
Richard Biener e1a5e7562d tree-optimization/105173 - fix insertion logic in reassoc
The find_insert_point logic around deciding whether to insert
before or after the found insertion point does not handle
the case of _12 = ..;, _12, 1.0 well.  The following puts the
logic into find_insert_point itself instead.

2022-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105173
	* tree-ssa-reassoc.cc (find_insert_point): Get extra
	insert_before output argument and compute it.
	(insert_stmt_before_use): Adjust.
	(rewrite_expr_tree): Likewise.

	* gcc.dg/pr105173.c: New testcase.
2022-04-06 13:15:35 +02:00
Richard Biener 4be0831512 ipa/105166 - avoid modref queries with mismatching types
We should avoid mismatched argument values (integers for pointers)
when doing modref queries.  This is the third place to guard.

2022-04-06  Richard Biener  <rguenther@suse.de>

	PR ipa/105166
	* ipa-modref-tree.cc (modref_access_node::get_ao_ref ): Bail
	out for non-pointer arguments.

	* gcc.dg/torture/pr105166.c: New testcase.
2022-04-06 12:23:17 +02:00
Richard Biener 44fe494017 tree-optimization/105163 - abnormal SSA coalescing and reassoc
The negate propagation optimizations in reassoc did not look out for
abnormal SSA coalescing issues.  The following fixes that.

2022-04-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/105163
	* tree-ssa-reassoc.cc (repropagate_negates): Avoid propagating
	negated abnormals.

	* gcc.dg/torture/pr105163.c: New testcase.
2022-04-06 10:33:13 +02:00