Commit Graph

205979 Commits

Author SHA1 Message Date
Jakub Jelinek
9bfebcb1b7 lower-bitint: Fix up handle_operand_addr for 0 constants [PR112771]
handle_operand_addr for INTEGER_CSTs uses wi::min_precision (UNSIGNED
for non-negative constants, SIGNED for negative ones) and from that
computes mp as minimum number of limbs which can represent that value,
and in some cases creates a test BITINT_TYPE with that precision to
categorize it and decide based on that what types to use on the constant
emitted into memory.  For the actual precisions (what will be passed
to libgcc) it actually already uses MAX/MIN to adjust the corner cases:
          *prec = MAX (min_prec, 1);
...
          *prec = MIN ((int) -min_prec, -2);
but for integer_zerop min_prec will be 0,
mp = CEIL (min_prec, limb_prec) * limb_prec;
will be also 0 and we ICE trying to build unsigned BITINT_TYPE with
0 precision.

Fixed thusly by noting even 0 has to be encoded at least as one limb.

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/112771
	* gimple-lower-bitint.cc (bitint_large_huge::handle_operand_addr):
	Use mp = 1 if it is zero.

	* gcc.dg/bitint-44.c: New test.
2023-12-01 10:55:49 +01:00
Jose E. Marchesi
b506834e7f bpf: quote section names whenever necessary in assembly output
In BPF section names are used to encode the kind of BPF program and
other metadata, involving all sort of non alphanumeric characters.

For example:

  /* use auto-attach format for section definition. */
  SEC("uretprobe//proc/self/exe:trigger_func2")
  int handle_uretprobe_byname(struct pt_regs *ctx)
  {
  	uretprobe_byname_res = 6;
  	return 0;
  }

The above requires to quote the section name in the output assembly
file, since otherwise the // in the name would be interpreted by the
assembler lexer as the beginning of a line comment.

This patch makes the BPF backend to emit quoted section names in
.section directives if the name requires to be quoted.  Simple section
names whose constituent characters are in the set [0-9a-zA-Z_] are
still emitted unquoted.

Tested in target bpf-unknown-none-gcc and host x86_64-linux-gnu.

gcc/ChangeLog

	* config/bpf/bpf.cc (bpf_asm_named_section): New function.
	(TARGET_ASM_NAMED_SECTION): Set to bpf_asm_named_section.

gcc/testsuite/ChangeLog

	* gcc.target/bpf/section-name-quoting-1.c: New test.
2023-12-01 10:42:40 +01:00
Di Zhao
6563d6767e aarch64: modify Ampere CPU tunings on reassociation/FMA
1. Allow reassociation on FP additions.

2. Avoid generating loop-dependant FMA chains. Added a tuning
option 'AARCH64_EXTRA_TUNE_AVOID_CROSS_LOOP_FMA' for this.

gcc/ChangeLog:

	* config/aarch64/aarch64-tuning-flags.def
	(AARCH64_EXTRA_TUNING_OPTION): New tuning option to avoid
	cross-loop FMA.
	* config/aarch64/aarch64.cc
	(aarch64_override_options_internal): Set
	param_avoid_fma_max_bits according to tuning option.
	* config/aarch64/tuning_models/ampere1.h (ampere1_tunings):
	Modify tunings related with FMA.
	* config/aarch64/tuning_models/ampere1a.h (ampere1a_tunings):
	Likewise.
	* config/aarch64/tuning_models/ampere1b.h (ampere1b_tunings):
	Likewise.
2023-12-01 17:02:46 +08:00
Rainer Orth
8228855001 libstdc++: Regenerate GCC_CHECK_ASSEMBLER_HWCAP users
This patch regenerates the remaining user of the GCC_CHECK_ASSEMBLER_HWCAP
macro.  No functional changes.

2023-11-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libstdc++-v3:
	* configure: Regenerate.
2023-12-01 09:59:08 +01:00
Sebastian Huber
4b8078142e gcov: Fix use of __LIBGCC_HAVE_LIBATOMIC
libgcc/ChangeLog:

	PR target/112777

	* libgcov.h (GCOV_SUPPORTS_ATOMIC):  Honor that __LIBGCC_HAVE_LIBATOMIC is
	always defined as either 0 or 1.
2023-12-01 09:54:24 +01:00
Richard Sandiford
a1bc121c00 aarch64: Add a result_mode helper function
SME will add more intrinsics whose expansion code requires
the mode of the function return value.  This patch adds an
associated helper routine.

gcc/
	* config/aarch64/aarch64-sve-builtins.h
	(function_expander::result_mode): New member function.
	* config/aarch64/aarch64-sve-builtins-base.cc
	(svld234_impl::expand): Use it.
	* config/aarch64/aarch64-sve-builtins.cc
	(function_expander::get_reg_target): Likewise.
2023-12-01 08:36:15 +00:00
Jakub Jelinek
e3be66dfe8 lower-bitint: Fix up maximum addition/subtraction/multiplication result computations
When debugging PR112750, I've noticed some issues in the computation
of precisions and the following patch attempts to fix those.

The pass uses range_to_prec function, which possibly using ranger returns
minimum precision of some operand in the style that libgcc _BitInt
entrypoints expect, i.e. for operands with unsigned types either the
precision of that type or with help of ranger
wi::min_precision (upper_bound, UNSIGNED) (done both if the types
are really unsigned or even when lower_bound is non-negative), while
for operands with signed types either negated precision of that type or
with help of ranger negated value of maximum of SIGNED min_precisions
of lower and upper bound.
Because _BitInt in C only supports unsigned precisions >= 1 and signed
precisions >= 2, the function also ensures that 0 is never returned (returns
1 instead) and should ensure that -1 is never returned (should return -2).
That is the first bug I found though, for the ranger case it ensured that,
but if an operand would be signed 1-bit precision (that means
non-BITINT_TYPE) operand, it could return -1.

Another thing is that both lower_addsub_overflow and lower_mul_overflow
compute from the prec0 and prec1 of the operands (returned by range_to_prec
with the above value meanings) prec2, which is how many bits of the result
we actually need to compute to know the infinite precision result.
This is then used by arith_overflow function together with prec
(TYPE_PRECISION (type)), type (type of the result), prec0 and prec1 to
compute which range of bits should be tested (if any, or that there is never
an overflow) and with which kind (require those bits to be zero vs.
check if all those bits together all all zeros/ones).
The arith_overflow function has one special case, when
prec0 >= 0 && prec1 >= 0 and operation is not .SUB_OVERFLOW; in that case
we treat prec2 as minimum precision to express any infinite precision
unsigned result (the result is never negative in that case), while
in all other cases prec2 is treated as minimum precision to express
any infinite precision signed result (because the result can be also
negative).
The computations of those values were apparently incorrect for all of
.{ADD,SUB}_OVERFLOW (in that case only if one operand was signed and
the other unsigned) and for .MUL_OVERFLOW it was sometimes too large.

It took me a while to get to the right expression how to compute that,
I've started with writing into the comment the possible results for
different prec0 and prec1 values (used just 8/-8/10/-10 as placeholders
for equal or different absolute values of the 2 precisions and cases
with positive and/or negative signs) and then turned into the attached
test program that actually printed what I was writing to make sure
I didn't make mistakes in it and in the end also verified the computation,
this time for all combinations of 1..14 and -2..-14 precisions.
The UNSIGNED vs. SIGNED in the table is what arith_overflow expects
the prec2 to be (see above mentioned exception).

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

	* gimple-lower-bitint.cc (range_to_prec): Don't return -1 for
	signed types.
	(bitint_large_huge::lower_addsub_overflow): Fix up computation of
	prec2.
	(bitint_large_huge::lower_mul_overflow): Likewise.
2023-12-01 09:26:56 +01:00
Jakub Jelinek
0ef93c86f7 lower-bitint: Fix ICE on bitint-39.c
torture/bitint-39.c ICEs with -O1; the problem is that the
finish_arith_overflow code in one spot replaces use_stmt with an
assignment or cast, but if unlucky and m_gsi iterator is the same statement,
when the code later
      tree clobber = build_clobber (TREE_TYPE (var), CLOBBER_EOL);
      g = gimple_build_assign (var, clobber);
      gsi_insert_after (&m_gsi, g, GSI_SAME_STMT);
it will insert after iterator which contains already replaced statement and
that causes the gimple chain corruption.

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

	* gimple-lower-bitint.cc (bitint_large_huge::finish_arith_overflow):
	When replacing use_stmt which is gsi_stmt (m_gsi), update m_gsi to
	the new statement.
2023-12-01 09:26:24 +01:00
Jakub Jelinek
364332658e lower-bitint: Fix _BitInt .{ADD,SUB}_OVERFLOW lowering [PR112750]
The .{ADD,SUB}_OVERFLOW lowering is implemented by performing normal
addition/subtraction (perhaps extended to even more bits than normally by
continuing with extended values of operands after running of normal bits)
and in addition to that trying to compute if certain sets of bits are either
all zero or all sign extensions of the least significant bit.

That code is in a lot of cases guarded just by a single condition (which
can be idx > startlimb, idx >= startlimb or idx == startlimb) or by
2 conditions - if (idx >= startlimb) { if (idx == startlimb) ... else ... }
Now, if_then_if_then_else when the second argument is NULL works just as
if_then and sets m_gsi to be within the initially empty then block and that is
where we emit code for constant tidx startlimb + (cmp_code == GT_EXPR).
But in the 2 conditions case, m_gsi is set to the initially empty else
block, so using EQ_EXPR for the condition was incorrect (and strangely
nothing in the testsuite caught that), because the code for extracting the
lowest set of bits (i.e. when tidx is startlimb) is then done when idx
is not startlimb rather than when it is.
The following patch fixes that.

Note, when developing the lowering, I was using gcov to make sure all code
is covered by the testsuite with minimum exceptions, so no idea how this
slipped out.

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/112750
	* gimple-lower-bitint.cc (bitint_large_huge::lower_addsub_overflow):
	Use NE_EXPR rather than EQ_EXPR for g2 if !single_comparison and
	adjust probabilities.

	* gcc.dg/bitint-41.c: Use -std=c23 rather than -std=c2x.
	* gcc.dg/torture/bitint-43.c: Likewise.
	* gcc.dg/torture/bitint-44.c: Likewise.
	* gcc.dg/torture/bitint-45.c: New test.
2023-12-01 09:25:45 +01:00
Xi Ruoyao
875c777109
doc: Update the status of build directory not fully separated
Recently there are some people building GCC with srcdir == objdir and
the attempts just failed [1].  So stop to say "it should work".  OTOH
objdir as a subdirectory of srcdir works: we've built GCC in LFS [2]
and BLFS [3] this way for decades and this is confirmed during the
review of a previous version of this patch [4].

[1]: https://gcc.gnu.org/pipermail/gcc-help/2023-November/143068.html
[2]: https://www.linuxfromscratch.org/lfs/view/12.0/chapter08/gcc.html
[3]: https://www.linuxfromscratch.org/blfs/view/12.0/general/gcc.html
[4]: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/638760.html

gcc/ChangeLog:

	* doc/install.texi: Deem srcdir == objdir broken, but objdir
	as a subdirectory of srcdir fine.
2023-12-01 15:48:58 +08:00
Juergen Christ
8a2e428591 s390x: Fix s390_md_asm_adjust handling of long doubles [PR112753]
Commit 466b100e5f introduced a bug in
s390_md_asm_adjust if vector extensions are not available.  Fix the
control flow of this function to not adjust long double values.

gcc/ChangeLog:

	PR target/112753
	* config/s390/s390.cc (s390_md_asm_adjust): Return after dealing
	with the outputs, if no further processing of long doubles is
	required.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/pr112753.c: New test.
2023-12-01 08:17:15 +01:00
Jakub Jelinek
28944a016b s390: Fix builtin-classify-type-1.c on s390 too [PR112725]
s390 suffers from the same issue with __builtin_classify_type vector
arguments, the target hook diagnoses those because it thinks a vector
is passed to an unprototyped function, but in this case it is a type-generic
builtin which can support vector types just fine, by folding into the
appropriate constant.

This fixes
-FAIL: c-c++-common/builtin-classify-type-1.c  -Wc++-compat  (test for excess errors)
-UNRESOLVED: c-c++-common/builtin-classify-type-1.c  -Wc++-compat  compilation failed to produce executable
on s390x-linux.

2023-12-01  Jakub Jelinek  <jakub@redhat.com>

	PR target/112725
	* config/s390/s390.cc (s390_invalid_arg_for_unprototyped_fn): Return
	NULL for __builtin_classify_type calls with vector arguments.
2023-12-01 08:15:25 +01:00
Florian Weimer
ff9efa3fc4 c: Add new -Wdeclaration-missing-parameter-type permerror
This used to be a warning, enabled by default, without its own option.

A subsequent change could improve diagnostics and provide spelling
hints for declarations like “void function (int32t);”.

gcc/c-family/

	* c.opt (Wdeclaration-missing-parameter-type): New.

gcc/c/ChangeLog:

	PR other/44209
	* c-decl.cc (grokparms): Issue permerror for
	OPT_Wdeclaration_missing_parameter_type instead of a pedwarn.

gcc/ChangeLog:

	* doc/invoke.texi (Warning Options): Document
	-Wdeclaration-missing-parameter-type.

gcc/testsuite/ChangeLog:

	* gcc.dg/permerror-default.c (missing_parameter_type):
	Expect error.
	* gcc.dg/permerror-fpermissive.c (missing_parameter_type):
	Expect -Wdeclaration-missing-parameter-type warning.
	* gcc.dg/permerror-gnu89-nopermissive.c (missing_parameter_type):
	Expect -Wdeclaration-missing-parameter-type error.
	* gcc.dg/permerror-gnu89-pedantic.c (missing_parameter_type):
	Likewise.
	* gcc.dg/permerror-gnu89.c (missing_parameter_type):
	Expect -Wdeclaration-missing-parameter-type warning.
	* gcc.dg/permerror-noerror.c: Add
	-Wno-error=declaration-missing-parameter-type to build flags.
	(missing_parameter_type): Expect
	-Wdeclaration-missing-parameter-type warning.
	* gcc.dg/permerror-nowarning.c: Build with
	-Wno-declaration-missing-parameter-type.  Remove previously
	expected warning.
	* gcc.dg/permerror-fpermissive-nowarning.c: Likewise.
	* gcc.dg/permerror-pedantic.c (missing_parameter_type):
	Expect -Wdeclaration-missing-parameter-type error.
	* gcc.dg/permerror-system.c (missing_parameter_type):
	Likewise.
2023-12-01 08:10:13 +01:00
Florian Weimer
9715c545d3 c: Turn -Wincompatible-pointer-types into a permerror
The change to build_conditional_expr drops the downgrade
from a pedwarn to warning for builtins for C99 and later
language dialects.  It remains a warning in C89 mode (not
a permerror), as the -std=gnu89 -fno-permissive test shows.

gcc/

	* doc/invoke.texi (Warning Options): Document changes.

gcc/c/

	PR c/96284
	* c-typeck.cc (build_conditional_expr): Upgrade most pointer
	type mismatches to a permerror.
	(convert_for_assignment): Use permerror_opt and
	permerror_init for OPT_Wincompatible_pointer_types warnings.

gcc/testsuite/

	* gcc.dg/permerror-default.c (incompatible_pointer_types):
	Expect new permerror.
	* gcc.dg/permerror-gnu89-nopermissive.c
	(incompatible_pointer_types): Likewise.
	* gcc.dg/permerror-pedantic.c (incompatible_pointer_types):
	Likewise.
	* gcc.dg/permerror-system.c: Likewise.
	* gcc.dg/Wincompatible-pointer-types-2.c: Compile with
	-fpermissive due to expected errors.
	* gcc.dg/Wincompatible-pointer-types-5.c: New test.  Copied
	from gcc.dg/Wincompatible-pointer-types-2.c.  Expect errors.
	* gcc.dg/anon-struct-11.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/anon-struct-11a.c: New test.  Copied from
	gcc.dg/anon-struct-11.c.  Expect errors.
	* gcc.dg/anon-struct-13.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/anon-struct-13a.c: New test.  Copied from
	gcc.dg/anon-struct-13.c.  Expect errors.
	* gcc.dg/builtin-arith-overflow-4.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/builtin-arith-overflow-4a.c: New test.  Copied from
	gcc.dg/builtin-arith-overflow-4.c.  Expect errors.
	* gcc.dg/c23-qual-4.c: Expect -Wincompatible-pointer-types errors.
	* gcc.dg/dfp/composite-type.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/dfp/composite-type-2.c: New test.  Copied from
	gcc.dg/dfp/composite-type.c.  Expect errors.
	* gcc.dg/diag-aka-1.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/diag-aka-1a.c: New test.  Copied from
	gcc.dg/diag-aka-1a.c.  Expect errors.
	* gcc.dg/enum-compat-1.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/enum-compat-2.c: New test.  Copied from
	gcc.dg/enum-compat-1.c.  Expect errors.
	* gcc.dg/func-ptr-conv-1.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/func-ptr-conv-2.c: New test.  Copied from
	gcc.dg/func-ptr-conv-1.c.  Expect errors.
	* gcc.dg/init-bad-7.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/init-bad-7a.c: New test.  Copied from gcc.dg/init-bad-7.c.
	Expect errors.
	* gcc.dg/noncompile/incomplete-3.c (foo): Expect
	-Wincompatible-pointer-types error.
	* gcc.dg/param-type-mismatch-2.c (test8): Likewise.
	* gcc.dg/pointer-array-atomic.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/pointer-array-atomic-2.c: New test.  Copied from
	gcc.dg/pointer-array-atomic.c.  Expect errors.
	* gcc.dg/pointer-array-quals-1.c (test): Expect
	-Wincompatible-pointer-types errors.
	* gcc.dg/transparent-union-1.c: Compile with -fpermissive
	due to expected errors.
	* gcc.dg/transparent-union-1a.c: New test.  Copied from
	gcc.dg/transparent-union-1.c.  Expect errors.
	* gcc.target/aarch64/acle/memtag_2a.c
	(test_memtag_warning_return_qualifier): Expect additional
	errors.
	* gcc.target/aarch64/sve/acle/general-c/load_2.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/sizeless-1.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/sizeless-2.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_1.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_2.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general/attributes_7.c
	(f1): Likewise.
	* gcc.target/i386/sse2-bfloat16-scalar-typecheck.c (footest):
	Expect -Wincompatible-pointer-types errors.
	* gcc.target/i386/vect-bfloat16-typecheck_1.c (footest): Likewise.
	* gcc.target/i386/vect-bfloat16-typecheck_2.c (footest): Likewise.
2023-12-01 08:10:13 +01:00
Florian Weimer
4ecfa6c4a9 c: Turn -Wreturn-mismatch into a permerror
gcc/

	* doc/invoke.texi (Warning Options): Document that
	-Wreturn-mismatch is a permerror in C99 and later.

gcc/c/

	PR c/96284
	* c-typeck.cc (c_finish_return): Use permerrors
	for OPT_Wreturn_mismatch diagnostics.

gcc/testsuite/

	* gcc.dg/permerror-default.c (return_mismatch_1)
	(return_mismatch_2): Expect new permerror.
	* gcc.dg/permerror-gnu89-nopermissive.c (return_mismatch_1):
	Likewise.
	* gcc.dg/permerror-system.c: Likewise.
	* gcc.dg/20030906-1.c: Compile with -fpermissive due to
	expected -Wreturn-mismatch error.
	* gcc.dg/20030906-1a.c: New test.  Copied from
	gcc.dg/20030906-1.c.  Expect the error.
	* gcc.dg/20030906-2.c: Compile with -fpermissive due to
	expected -Wreturn-mismatch error.
	* gcc.dg/20030906-2a.c: New test.  Copied from
	gcc.dg/20030906-2.c.  Expect the error.
	* gcc.dg/Wreturn-mismatch-1.c: Compile with -fpermissive due to
	expected -Wreturn-mismatch error.
	* gcc.dg/Wreturn-mismatch-1a.c: New test.  Copied from
	gcc.dg/Wreturn-mismatch-1.c.  Expect the error.
	* gcc.dg/Wreturn-mismatch-2.c: Compile with -fpermissive due to
	expected -Wreturn-mismatch error.
	* gcc.dg/Wreturn-mismatch-2a.c: New test.  Copied from
	gcc.dg/Wreturn-mismatch-2.c.  Expect the error.
	* gcc.dg/diagnostic-range-bad-return.c: Compile with
	-fpermissive due to expected -Wreturn-mismatch error.
	* gcc.dg/diagnostic-range-bad-return-2.c: New test.
	Copied from gcc.dg/diagnostic-range-bad-return.c.  Expect the
	error.
	* gcc.dg/pr105635-2.c: Expect -Wreturn-mismatch error.
	* gcc.dg/pr23075.c: Build with -fpermissive due to
	expected -Wreturn-mismatch error.
	* gcc.dg/pr23075-2.c: New test.  Copied from gcc.dg/pr23075.c.
	Expect the error.
	* gcc.dg/pr29521.c: Compile with -fpermissive due to expected
	-Wreturn-mismatch error.
	* gcc.dg/pr29521-a.c: New test. Copied from gcc.dg/pr29521.c.
	Expect error.
	* gcc.dg/pr67730.c: Compile with -fpermissive due to expected
	-Wreturn-mismatch error.
	* gcc.dg/pr67730-a.c: New test.  Copied from
	gcc.dg/pr67730-a.c.  Expect error.
	* gcc.target/powerpc/conditional-return.c: Compile with
	-fpermissive due to expected -Wreturn-mismatch error.
2023-12-01 08:10:13 +01:00
Florian Weimer
3ae8882e70 c: Do not ignore some forms of -Wimplicit-int in system headers
Most -Wimplicit-int warnings were unconditionally disabled for system
headers.  Only missing types for parameters in old-style function
definitions resulted in warnings.  This is inconsistent with the
treatment of other permerrors, which are active in system headers.

gcc/c/

	* c-decl.cc (grokdeclarator): Do not skip -Wimplicit-int
	warnings or errors in system headers.

gcc/testsuite/

	* gcc.dg/permerror-system.c: Expect all -Wimplicit-int
	permerrors.
2023-12-01 08:10:13 +01:00
Florian Weimer
4ee2aca7ca c: Turn -Wimplicit-int into a permerror
Most of these new permerrors are currently not diagnosed in system
headers.

gcc/

	PR c/91093
	PR c/96284
	* doc/invoke.texi (Warning Options): Document changes.

gcc/c/

	* c-decl.cc (warn_defaults_to): Remove.
	(grok_declarator, start_function): Call permerror_opt
	instead of warn_defaults_to.
	(store_parm_decls_oldstyle): Call permerror_opt for
	OPT_Wimplicit_int.

gcc/testsuite/

	* gcc.dg/permerror-default.c (implicit_int_1, implicit_int_2)
	(implicit_int_3, implicit_int_4): Expect new permerror.
	* gcc.dg/permerror-system.c: Expect a single new permerror.
	* gcc.dg/Wimplicit-int-1.c: Compile with -fpermissive due to
	expected warning.
	* gcc.dg/Wimplicit-int-4.c: Likewise.
	* gcc.dg/Wimplicit-int-1a.c: New test.  Copied from
	gcc.dg/Wimplicit-int-1.c, but expect errors.
	* gcc.dg/Wimplicit-int-4a.c: New test.  Copied from
	gcc.dg/Wimplicit-int-4.c, but expect errors.
	* gcc.dg/gnu23-attr-syntax-2.c: Compile with -fpermissive
	due to expected implicit-int error.
	* gcc.dg/gnu23-attr-syntax-3.c: New test.  Copied from
	gcc.dg/gnu23-attr-syntax-2.c, but expect an error.
	* gcc.dg/pr105635.c: Build with -fpermissive due to implicit
	int.
	* gcc.dg/pr105635-2.c: New test.  Copied from
	gcc.dg/pr105635.c.  Expect implicit int error.
	* gcc.dg/noncompile/pr79758.c: Build with -fpermissive due to
	implicit int.
	* gcc.dg/noncompile/pr79758-2.c: New test.  Copied from
	gcc.dg/noncompile/pr79758.c.  Expect implicit int error.
2023-12-01 08:10:13 +01:00
Florian Weimer
55e94561e9 c: Turn -Wimplicit-function-declaration into a permerror
In the future, it may make sense to avoid cascading errors from
the implicit declaration, especially its assumed int return type.
This change here only changes the kind of the diagnostic, not
its wording or consequences.

gcc/

	* doc/invoke.texi (Warning Options): Document changes.

gcc/c/

	PR c/91092
	PR c/96284
	* c-decl.cc (implicit_decl_permerror): Rename from
	implicit_decl_warning.  Call permerror_opt instead of
	pedwarn and warning_at.
	(implicitly_declare): Adjust callers.

gcc/testsuite/

	* gcc.dg/permerror-default.c (implicit_function_declaration):
	Expect the new permerror.
	* gcc.dg/permerror-system.c: Likewise.
	* c-c++-common/spellcheck-reserved.c (test, test_2): Expect
	error instead of warning.
	(f): Expect error instead of warning.
	* gcc.dg/Wimplicit-function-declaration-c99.c: Compile with
	-fpermissive due to expected warning.
	* gcc.dg/Wimplicit-function-declaration-c99-2.c: New test.
	Copied from gcc.dg/Wimplicit-function-declaration-c99.c.
	Expect error.
	* gcc.dg/missing-header-fixit-1.c: Compile with -fpermissive
	due to expect error.
	* gcc.dg/missing-header-fixit-1a.c: New test.  Copied from
	gcc.dg/missing-header-fixit-1.c, but expect error.
	* gcc.dg/missing-header-fixit-2.c: Compile with -fpermissive
	due to expect error.
	* gcc.dg/missing-header-fixit-2a.c: New test.  Copied from
	gcc.dg/missing-header-fixit-2.c, but expect error.
	* gcc.dg/missing-header-fixit-4.c: Compile with -fpermissive
	due to expect error.
	* gcc.dg/missing-header-fixit-4a.c: New test.  Copied from
	gcc.dg/missing-header-fixit-4.c, but expect error.
	* gcc.dg/missing-header-fixit-5.c: Compile with -fpermissive
	due to expect error.
	* gcc.dg/missing-header-fixit-5a.c: New test.  Copied from
	gcc.dg/missing-header-fixit-5.c, but expect error.
	* gcc.dg/pr61852.c: Expect implicit-function-declaration
	error instead of warning.
	* gcc.dg/spellcheck-identifiers-2.c: Compile with
	-fpermissive due to expected warnings.
	* gcc.dg/spellcheck-identifiers-2a.c: New test.  Copied
	from gcc.dg/spellcheck-identifiers-2a.c.  Expect errors.
	* gcc.dg/spellcheck-identifiers-3.c: Compile with
	-fpermissive due to expected warnings.
	* gcc.dg/spellcheck-identifiers-3a.c: New test.  Copied
	from gcc.dg/spellcheck-identifiers-2a.c.  Expect errors.
	* gcc.dg/spellcheck-identifiers-4.c: Compile with
	-fpermissive due to expected warnings.
	* gcc.dg/spellcheck-identifiers-4a.c: New test.  Copied
	from gcc.dg/spellcheck-identifiers-2a.c.  Expect error.
	* gcc.dg/spellcheck-identifiers.c: Compile with
	-fpermissive due to expected warnings.
	* gcc.dg/spellcheck-identifiers-1a.c: New test.  Copied
	from gcc.dg/spellcheck-identifiers.c.  Expect errors.
	* gcc.target/aarch64/sve/acle/general-c/ld1sh_gather_1.c (f1):
	Expect error.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_index_1.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_index_restricted_1.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_1.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_2.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_3.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_4.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_5.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_1.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_2.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_3.c:
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/load_ext_gather_offset_restricted_4.c:
	(f1): Likewise.
2023-12-01 08:10:13 +01:00
Florian Weimer
2c3db94d9f c: Turn int-conversion warnings into permerrors
gcc/

	* doc/invoke.texi (Warning Options): Document changes.

gcc/c/

	PR c/96284
	PR c/106416
	* c-typeck.cc (build_conditional_expr): Use permerror_opt for
	pointer/integer type mismatches, based on -Wint-conversion.
	(pedwarn_permerror_init, permerror_init): New function.
	(pedwarn_init): Call pedwarn_permerror_init.
	(convert_for_assignment): Use permerror_opt and
	permerror_init for -Wint-conversion warnings.

gcc/testsuite/

	* gcc.dg/permerror-default.c (int_conversion_1)
	(int_conversion_2): Expect the new permerrors.
	* gcc.dg/permerror-gnu89-nopermissive.c (int_conversion_1)
	(int_conversion_2): Likewise.
	* gcc.dg/permerror-system.c: Likewise.
	* c-c++-common/pr77624-1.c (foo, bar): Expect
	error instead of warning.
	* gcc.dg/Wint-conversion-2.c: Compile with -fpermissive due
	to expected int-conversion warning.
	* gcc.dg/Wint-conversion-3.c: Likewise.
	* gcc.dg/Wint-conversion-4.c: New test.  Based on
	gcc.dg/Wint-conversion-3.c.  Expect int-conversion errors.
	* gcc.dg/assign-warn-1.c: Compile with -fpermissive.
	* gcc.dg/assign-warn-4.c: New file.  Extracted from
	assign-warn1.c.  Expect int-conversion errors.
	* gcc.dg/diagnostic-types-1.c: Compile with -fpermissive.
	* gcc.dg/diagnostic-types-2.c: New file.  Extracted from
	gcc.dg/diagnostic-types-1.c.  Expect some errors instead of
	warnings.
	* gcc.dg/gomp/pr35738.c: Compile with -fpermissive due to
	expected int-conversion error.
	* gcc.dg/gomp/pr35738-2.c: New test.  Based on
	gcc.dg/gomp/pr35738.c.  Expect int-converison errors.
	* gcc.dg/init-excess-3.c: Expect int-converison errors.
	* gcc.dg/overflow-warn-1.c: Likewise.
	* gcc.dg/overflow-warn-3.c: Likewise.
	* gcc.dg/param-type-mismatch.c: Compile with -fpermissive.
	* gcc.dg/param-type-mismatch-2.c: New test.  Copied from
	gcc.dg/param-type-mismatch.c.  Expect errors.
	* gcc.dg/pr61162-2.c: Compile with -fpermissive.
	* gcc.dg/pr61162-3.c: New test. Extracted from
	gcc.dg/pr61162-2.c.  Expect int-conversion errors.
	* gcc.dg/spec-barrier-3.c: Use -fpermissive due to expected
	int-conversion error.
	* gcc.dg/spec-barrier-3a.c: New test.  Based on
	gcc.dg/spec-barrier-3.c.  Expect int-conversion errors.
	* gcc.target/aarch64/acle/memtag_2.c: Use -fpermissive due to expected
	int-conversion error.
	* gcc.target/aarch64/acle/memtag_2a.c: New test.  Copied from
	gcc.target/aarch64/acle/memtag_2.c.  Expect error.
	* gcc.target/aarch64/sve/acle/general-c/load_3.c (f1): Expect
	error.
	* gcc.target/aarch64/sve/acle/general-c/store_2.c (f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_index_restricted_1.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_2.c
	(f1): Likewise.
	* gcc.target/aarch64/sve/acle/general-c/store_scatter_offset_restricted_1.c
	(f1): Likewise.
2023-12-01 08:10:12 +01:00
Florian Weimer
3704326882 Add tests for validating future C permerrors
The dg-error directives for gcc.dg/permerror-system.c can be generated
using (for the most part at least):

perl -ne 'print if s,.*(/\* \{ dg-error .*) } \*/$,$1 "" { target *-*-* } $. } */,' \
  < gcc/testsuite/gcc.dg/permerror-default.c

gcc/testsuite/

	* gcc.dg/permerror-default.c: New test.
	* gcc.dg/permerror-fpermissive.c: Likewise.
	* gcc.dg/permerror-fpermissive-nowarning.c: Likewise.
	* gcc.dg/permerror-gnu89-nopermissive.c: Likewise.
	No permerrors yet, so this matches gcc.dg/permerror-gnu89.c
	for now.
	* gcc.dg/permerror-gnu89-pedantic.c: New test.
	* gcc.dg/permerror-gnu89.c: Likewise.
	* gcc.dg/permerror-noerror.c: Likewise.
	* gcc.dg/permerror-nowarning.c: Likewise.
	* gcc.dg/permerror-pedantic.c: Likewise.
	* gcc.dg/permerror-system.c: Likewise.
2023-12-01 08:10:12 +01:00
Florian Weimer
bf783f6ca4 gm2: Add missing declaration of m2pim_M2RTS_Terminate to test
gcc/testsuite/

	* gm2/link/externalscaffold/pass/scaffold.c (m2pim_M2RTS_Terminate):
	Declare.
2023-12-01 08:10:12 +01:00
Florian Weimer
989af9473d aarch64: Call named function in gcc.target/aarch64/aapcs64/ice_1.c
This test looks like it intends to pass a small struct argument
through both a non-variadic and variadic argument, but due to
the typo, it does not achieve that.

gcc/testsuite/

	* gcc.target/aarch64/aapcs64/ice_1.c (foo): Call named.
2023-12-01 08:10:12 +01:00
Florian Weimer
335bd6c938 aarch64: Avoid -Wincompatible-pointer-types warning in Linux unwinder
* config/aarch64/linux-unwind.h
	(aarch64_fallback_frame_state): Add cast to the expected type
	in sc assignment.
2023-12-01 08:10:12 +01:00
Juzhe-Zhong
923a67f17b RISC-V: Fix VSETVL PASS regression
This patch fix 2 regression (one is bug regression, the other is performance regression).
Those 2 regressions are both we are comparing ratio for same AVL in wrong place.

1. BUG regression:
avl_single-84.c:

f0:
        li      a5,999424
        add     a1,a1,a5
        li      a4,299008
        add     a5,a0,a5
        addi    a3,a4,992
        addi    a5,a5,576
        addi    a1,a1,576
        vsetvli a4,zero,e8,m2,ta,ma
        add     a0,a0,a3
        vlm.v   v1,0(a5)
        vsm.v   v1,0(a1)
        vl1re64.v       v1,0(a0)
        beq     a2,zero,.L10
        li      a5,0
        vsetvli zero,zero,e64,m1,tu,ma   --->  This is totally incorrect since the ratio above is 4, wheras it is demanding ratio = 64 here.
.L3:
        fcvt.d.lu       fa5,a5
        addi    a5,a5,1
        fadd.d  fa5,fa5,fa0
        vfmv.s.f        v1,fa5
        bne     a5,a2,.L3
        vfmv.f.s        fa0,v1
        ret
.L10:
        vsetvli zero,zero,e64,m1,ta,ma
        vfmv.f.s        fa0,v1
        ret

2. Performance regression:

before this patch:

        vsetvli a5,a4,e8,m1,ta,ma
        vsetvli zero,a5,e32,m1,tu,ma
        vmv.s.x v2,zero
        vmv.s.x v1,zero
        vsetvli zero,a5,e32,m4,tu,ma
        vle32.v v4,0(a1)
        vfmul.vv        v4,v4,v4
        vfredosum.vs    v1,v4,v2
        vfmv.f.s        fa5,v1
        fsw     fa5,0(a0)
        sub     a4,a4,a5
        bne     a4,zero,.L2
        ret

After this patch:

	vsetvli	a5,a4,e32,m4,tu,ma
	vle32.v	v4,0(a1)
	vmv.s.x	v2,zero
	vmv.s.x	v1,zero
	vfmul.vv	v4,v4,v4
	vfredosum.vs	v1,v4,v2
	vfmv.f.s	fa5,v1
	fsw	fa5,0(a0)
	sub	a4,a4,a5
	bne	a4,zero,.L2
	ret

Tested rv64gcv_zvfh_zfh passed no regression.

zvl256b/zvl512b/zvl1024b/zve64d is runing.

	PR target/112776

gcc/ChangeLog:

	* config/riscv/riscv-vsetvl.cc (pre_vsetvl::pre_global_vsetvl_info): Fix ratio.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/vsetvl/avl_single-84.c: Adapt test.
	* gcc.target/riscv/rvv/vsetvl/pr111037-3.c: Ditto.
	* gcc.target/riscv/rvv/vsetvl/pr112776.c: New test.
2023-12-01 14:49:01 +08:00
Jason Merrill
73e2bdbf9b c++: lambda capture and explicit object parm
More adjustments to allow for explicit object parameters in lambdas.  This
has no practical effect until that patch goes in, but applying this
separately seems reasonable.

gcc/cp/ChangeLog:

	* semantics.cc (finish_non_static_data_member)
	(finish_decltype_type, capture_decltype):
	Handle deduced closure parameter.
2023-11-30 22:51:04 -05:00
GCC Administrator
8428bcd703 Daily bump. 2023-12-01 00:17:36 +00:00
Marek Polacek
725c68c54c c++: wrong ambiguity in accessing static field [PR112744]
Given

  struct A { constexpr static int a = 0; };
  struct B : A {};
  struct C : A {};
  struct D : B, C {};

we give the "'A' is an ambiguous base of 'D'" error for

  D{}.A::a;

which seems wrong: 'a' is a static data member so there is only one copy
so it can be unambiguously referred to even if there are multiple A
objects.  clang++/MSVC/icx agree.

This patch uses ba_any: [class.access.base] requires conversion to a unique
base subobject for non-static data members, but it does not require that the
base be unique or accessible for static data members.

	PR c++/112744

gcc/cp/ChangeLog:

	* typeck.cc (finish_class_member_access_expr): When accessing
	a static data member, use ba_any for lookup_base.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/scoped11.C: New test.
	* g++.dg/lookup/scoped12.C: New test.
	* g++.dg/lookup/scoped13.C: New test.
	* g++.dg/lookup/scoped14.C: New test.
	* g++.dg/lookup/scoped15.C: New test.
2023-11-30 16:40:57 -05:00
Ian Lance Taylor
e81e84e02b libgo: update configure.ac to upstream GCC
The libgo/configure.ac file in upstream GCC was changed in

https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6a6d3817afa02bbcd2388c8e005da6faf88932f1

This adds an automake conditional that is not used, but will be used
in the future when and if libgo is ported to Darwin.

This CL makes the corresponding change in this repo.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/546435
2023-11-30 13:23:53 -08:00
Ian Lance Taylor
c6f7253bcc libbacktrace: support ASLR on Windows
Patch from Björn Schäpers.

	* pecoff.c: Include <windows.h> if available.
	(coff_add): On Windows call GetModuleHandle to get base address.
2023-11-30 11:24:57 -08:00
Wilco Dijkstra
df8958e6bc AArch64: Fix __sync_val_compare_and_swap [PR111404]
__sync_val_compare_and_swap may be used on 128-bit types and either calls the
outline atomic code or uses an inline loop.  On AArch64 LDXP is only atomic if
the value is stored successfully using STXP, but the current implementations
do not perform the store if the comparison fails.  In this case the value
returned is not read atomically.

gcc/ChangeLog:
	PR target/111404
	* config/aarch64/aarch64.cc (aarch64_split_compare_and_swap):
	For 128-bit store the loaded value and loop if needed.

libgcc/ChangeLog:
	PR target/111404
	* config/aarch64/lse.S (__aarch64_cas16_acq_rel): Execute STLXP using
	either new value or loaded value.
2023-11-30 16:15:29 +00:00
Jonathan Wakely
18d8a50a04 libstdc++: Fix std::ranges::to errors
Fix some errors that Patrick noticed, and remove a #if 0 group that I
didn't mean to leave in the file.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__toable): Fix incorrect use of
	_Range instead of _Cont.
	(__detail::_ToClosure, __detail::_ToClosure2): Add missing
	constexpr specifier on constructors.
	* testsuite/std/ranges/conv/1.cc (_Cont, _Cont2, _Cont3): Remove
	unnecessary begin() and end() members.
	(test_constexpr): New function to check range adaptors are
	usable in constant expressions.
2023-11-30 15:45:30 +00:00
Gaius Mulley
c8dafbef1a modula2: libgm2 bump version to 19:0.0
This patch bumps the libgm2 version to 19.0.0 reflecting
time related fixes, changes to builtins.def and the
commencement of gcc stage3.

libgm2/ChangeLog:

	* configure: Regenerate.
	* configure.ac:(libtool_VERSION): Bump to 19:0:0.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2023-11-30 15:39:17 +00:00
Christophe Lyon
d77d2dd9bd testsuite/arm: Fix bfloat16_vector_typecheck_[12].c tests [PR 112698]
After commit r14-5617-gb8592186611, int32x[24]_t types now use
elements of 'long int' type instead of 'int' on arm-eabi (it's still
'int' on arm-linux-gnueabihf).  Both are 32-bit types anyway.

This patch adjust the two tests so that they optionnally accept 'long '
before 'int' in the expected error message.

2023-11-30  Christophe Lyon  <christophe.lyon@linaro.org>

	PR target/112698
	gcc/testsuite/
	* gcc.target/arm/bfloat16_vector_typecheck_1.c: Update expected
	error message.
	* gcc.target/arm/bfloat16_vector_typecheck_2.c: Likewise.
2023-11-30 15:30:21 +00:00
Thomas Schwinge
aae57a9e19 Fix 'libgomp.c/declare-variant-4-*.c', add 'libgomp.c/declare-variant-4.c'
These test cases being 'dg-skip-if [...] { ! amdgcn-*-* }' meant they were
only ever considered for 'amdgcn-*-*' target -- that is, GCN *target*, not
GCN *offload target*, what is intended to be tested here, but for which they
thus always were UNSUPPORTED.  Use the same style of 'dg-[...]' directives
as for the nvptx offloading test cases, 'libgomp.c/declare-variant-3*.c'.

Fix-up for commit 1fd508744e
"amdgcn: Support AMD-specific 'isa' traits in OpenMP context selectors".

	libgomp/
	* testsuite/libgomp.c/declare-variant-4-fiji.c: Adjust.
	* testsuite/libgomp.c/declare-variant-4-gfx803.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx900.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx906.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx908.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx90a.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4.h: Likewise.
	* testsuite/libgomp.c/declare-variant-4.c: New.
2023-11-30 15:42:57 +01:00
Thomas Schwinge
95e6e32a85 Spin 'dg-do run' part of 'libgomp.c/declare-variant-3-sm30.c' off into new 'libgomp.c/declare-variant-3.c'
Having nvptx offloading configured doesn't imply being able to run nvptx
offloading test cases on the test host.

Also, make 'libgomp.c/declare-variant-3.c' work for all non-offloading and
offloading cases.

Fix-up for commit 59b8ade887
"[libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c".

	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm30.c: Turn 'dg-do run'
	into 'dg-do link'.
	* testsuite/libgomp.c/declare-variant-3.c: New.
	* testsuite/libgomp.c/declare-variant-3.h: Extend.
2023-11-30 15:42:57 +01:00
Thomas Schwinge
186e22c5de In 'libgomp.c/declare-variant-{3,4}-*.c', restrict 'scan-offload-tree-dump's to 'only_for_offload_target [...]'
... to care for the case where not just one but both of GCN and nvptx
offloading are enabled.  In that case, we currently get:

    UNRESOLVED: libgomp.c/declare-variant-3-sm30.c scan-amdgcn-amdhsa-offload-tree-dump optimized "= f30 \\(\\);"

... in addition to:

    PASS: libgomp.c/declare-variant-3-sm30.c scan-nvptx-none-offload-tree-dump optimized "= f30 \\(\\);"

Etc.

Fix-up for commit 59b8ade887
"[libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c",
and commit 1fd508744e
"amdgcn: Support AMD-specific 'isa' traits in OpenMP context selectors".

	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm30.c: Restrict
	'scan-offload-tree-dump' to 'only_for_offload_target nvptx-none'.
	* testsuite/libgomp.c/declare-variant-3-sm35.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm53.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm70.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm75.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm80.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-fiji.c: Restrict
	'scan-offload-tree-dump' to
	'only_for_offload_target amdgcn-amdhsa'.
	* testsuite/libgomp.c/declare-variant-4-gfx803.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx900.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx906.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx908.c: Likewise.
	* testsuite/libgomp.c/declare-variant-4-gfx90a.c: Likewise.
2023-11-30 15:42:57 +01:00
Thomas Schwinge
3f5a3b7539 Fix 'libgomp.c/declare-variant-3-*.c' compilation for configurations where GCN offloading is enabled in addition to nvptx
The GCN offloading compiler doesn't like '-misa=sm_30' etc.; restrict to
'-foffload=nvptx-none' compilation only.

Fix-up for commit 59b8ade887
"[libgomp, testsuite, nvptx] Add libgomp.c/declare-variant-3-sm*.c".

	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm30.c:
	'dg-additional-options -foffload=nvptx-none'.
	* testsuite/libgomp.c/declare-variant-3-sm35.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm53.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm70.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm75.c: Likewise.
	* testsuite/libgomp.c/declare-variant-3-sm80.c: Likewise.
2023-11-30 15:42:57 +01:00
Thomas Schwinge
9bd6ee8a82 GCN: Generally enable the 'gcc.target/gcn/avgpr-[...]' test cases
... added in commit ae0d2c2402
"amdgcn: Add Accelerator VGPR registers".  This way, they're correctly tested
no matter what '-march=[...]' is used with 'make check'.

	gcc/testsuite/
	* gcc.target/gcn/avgpr-mem-double.c: Remove
	'dg-skip-if "incompatible ISA" [...]'.
	* gcc.target/gcn/avgpr-mem-int.c: Likewise.
	* gcc.target/gcn/avgpr-mem-long.c: Likewise.
	* gcc.target/gcn/avgpr-mem-short.c: Likewise.
	* gcc.target/gcn/avgpr-spill-double.c: Likewise.
	* gcc.target/gcn/avgpr-spill-int.c: Likewise.
	* gcc.target/gcn/avgpr-spill-long.c: Likewise.
	* gcc.target/gcn/avgpr-spill-short.c: Likewise.
2023-11-30 15:42:57 +01:00
Wilco Dijkstra
318f5232cf AArch64: Fix strict-align cpymem/setmem [PR103100]
The cpymemdi/setmemdi implementation doesn't fully support strict alignment.
Block the expansion if the alignment is less than 16 with STRICT_ALIGNMENT.
Clean up the condition when to use MOPS.

gcc/ChangeLog/
	PR target/103100
	* config/aarch64/aarch64.md (cpymemdi): Remove pattern condition.
	(setmemdi): Likewise.
	* config/aarch64/aarch64.cc (aarch64_expand_cpymem): Support
	strict-align.  Cleanup condition for using MOPS.
	(aarch64_expand_setmem): Likewise.
2023-11-30 13:27:11 +00:00
Harald Anlauf
951a3e3749 Fortran: fix TARGET attribute of associating entity in ASSOCIATE [PR112764]
The associating entity in an ASSOCIATE construct has the TARGET attribute
if and only if the selector is a variable and has either the TARGET or
POINTER attribute (e.g. F2018:11.1.3.3).

gcc/fortran/ChangeLog:

	PR fortran/112764
	* primary.cc (gfc_variable_attr): Set TARGET attribute of associating
	entity dependent on TARGET or POINTER attribute of selector.

gcc/testsuite/ChangeLog:

	PR fortran/112764
	* gfortran.dg/associate_62.f90: New test.
2023-11-30 13:37:56 +01:00
Richard Biener
2dde9f326d tree-optimization/112767 - spurious diagnostic after sccp/loop-split swap
We are diagnosing an unreachable loop which we only manage to elide
after the copyprop pass after sccp which leaves the code open for
diagnosing by the intermittent ivcanon pass.  The following makes sure
to clean things up a bit earlier, propagating constant final values
to uses immediately.

	PR tree-optimization/112767
	* tree-scalar-evolution.cc (final_value_replacement_loop):
	Propagate constants to immediate uses immediately.

	* gcc.dg/tree-ssa/pr112767.c: New testcase.
	* gcc.dg/graphite/pr83255.c: Disable SCCP.
2023-11-30 13:31:26 +01:00
Richard Biener
8a6062a47b tree-optimization/112766 - improve pruning of uninit diagnostics
Uninit diagnostics has code to prune based on incoming PHI args
that prove the uninit code is never executed.  But that only
looks at the first found flag candidate while in the PRs case
only the second candidate would be the one to prune on.  The
following patch makes us consider all of the flag candidates
which is cycles well spent IMHO.

	PR tree-optimization/112766
	* gimple-predicate-analysis.cc (find_var_cmp_const):
	Support continuing the iteration and report every candidate.
	(uninit_analysis::overlap): Iterate over all flag var
	candidates.

	* g++.dg/torture/uninit-pr112766.C: New testcase.
2023-11-30 13:31:25 +01:00
Juzhe-Zhong
303195e2a6 RISC-V: Support widening register overlap for vf4/vf8
size_t
foo (char const *buf, size_t len)
{
  size_t sum = 0;
  size_t vl = __riscv_vsetvlmax_e8m8 ();
  size_t step = vl * 4;
  const char *it = buf, *end = buf + len;
  for (; it + step <= end;)
    {
      vint8m1_t v0 = __riscv_vle8_v_i8m1 ((void *) it, vl);
      it += vl;
      vint8m1_t v1 = __riscv_vle8_v_i8m1 ((void *) it, vl);
      it += vl;
      vint8m1_t v2 = __riscv_vle8_v_i8m1 ((void *) it, vl);
      it += vl;
      vint8m1_t v3 = __riscv_vle8_v_i8m1 ((void *) it, vl);
      it += vl;

      asm volatile("nop" ::: "memory");
      vint64m8_t vw0 = __riscv_vsext_vf8_i64m8 (v0, vl);
      vint64m8_t vw1 = __riscv_vsext_vf8_i64m8 (v1, vl);
      vint64m8_t vw2 = __riscv_vsext_vf8_i64m8 (v2, vl);
      vint64m8_t vw3 = __riscv_vsext_vf8_i64m8 (v3, vl);

      asm volatile("nop" ::: "memory");
      size_t sum0 = __riscv_vmv_x_s_i64m8_i64 (vw0);
      size_t sum1 = __riscv_vmv_x_s_i64m8_i64 (vw1);
      size_t sum2 = __riscv_vmv_x_s_i64m8_i64 (vw2);
      size_t sum3 = __riscv_vmv_x_s_i64m8_i64 (vw3);

      sum += sumation (sum0, sum1, sum2, sum3);
    }
  return sum;
}

Before this patch:

        add     a3,s0,s1
        add     a4,s6,s1
        add     a5,s7,s1
        vsetvli zero,s0,e64,m8,ta,ma
        vle8.v  v4,0(s1)
        vle8.v  v3,0(a3)
        mv      s1,s2
        vle8.v  v2,0(a4)
        vle8.v  v1,0(a5)
        nop
        vsext.vf8       v8,v4
        vsext.vf8       v16,v2
        vs8r.v  v8,0(sp)
        vsext.vf8       v24,v1
        vsext.vf8       v8,v3
        nop
        vmv.x.s a1,v8
        vl8re64.v       v8,0(sp)
        vmv.x.s a3,v24
        vmv.x.s a2,v16
        vmv.x.s a0,v8
        add     s2,s2,s5
        call    sumation
        add     s3,s3,a0
        bgeu    s4,s2,.L5

After this patch:

	add	a3,s0,s1
	add	a4,s6,s1
	add	a5,s7,s1
	vsetvli	zero,s0,e64,m8,ta,ma
	vle8.v	v15,0(s1)
	vle8.v	v23,0(a3)
	mv	s1,s2
	vle8.v	v31,0(a4)
	vle8.v	v7,0(a5)
	vsext.vf8	v8,v15
	vsext.vf8	v16,v23
	vsext.vf8	v24,v31
	vsext.vf8	v0,v7
	vmv.x.s	a3,v0
	vmv.x.s	a2,v24
	vmv.x.s	a1,v16
	vmv.x.s	a0,v8
	add	s2,s2,s5
	call	sumation
	add	s3,s3,a0
	bgeu	s4,s2,.L5

	PR target/112431

gcc/ChangeLog:

	* config/riscv/vector.md: Add widening overlap of vf2/vf4.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr112431-16.c: New test.
	* gcc.target/riscv/rvv/base/pr112431-17.c: New test.
	* gcc.target/riscv/rvv/base/pr112431-18.c: New test.
2023-11-30 20:11:24 +08:00
Juzhe-Zhong
5a35152f87 RISC-V: Remove earlyclobber for wx/wf instructions.
While working on overlap for widening instructions, I realize that we set
vwadd.wx/vfwadd.wf as earlyclobber which is incorrect.

Since according to RVV ISA:
"The destination EEW equals the source EEW."

vwadd.vx widens the first source operand (i.e. 2 * source EEW = dest EEW) while
vwadd.wx only widens the second/scalar source operand.

Therefore overlap is legal for wx but not for vx.

Before this patch (heave spillings):

        csrr    a5,vlenb
        slli    a5,a5,1
        addi    a5,a5,64
        vfwadd.wf       v2,v14,fs0
        add     a5,a5,sp
        vs2r.v  v2,0(a5)
        vl2re32.v       v2,0(a1)
        vfwadd.wf       v14,v12,fs0
        vfwadd.wf       v12,v10,fs0
        vfwadd.wf       v10,v8,fs0
        vfwadd.wf       v8,v6,fs0
        vfwadd.wf       v6,v4,fs0
        vfwadd.wf       v4,v2,fs0
        vfwadd.wf       v2,v16,fs0
        vfwadd.wf       v16,v18,fs0
        vfwadd.wf       v18,v20,fs0
        vfwadd.wf       v20,v22,fs0
        vfwadd.wf       v22,v24,fs0
        vfwadd.wf       v24,v26,fs0
        vfwadd.wf       v26,v28,fs0
        vfwadd.wf       v28,v30,fs0
        vfwadd.wf       v30,v0,fs0
        nop
        vsetvli zero,zero,e32,m2,ta,ma
        csrr    a5,vlenb

After this patch (no spillings):

       	vfwadd.wf	v16,v16,fs0
	vfwadd.wf	v14,v14,fs0
	vfwadd.wf	v12,v12,fs0
	vfwadd.wf	v10,v10,fs0
	vfwadd.wf	v8,v8,fs0
	vfwadd.wf	v6,v6,fs0
	vfwadd.wf	v4,v4,fs0
	vfwadd.wf	v2,v2,fs0
	vfwadd.wf	v18,v18,fs0
	vfwadd.wf	v20,v20,fs0
	vfwadd.wf	v22,v22,fs0
	vfwadd.wf	v24,v24,fs0
	vfwadd.wf	v26,v26,fs0
	vfwadd.wf	v28,v28,fs0
	vfwadd.wf	v30,v30,fs0
	vfwadd.wf	v0,v0,fs0

Confirm the codegen above run successfully on both SPIKE/QEMU.

	PR target/112431

gcc/ChangeLog:

	* config/riscv/vector.md: Remove earlyclobber for wx/wf instructions.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/base/pr112431-19.c: New test.
	* gcc.target/riscv/rvv/base/pr112431-20.c: New test.
	* gcc.target/riscv/rvv/base/pr112431-21.c: New test.
2023-11-30 18:50:23 +08:00
Eric Botcazou
8f9956fc5c ada: Rework fix for wrong finalization of qualified aggregate in allocator
The problem is that there is no easy method to insert an action after an
arbitrary node in the tree, so the original fix does not correctly work
when the allocator is nested in another expression.

Therefore this moves the burden of the insertion from Apply_Predicate_Check
to Expand_Allocator_Expression and restricts the new processing to the case
where it is really required.

gcc/ada/

	* checks.ads (Apply_Predicate_Check): Add Deref boolean parameter.
	* checks.adb (Apply_Predicate_Check): Revert latest change. Use
	Loc local variable to hold the source location. Use a common code
	path for the generic processing and make a dereference if Deref is
	True.
	* exp_ch4.adb (Expand_Allocator_Expression): Compute Aggr_In_Place
	earlier. If it is true, do not call Apply_Predicate_Check on the
	expression on entry but on the temporary on exit with a
	dereference.
	* sem_res.adb (Resolve_Actuals): Add explicit parameter
	association in call to Apply_Predicate_Check.
2023-11-30 11:12:49 +01:00
Steve Baird
262229e1e6 ada: Support Put_Image for types in user-defined instances of predefined generics.
Predefined units do not generally support the Put_Image attribute.
There are good reasons for this in most cases. But if a user-defined
instantiation of a predefined generic occurs in Ada 2022 code, then
Put_Image can be supported for types declared therein. Add this support.

gcc/ada/

	* exp_put_image.adb (Put_Image_Enabled): Return True in more
	cases. In particular, when testing to see if a type occurs in a
	predefined unit, test the type's code unit
	(obtained by calling Get_Code_Unit). In the case of type within a
	user-defined instance of a predefined generic, Is_Predefined_Unit
	will return True for the type and False for the type's code unit.
2023-11-30 11:12:49 +01:00
Yannick Moy
1029b95079 ada: Remove SPARK legality checks
SPARK legality checks apply only to code with SPARK_Mode On, and are
performed again in GNATprove for detecting SPARK-compatible declarations
in code with SPARK_Mode Auto. Remove this duplication, to only perform
SPARK legality checking in GNATprove. After this patch, only a few
special SPARK legality checks are performed in the frontend, which could
be moved to GNATprove later.

gcc/ada/

	* contracts.adb (Analyze_Entry_Or_Subprogram_Body_Contract):
	Remove checking on volatility. Remove handling of SPARK_Mode, not
	needed anymore.
	(Analyze_Entry_Or_Subprogram_Contract): Remove checking on
	volatility.
	(Check_Type_Or_Object_External_Properties): Same.
	(Analyze_Object_Contract): Same.
	* freeze.adb (Freeze_Record_Type): Same. Also remove checking on
	synchronized types and ghost types.
	* sem_ch12.adb (Instantiate_Object): Remove checking on
	volatility.
	(Instantiate_Type): Same.
	* sem_ch3.adb (Access_Type_Declaration): Same.
	(Derived_Type_Declaration): Remove checking related to untagged
	partial view.
	(Process_Discriminants): Remove checking on volatility.
	* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Same.
	* sem_ch6.adb (Analyze_Procedure_Call): Fix use of SPARK_Mode
	where GNATprove_Mode was intended.
	* sem_disp.adb (Inherited_Subprograms): Protect against Empty
	node.
	* sem_prag.adb (Analyze_Global_In_Decl_Part): Remove checking on
	volatility.
	(Analyze_Pragma): Same.
	* sem_res.adb (Flag_Effectively_Volatile_Objects): Remove.
	(Resolve_Actuals): Remove checking on volatility.
	(Resolve_Entity_Name): Same.
	* sem_util.adb (Check_Nonvolatile_Function_Profile): Remove.
	(Check_Volatility_Compatibility): Remove.
	* sem_util.ads: Same.
2023-11-30 11:12:49 +01:00
Sheri Bernstein
dab7e3430e ada: Remove GNATcheck violations
Remove GNATcheck violations by refactoring code and also using
pragma Annotate to exempt them.

gcc/ada/

	* libgnat/i-cstrin.adb (Free): Rewrite code so there is only one
	return, to remove Improper_Returns violation.
	(Position_Of_Nul): Add pragma to exempt Improper_Returns
	violation.
	(To_Chars_Ptr): Likewise.
	(Value): Likewise
2023-11-30 11:12:48 +01:00
Viljar Indus
ce5572d4b8 ada: Ignore defered compile time errors without backend
We defer some compile time warnings and errors until the
backend has added the extra information needed. However
it is not guaranteed that the backend has run by this point.
Avoid checking these errors if the backend has not been activated
and no code has been generated.

gcc/ada/

	* sem_prag.adb (Validate_Compile_Time_Warning_Errors): Avoid
	checking compile time warnings and errors if backend has not been
	activated.
2023-11-30 11:12:48 +01:00
Yannick Moy
e5eb84aa8c ada: Fix spelling of functions with(out) "side effects"
Correct spelling does not include an hyphen. Fix comments and one
error message.

Also fix other mispellings of "side-effect" or "side effect" depending
on the case (adjective should have hyphen), and "side-effect-free" with
double hyphen as an adjective.

gcc/ada/

	* checks.adb, exp_aggr.adb, exp_ch4.ads, exp_ch5.adb,
	exp_util.adb, exp_util.ads, inline.adb, sem_ch13.adb,
	sem_ch6.adb, sem_ch8.adb, sem_prag.adb, sem_util.ads: Fix comments
	and typos.
2023-11-30 11:12:48 +01:00