Commit Graph

217772 Commits

Author SHA1 Message Date
Iain Buclaw
df4565eaa9 libphobos: Add script for extracting unittests from phobos
This script parses all unittests annotated with three slashes (`///')
and extracts them into a standalone test case.  The intended use is for
generating inexpensive tests to be ran for the phobos testsuite.

libphobos/ChangeLog:

	* scripts/.gitignore: Add tests_extractor.
	* scripts/README: Document tests_extractor.d.
	* scripts/tests_extractor.d: New file.
2025-02-25 22:31:51 +01:00
Iain Buclaw
a407eada01 libphobos: Organize druntime and phobos tests under common directory
The druntime and druntime_shared tests are identical, save for one
compiled with `-static-libphobos' and the other `-shared-libphobos'.
Move them to libphobos.druntime/static and libphobos.druntime/shared
respectively.  This has also been done for libphobos.phobos.

libphobos/ChangeLog:

	* testsuite/libphobos.druntime_shared/druntime_shared.exp: Move to...
	* testsuite/libphobos.druntime/shared/druntime-shared.exp: ...here.
	* testsuite/libphobos.druntime/druntime.exp: Move to...
	* testsuite/libphobos.druntime/static/druntime-static.exp: ...here.
	* testsuite/libphobos.phobos_shared/phobos_shared.exp: Move to...
	* testsuite/libphobos.phobos/shared/phobos-shared.exp: ...here.
	* testsuite/libphobos.phobos/phobos.exp: Move to...
	* testsuite/libphobos.phobos/static/phobos-static.exp: ...here.
2025-02-25 22:31:50 +01:00
François Dumont
bcc8dea6a4 libstdc++: [_Hashtable] Fix hash code cache usage when stateful hash functor
It is wrong to reuse a cached hash code from another container when this code depends
on the state of the container's Hash functor.

Add checks that Hash functor is stateless before reusing the cached hash code.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h
	(_Hash_code_base::_M_copy_code, _Hash_code_base::_M_store_code): Remove.
	* include/bits/hashtable.h (_M_hash_code_ext): New.
	(_M_merge_multi(_Hashtable&)): Use latter.
	(_M_copy_code): New.
	(_M_assign): Use latter.
	(_M_bucket_index_ex): New.
	(_M_equals): Use latter.
	(_M_store_code): New.
	(_M_src_hash_code): Remove key_type parameter.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc (test10): New
	test case.
2025-02-25 22:27:14 +01:00
Jason Merrill
dc9db80075 doc: update C++98 bootstrap note
r10-11132 uses C++11 default member initializers, which breaks bootstrapping
with a C++98 compiler.

gcc/ChangeLog:

	* doc/install.texi: 10.5 won't bootstrap with C++98.
2025-02-25 15:18:38 -05:00
Vladimir N. Makarov
2341f675ed [PR115458][LRA]: Run split sub-pass more times
In this PR case LRA needs to provide too many hard regs for insn
reloads, where some reload pseudos require 8 aligned regs for
themselves.  As the last attempt, LRA tries to split live ranges of
hard regs for insn reload pseudos.  It is a very rare case.  An
inheritance pseudo involving a reload pseudo of the insn can be
spilled in the assignment sub-pass run right after splitting and we need
to run split sub-pass for the inheritance pseudo now.

gcc/ChangeLog:

	PR target/115458
	* lra-int.h (LRA_MAX_FAILED_SPLITS): Define and check its value.
	(lra_split_hard_reg_for): Change prototype.
	* lra.cc (lra): Try to split hard reg range several times after a
	failure.
	* lra-assigns.cc (lra_split_hard_reg_for): Add an arg, a flag of
	giving up.  Report asm error and nullify the asm insn depending on
	the arg value.

gcc/testsuite/ChangeLog:

	PR target/115458
	* g++.target/riscv/pr115458.C: New.
2025-02-25 15:04:50 -05:00
Jakub Jelinek
0bb431d0a7 pru: Fix pru_pragma_ctable_entry diagnostics [PR118991]
HOST_WIDE_INT_PRINT* macros aren't supposed to be used in
gcc-internal-format format strings, we have the w modifier for HOST_WIDE_INT
in that case, the HOST_WIDE_INT_PRINT* macros might not work properly on
some hosts (e.g. mingw32 has HOST_LONG_LONG_FORMAT "I64" and that is
something pretty-print doesn't handle, while it handles "ll" for long long)
and also the use of macros in the middle of format strings breaks
translations (both that exgettext can't retrieve the string from there
and we get
 #: config/pru/pru-pragma.cc:61
 msgid "%<CTABLE_ENTRY%> index %"
 msgstr ""

 #: config/pru/pru-pragma.cc:64
 msgid "redefinition of %<CTABLE_ENTRY %"
 msgstr ""
in po/gcc.pot and also the macros are different on different hosts,
so even if exgettext extracted say "%<CTABLE_ENTRY%> index %lld is not valid"
it could be translated on some hosts but not e.g. mingw32).

So, the following patch just uses %wd instead.

Tested it before/after the
patch on
 #pragma ctable_entry 12 0x48040000
 #pragma ctable_entry 1024 0x48040000
 #pragma ctable_entry 12 0x48040001
and the result is the same.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR translation/118991
	* config/pru/pru-pragma.cc (pru_pragma_ctable_entry): Use %wd
	instead of %" HOST_WIDE_INT_PRINT "d to print a hwi in error.
2025-02-25 20:03:38 +01:00
Patrick Palka
1b9e4fe2ff libstdc++: Implement LWG 4027 change to possibly-const-range [PR118083]
LWG 4027 effectively makes the const range access CPOs ranges::cfoo behave
more consistently across C++23 and C++20 (pre-P2278R4) and also more
consistently with the std::cfoo range accessors, as the below testcase
adjustments demonstrate (which mostly consist of reverting workarounds
added by r14-3771-gf12e26f3496275 and r13-7186-g0d94c6df183375).

In passing fix PR118083 which reports that the input_range constraint on
possibly-const-range is missing in our implementation.  A consequence of
this is that the const range access CPOs now consistently reject a non-range
argument, and so in some our of tests we need to introduce otherwise
unused begin/end members.

	PR libstdc++/118083

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h
	(ranges::__access::__possibly_const_range): Adjust logic as per
	LWG 4027.  Add missing input_range constraint.
	* testsuite/std/ranges/access/cbegin.cc (test05): Verify LWG
	4027 testcases.
	* testsuite/std/ranges/access/cdata.cc: Adjust, simplify and
	consolidate some tests after the above.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/crbegin.cc: Likewise.
	* testsuite/std/ranges/access/crend.cc: Likewise.
	* testsuite/std/ranges/adaptors/join.cc: Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2025-02-25 13:35:04 -05:00
Iain Buclaw
fffe14f045 libphobos: Add scripts to update Makefile.am after an upstream merge
These two scripts have been used for updating Makefile.am whenever
there's been a file added/removed from either Druntime or Phobos since
the start, but never included in the source tree.

libphobos/ChangeLog:

	* libdruntime/Makefile.am: Update comment.
	* libdruntime/Makefile.in: Regenerate.
	* src/Makefile.am: Update comment.
	* src/Makefile.in: Regenerate.
	* scripts/.gitignore: New file.
	* scripts/README: New file.
	* scripts/gen_druntime_sources.d: New file.
	* scripts/gen_phobos_sources.d: New file.
2025-02-25 19:09:03 +01:00
Iain Buclaw
c17044e509 d/i386: Add CET TargetInfo key and predefined version [PR118654]
Adds a new i386 d_target_info_spec entry to handle requests for
`__traits(getTargetInfo, "CET")', and add predefined target version
`GNU_CET' when the option `-fcf-protecton' is used.

Both TargetInfo key and predefined version have been added to the D
front-end documentation.

In the library, `GNU_CET' replaces the existing use of the user-defined
version flag `CET' when building libphobos.

	PR d/118654

gcc/ChangeLog:

	* config/i386/i386-d.cc (ix86_d_target_versions): Predefine GNU_CET.
	(ix86_d_handle_target_cf_protection): New.
	(ix86_d_register_target_info): Add 'CET' TargetInfo key.

gcc/d/ChangeLog:

	* implement-d.texi: Document CET version and traits key.

libphobos/ChangeLog:

	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Remove CET_DFLAGS.
	* libdruntime/Makefile.am: Replace CET_DFLAGS with CET_FLAGS.
	* libdruntime/Makefile.in: Regenerate.
	* libdruntime/core/thread/fiber/package.d: Replace CET with GNU_CET.
	* src/Makefile.am: Replace CET_DFLAGS with CET_FLAGS.
	* src/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/testsuite_flags.in: Replace CET_DFLAGS with CET_FLAGS.

gcc/testsuite/ChangeLog:

	* gdc.dg/target/i386/i386.exp: New test.
	* gdc.dg/target/i386/targetinfo_CET.d: New test.
2025-02-25 18:04:46 +01:00
Iain Buclaw
2d812eecc3 d: Increase max parallelism of the D testsuite
It was noticed that when running the testsuite for gdc and libphobos in
parallel, this was capped at 10 simultaneous jobs each.  Increase this
limit to 128, which enables running for example `make check-d -j48` to
complete in half the time.

gcc/d/ChangeLog:

	* Make-lang.in (check_gdc_parallelize): Increase to 128.

libphobos/ChangeLog:

	* testsuite/Makefile.am (check_p_subno): Remove variable.
	(check_p_subdirs): Increase default parallel slots to 128.
	* testsuite/Makefile.in: Regenerate.
2025-02-25 17:50:24 +01:00
Andre Vehreschild
af73228fdb Fortran: Fix detection of descriptor arrays in coarray [PR107635]
Look at the formal arguments generated type in the function declaration
to figure if an argument is a descriptor arrays.  Fix handling of class
types while splitting coarray expressions.

	PR fortran/107635

gcc/fortran/ChangeLog:

	* coarray.cc (fixup_comp_refs): For class types set correct
	component (class) type.
	(split_expr_at_caf_ref): Provide location.
	* trans-intrinsic.cc (conv_caf_send_to_remote): Look at
	generated formal argument and not declared one to detect
	descriptor arrays.
	(conv_caf_sendget): Same.
2025-02-25 10:10:36 +01:00
Andre Vehreschild
cc81363c33 Fortran: Use correct size when transferring between images [PR107635]
gcc/fortran/ChangeLog:

	PR fortran/107635

	* trans-intrinsic.cc (conv_caf_sendget): Use the size of data
	transferred between the two images and not the descritor's size.
2025-02-25 10:10:36 +01:00
Jakub Jelinek
cdffc76393 openmp: Mark OpenMP atomic write expression as read [PR119000]
The following testcase was emitting false positive warning that
the rhs of #pragma omp atomic write was stored but not read,
when the atomic actually does read it.  The following patch
fixes that by calling default_function_array_read_conversion
on it, so that it is marked as read as well as converted from
lvalue to rvalue.
Furthermore, the code had
if (code == NOP_EXPR) ... else ... if (code == NOP_EXPR) ...
with none of ... parts changing code, so I've merged the two ifs.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR c/119000
	* c-parser.cc (c_parser_omp_atomic): For omp write call
	default_function_array_read_conversion on the rhs expression.
	Merge the two adjacent if (code == NOP_EXPR) blocks.

	* c-c++-common/gomp/pr119000.c: New test.
2025-02-25 09:33:21 +01:00
Jakub Jelinek
86a4af2793 openmp: Fix handling of declare target statics with array type which need destruction [PR118876]
The following testcase ICEs because it attempts to emit the __tcfa function twice,
once when handling the host destruction and once when handling nohost destruction.

This patch fixes it by using __omp_tcfa function for the nohost case and marks it
with the needed "omp declare target" and "omp declare target nohost" attributes.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118876
	* cp-tree.h (register_dtor_fn): Add a bool argument defaulted to false.
	* decl.cc (start_cleanup_fn): Add OMP_TARGET argument, use
	"__omp_tcf" prefix rather than "__tcf" in that case.  Add
	"omp declare target" and "omp declare target nohost" attributes
	to the fndecl.
	(register_dtor_fn): Add OMP_TARGET argument, pass it down to
	start_cleanup_fn.
	* decl2.cc (one_static_initialization_or_destruction): Add OMP_TARGET
	argument, pass it down to register_dtor_fn.
	(emit_partial_init_fini_fn): Pass omp_target to
	one_static_initialization_or_destruction.
	(handle_tls_init): Pass false to
	one_static_initialization_or_destruction.

	* g++.dg/gomp/pr118876.C: New test.
2025-02-25 09:29:39 +01:00
Jakub Jelinek
a41b3f54c1 c++: Fix range for with PMFs [PR118923]
The following testcases segfault because the new range for -frange-for-ext-temps
temporary extension extends even the internal TARGET_EXPRs created by
get_member_function_from_ptrfunc.

The following patch fixes that by using get_internal_target_expr for those
instead of force_target_expr (similarly in cp_finish_decl and
build_comparison_op) and using force_target_expr inside of
get_internal_target_expr.

2025-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR c++/118923
	* tree.cc (get_internal_target_expr): Use force_target_expr
	instead of build_target_expr_with_type.
	* typeck.cc (get_member_function_from_ptrfunc): Use
	get_internal_target_expr instead of force_target_expr.
	* decl.cc (cp_finish_decl): Likewise.
	* method.cc (build_comparison_op): Likewise.

	* g++.dg/cpp0x/pr118923.C: New test.
	* g++.dg/cpp1y/pr118923.C: New test.
2025-02-25 09:26:46 +01:00
GCC Administrator
90b735b397 Daily bump. 2025-02-25 00:17:52 +00:00
Robin Dapp
6be1b9e94d RISC-V: Include pattern stmts for dynamic LMUL computation [PR114516].
When scanning for program points, i.e. vector statements, we're missing
pattern statements.  In PR114516 this becomes obvious as we choose
LMUL=8 assuming there are only three statements but the divmod pattern
adds another three.  Those push us beyond four registers so we need to
switch to LMUL=4.

This patch adds pattern statements to the program points which helps
calculate a better register pressure estimate.

	PR target/114516

gcc/ChangeLog:

	* config/riscv/riscv-vector-costs.cc (compute_estimated_lmul):
	Add pattern statements to program points.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/costmodel/riscv/rvv/pr114516.c: New test.
2025-02-24 16:04:13 +01:00
Robin Dapp
f3d4208e79 vect: Use original LHS type for gather pattern [PR118950].
In PR118950 we do not zero masked elements in a gather load.
While recognizing a gather/scatter pattern we do not use the original
type of the LHS.  This matters because the type can differ with bool
patterns (e.g. _Bool vs unsigned char) and we don't notice the need
for zeroing out the padding bytes.

This patch just uses the original LHS's type.

	PR middle-end/118950

gcc/ChangeLog:

	* tree-vect-patterns.cc (vect_recog_gather_scatter_pattern): Use
	original LHS's type.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/pr118950.c: New test.
2025-02-24 13:11:15 +01:00
Jakub Jelinek
5806279610 reassoc: Fix up optimize_range_tests_to_bit_test [PR118915]
The following testcase is miscompiled due to a bug in
optimize_range_tests_to_bit_test.  It is trying to optimize
check for a in [-34,-34] or [-26,-26] or [-6,-6] or [-4,inf] ranges.
Another reassoc optimization folds the the test for the first
two ranges into (a + 34U) & ~8U in [0U,0U] range, and extract_bit_test_mask
actually has code to virtually undo it and treat that again as test
for a being -34 or -26.  The problem is that optimize_range_tests_to_bit_test
remembers in the type variable TREE_TYPE (ranges[i].exp); from the first
range.  If extract_bit_test_mask doesn't do that virtual undoing of the
BIT_AND_EXPR handling, that is just fine, the returned exp is ranges[i].exp.
But if the first range is BIT_AND_EXPR, the type could be different, the
BIT_AND_EXPR form has the optional cast to corresponding unsigned type
in order to avoid introducing UB.  Now, type was used to fill in the
max value if ranges[j].high was missing in subsequently tested range,
and so in this particular testcase the [-4,inf] range which was
signed int and so [-4,INT_MAX] was treated as [-4,UINT_MAX] instead.
And we were subtracting values of 2 different types and trying to make
sense out of that.

The following patch fixes this by using the type of the low bound
(which is always non-NULL) for the max value of the high bound instead.

2025-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/118915
	* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): For
	highj == NULL_TREE use TYPE_MAX_VALUE (TREE_TYPE (lowj)) rather
	than TYPE_MAX_VALUE (type).

	* gcc.c-torture/execute/pr118915.c: New test.
2025-02-24 12:19:16 +01:00
Richard Biener
9e4c57f7a6 tree-optimization/118973 - stray abnormal edge after DCE
DCE preserves stmts performing abnormal control flow transfer but
currently has an exception for replaceable allocations and cxa_atexit
calls.  That results in a broken CFG since DCE isn't set up to prune
abnormal edges possibly hanging off those.

While we could try to add this handling, the following is the safe
fix at this point and more suitable for backporting.

	PR tree-optimization/118973
	* tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Calls
	that alter control flow in unpredictable ways need to be
	preserved.

	* g++.dg/torture/pr118973.C: New testcase.
2025-02-24 11:11:54 +01:00
Jakub Jelinek
27ebd2a55c openmp: Fix diagnostics typo [PR118993]
There is a typo in one of the OpenMP gimplification diagnostics messages.
The following patch fixes that and adjusts tests which just copied that
message including typo to dg-warning regexps in 2 tests.

2025-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/118993
	* gimplify.cc (gimplify_scan_omp_clauses): Fix diagnostics typo,
	undfined -> undefined.

	* c-c++-common/gomp/allocate-18.c: Adjust dg-warning regex for
	diagnostics typo fix.
	* gfortran.dg/gomp/allocate-clause.f90: Likewise.
2025-02-24 09:25:34 +01:00
Jakub Jelinek
0d590d2158 Use nonnull_if_nonzero attribute rather than nonnull on various builtins [PR117023]
On top of the
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668699.html
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668700.html
patches the following patch adds nonnull_if_nonzero attribute(s) to
various builtins instead of or in addition to nonnull attribute.

The patch adjusts builtins (when we have them) corresponding to the APIs
mentioned in the C2Y N3322 paper:
1) strndup and memset get one nonnull_if_nonzero attribute instead of
   nonnull
2) memcpy, memmove, strncpy, memcmp, strncmp get two nonnull_if_nonzero
   attributes instead of nonnull
3) strncat has nonnull without argument changed to nonnull (1) and
   gets one nonnull_if_nonzero for the src argument (maybe it needs
   to be clarified in C2Y, but I really think first argument to strncat
   and wcsncat shouldn't be NULL even for n == 0, because NULL doesn't
   point to NULL terminated string and one can't append anything to it;
   and various implementations in the wild including glibc will crash
   with NULL first argument (x86_64 avx+ doesn't though)

Such changes are done also to the _chk suffixed counterparts of the
builtins.

Furthermore I've changed a couple of builtins for POSIX functions which
aren't covered by ISO C, but I'd expect if/when POSIX incorporates C2Y
it would do the same changes.  In particular

4) strnlen gets one nonnull_if_nonzero instead of nonnull
5) mempcpy and stpncpy get two nonnull_if_nonzero instead of nonnull
   and lose returns_nonnull attribute; this is kind of unfortunate
   but I think in the spirit of N3322 mempcpy (NULL, src, 0) should
   return NULL (i.e. dest + n aka NULL + 0, now valid) and it is hard to
   express returns non-NULL if first argument is non-NULL or third argument
   is non-zero

I'm not really sure about fread/fwrite, N3322 doesn't mention those,
can the first argument be NULL if third argument is 0?  What about
if second argument is 0?  Can the fourth argument be NULL in such cases?

And of course, when not using builtins the glibc headers will affect stuff
too, so we'll need to wait for N3322 implementation there too (possibly
by dropping the nonnull attributes and perhaps conditionally replacing them
with this new one if the compiler supports them).

2025-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR c/117023
gcc/
	* builtin-attrs.def (ATTR_NONNULL_IF_NONZERO): New DEF_ATTR_IDENT.
	(ATTR_NOTHROW_NONNULL_IF12_LEAF, ATTR_NOTHROW_NONNULL_IF13_LEAF,
	ATTR_NOTHROW_NONNULL_IF123_LEAF, ATTR_NOTHROW_NONNULL_IF23_LEAF,
	ATTR_NOTHROW_NONNULL_1_IF23_LEAF, ATTR_PURE_NOTHROW_NONNULL_IF12_LEAF,
	ATTR_PURE_NOTHROW_NONNULL_IF13_LEAF,
	ATTR_PURE_NOTHROW_NONNULL_IF123_LEAF,
	ATTR_WARN_UNUSED_RESULT_NOTHROW_NONNULL_IF12_LEAF,
	ATTR_MALLOC_WARN_UNUSED_RESULT_NOTHROW_NONNULL_IF12_LEAF): New
	DEF_ATTR_TREE_LIST.
	* builtins.def (BUILT_IN_STRNDUP): Use
	ATTR_MALLOC_WARN_UNUSED_RESULT_NOTHROW_NONNULL_IF12_LEAF instead of
	ATTR_MALLOC_WARN_UNUSED_RESULT_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_STRNCAT, BUILT_IN_STRNCAT_CHK): Use
	ATTR_NOTHROW_NONNULL_1_IF23_LEAF instead of ATTR_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_BCOPY, BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK,
	BUILT_IN_MEMMOVE, BUILT_IN_MEMMOVE_CHK,  BUILT_IN_STRNCPY,
	BUILT_IN_STRNCPY_CHK): Use ATTR_NOTHROW_NONNULL_IF123_LEAF instead of
	ATTR_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_MEMPCPY, BUILT_IN_MEMPCPY_CHK, BUILT_IN_STPNCPY,
	BUILT_IN_STPNCPY_CHK): Use ATTR_NOTHROW_NONNULL_IF123_LEAF instead of
	ATTR_RETNONNULL_NOTHROW_LEAF.
	(BUILT_IN_BZERO, BUILT_IN_MEMSET, BUILT_IN_MEMSET_CHK): Use
	ATTR_NOTHROW_NONNULL_IF13_LEAF instead of ATTR_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_BCMP, BUILT_IN_MEMCMP, BUILT_IN_STRNCASECMP,
	BUILT_IN_STRNCMP): Use ATTR_PURE_NOTHROW_NONNULL_IF123_LEAF instead of
	ATTR_PURE_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_STRNLEN): Use ATTR_PURE_NOTHROW_NONNULL_IF12_LEAF instead of
	ATTR_PURE_NOTHROW_NONNULL_LEAF.
	(BUILT_IN_MEMCHR): Use ATTR_PURE_NOTHROW_NONNULL_IF13_LEAF instead of
	ATTR_PURE_NOTHROW_NONNULL_LEAF.
gcc/testsuite/
	* gcc.dg/builtins-nonnull.c (test_memfuncs, test_memfuncs_chk,
	test_strfuncs, test_strfuncs_chk): Add if (n == 0) return; at the
	start of the functions.
	* gcc.dg/Wnonnull-2.c: Copy __builtin_* call statements where
	appropriate 3 times, once with 0 length, once with n and once with
	non-zero constant and expect warning only in the third case.
	Formatting fixes.
	* gcc.dg/Wnonnull-3.c: Copy __builtin_* call statements where
	appropriate 3 times, once with 0 length, once with n and once with
	n guarded with n != 0 and expect warning only in the third case.
	Formatting fixes.
	* gcc.dg/nonnull-3.c (foo): Use 16 instead of 0 in the calls added
	for PR80936.
	* gcc.dg/nonnull-11.c: New test.
	* c-c++-common/ubsan/nonnull-1.c: Don't expect runtime diagnostics
	for the __builtin_memcpy call.
	* gcc.dg/tree-ssa/pr78154.c (f): Add dn argument and return early
	if it is NULL.  Duplicate cases of builtins which have the first
	argument changed from nonnull to nonnull_if_nonzero except stpncpy,
	once with dn as first argument instead of d and once with constant
	non-zero count rather than n.  Disable the stpncpy non-null check.
	* gcc.dg/Wbuiltin-declaration-mismatch-14.c (test_builtin_calls):
	Triplicate the strncmp calls, once with 1 last argument and expect
	warning, once with n last argument and don't expect warning and
	once with 0 last argument and don't expect warning.
	* gcc.dg/Wbuiltin-declaration-mismatch-15.c (test_builtin_calls_fe):
	Likewise.
2025-02-24 09:20:47 +01:00
Jakub Jelinek
206cb6c105 analyzer: Handle nonnull_if_nonzero attribute [PR117023]
On top of the
https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html
patch which introduces the nonnull_if_nonzero attribute (because
C2Y is allowing NULL arguments on various calls like memcpy, memset,
strncpy etc. as long as the count is 0) the following patch adds just
limited handling of the attribute in the analyzer.

For nonnull attribute(s) we have the get_nonnull_args helper which
returns a bitmap, for nonnull_if_nonzero a function would need to
return a hash_map or something similar, I think it is better to
handle the attributes one by one.  This patch just handles the
non-zero INTEGER_CST (integer_nonzerop) count arguments, in other places
the above patch uses ranger to some extent, but I'm not familiar enough
with the analyzer to know if one can use the ranger, or should somehow
explain in data structures the conditional nature of the nonnull property,
the argument is nonnull only if some other argument is nonzero.

Also, analyzer uses get_nonnull_args in another spot when entering a frame,
not sure if anything can be done there (note the conditional nonnull
somehow, pass from callers if the argument is nonzero, ...).

Note, the testsuite changes aren't strictly necessary with just
the above and this patch, but will be with a patch I'm going to post
soon.

2025-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR c/117023
gcc/analyzer/
	* sm-malloc.cc (malloc_state_machine::handle_nonnull): New private
	method.
	(malloc_state_machine::on_stmt): Use it for nonnull attribute arguments.
	Handle also nonnull_if_nonzero attributes.
gcc/testsuite/
	* c-c++-common/analyzer/call-summaries-malloc.c
	(test_use_without_check): Pass 4 rather than sz to memset.
	* c-c++-common/analyzer/strncpy-1.c (test_null_dst,
	test_null_src): Pass 42 rather than count to strncpy.
2025-02-24 09:18:27 +01:00
Lino Hsing-Yu Peng
4dcd3c7749 RISC-V: Fix .cfi_offset directive when push/pop in zcmp
The incorrect cfi directive info breaks stack unwind in try/catch/cxa.

Before patch:
  cm.push	{ra, s0-s2}, -16
  .cfi_offset 1, -12
  .cfi_offset 8, -8
  .cfi_offset 18, -4

After patch:
  cm.push	{ra, s0-s2}, -16
  .cfi_offset 1, -16
  .cfi_offset 8, -12
  .cfi_offset 9, -8
  .cfi_offset 18, -4

gcc/ChangeLog:

	* config/riscv/riscv.cc: Set multi push regs bits.

gcc/testsuite/ChangeLog:
	* gcc.target/riscv/zcmp_push_gpr.c: New test.
2025-02-24 16:04:32 +08:00
GCC Administrator
7cfb2c8839 Daily bump. 2025-02-24 00:17:12 +00:00
H.J. Lu
bf0aa9dc88 x86: Add tests for PR tree-optimization/82142
Verify that PR tree-optimization/82142 testcase is properly optimized.

	PR tree-optimization/82142
	* gcc.target/i386/pr82142a.c: New file.
	* gcc.target/i386/pr82142b.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-24 05:54:26 +08:00
GCC Administrator
4cc54ed1f0 Daily bump. 2025-02-23 00:17:00 +00:00
Jonathan Wakely
d4a777d098 libstdc++: Fix bootstrap failure with --enable-vtable-verify [PR118981]
The compiler emits code with init_priority(99) for -fvtable-verify=std
and that creates a section conflict with the uses of init_priority(99)
that I recently added to src/c++20/tzdb.cc.

Change tzdb.cc to use a different priority to avoid the conflict.

libstdc++-v3/ChangeLog:

	PR c++/118981
	* src/c++20/tzdb.cc: Use init_priority(98) instead of
	init_priority(99).
2025-02-22 22:51:33 +00:00
Thomas Schwinge
0128fa8b41 Turn test cases into UNSUPPORTED if running into 'sorry, unimplemented: dynamic stack allocation not supported'
In Subversion r217296 (Git commit e2acc079ff)
"Testsuite alloca fixes for ptx", effective-target 'alloca' was added to mark
up test cases that run into the nvptx back end's non-support of dynamic stack
allocation.  (Later, nvptx gained conditional support for that in
commit 3861d362ec
"nvptx: PTX 'alloca' for '-mptx=7.3'+, '-march=sm_52'+ [PR65181]", but on the
other hand, in commit f93a612fc4
"bpf: liberate R9 for general register allocation", the BPF back end joined
"the list of targets that do not support alloca in target-support.exp".

Manually maintaining the list of test cases requiring effective-target 'alloca'
is notoriously hard, gets out of date quickly: new test cases added to the test
suite may need to be analyzed and annotated, and over time annotations also may
need to be removed, in cases where the compiler learns to optimize out
'alloca'/VLA usage, for example.  This commit replaces (99 % of) the manual
annotations with an automatic scheme: turn test cases into UNSUPPORTED if
running into 'sorry, unimplemented: dynamic stack allocation not supported'.

	gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_alloca):
	Gracefully handle the case that we've not be called (indirectly)
	from 'dg-test'.
	* lib/gcc-dg.exp (proc gcc-dg-prune): Turn
	'sorry, unimplemented: dynamic stack allocation not supported' into
	UNSUPPORTED.
	* c-c++-common/Walloca-larger-than.c: Don't
	'dg-require-effective-target alloca'.
	* c-c++-common/Warray-bounds-9.c: Likewise.
	* c-c++-common/Warray-bounds.c: Likewise.
	* c-c++-common/Wdangling-pointer-2.c: Likewise.
	* c-c++-common/Wdangling-pointer-4.c: Likewise.
	* c-c++-common/Wdangling-pointer-5.c: Likewise.
	* c-c++-common/Wdangling-pointer.c: Likewise.
	* c-c++-common/Wimplicit-fallthrough-7.c: Likewise.
	* c-c++-common/Wsizeof-pointer-memaccess1.c: Likewise.
	* c-c++-common/Wsizeof-pointer-memaccess2.c: Likewise.
	* c-c++-common/Wstringop-truncation.c: Likewise.
	* c-c++-common/Wunused-var-6.c: Likewise.
	* c-c++-common/Wunused-var-8.c: Likewise.
	* c-c++-common/analyzer/alloca-leak.c: Likewise.
	* c-c++-common/analyzer/allocation-size-multiline-2.c: Likewise.
	* c-c++-common/analyzer/allocation-size-multiline-3.c: Likewise.
	* c-c++-common/analyzer/capacity-1.c: Likewise.
	* c-c++-common/analyzer/capacity-3.c: Likewise.
	* c-c++-common/analyzer/imprecise-floating-point-1.c: Likewise.
	* c-c++-common/analyzer/infinite-recursion-alloca.c: Likewise.
	* c-c++-common/analyzer/malloc-callbacks.c: Likewise.
	* c-c++-common/analyzer/malloc-paths-8.c: Likewise.
	* c-c++-common/analyzer/out-of-bounds-5.c: Likewise.
	* c-c++-common/analyzer/out-of-bounds-diagram-11.c: Likewise.
	* c-c++-common/analyzer/uninit-alloca.c: Likewise.
	* c-c++-common/analyzer/write-to-string-literal-5.c: Likewise.
	* c-c++-common/asan/alloca_loop_unpoisoning.c: Likewise.
	* c-c++-common/auto-init-11.c: Likewise.
	* c-c++-common/auto-init-12.c: Likewise.
	* c-c++-common/auto-init-15.c: Likewise.
	* c-c++-common/auto-init-16.c: Likewise.
	* c-c++-common/builtins.c: Likewise.
	* c-c++-common/dwarf2/vla1.c: Likewise.
	* c-c++-common/gomp/pr61486-2.c: Likewise.
	* c-c++-common/torture/builtin-clear-padding-4.c: Likewise.
	* c-c++-common/torture/strub-run3.c: Likewise.
	* c-c++-common/torture/strub-run4.c: Likewise.
	* c-c++-common/torture/strub-run4c.c: Likewise.
	* c-c++-common/torture/strub-run4d.c: Likewise.
	* c-c++-common/torture/strub-run4i.c: Likewise.
	* g++.dg/Walloca1.C: Likewise.
	* g++.dg/Walloca2.C: Likewise.
	* g++.dg/cpp0x/pr70338.C: Likewise.
	* g++.dg/cpp1y/lambda-generic-vla1.C: Likewise.
	* g++.dg/cpp1y/vla10.C: Likewise.
	* g++.dg/cpp1y/vla2.C: Likewise.
	* g++.dg/cpp1y/vla6.C: Likewise.
	* g++.dg/cpp1y/vla8.C: Likewise.
	* g++.dg/debug/debug5.C: Likewise.
	* g++.dg/debug/debug6.C: Likewise.
	* g++.dg/debug/pr54828.C: Likewise.
	* g++.dg/diagnostic/pr70105.C: Likewise.
	* g++.dg/eh/cleanup5.C: Likewise.
	* g++.dg/eh/spbp.C: Likewise.
	* g++.dg/ext/builtin_alloca.C: Likewise.
	* g++.dg/ext/tmplattr9.C: Likewise.
	* g++.dg/ext/vla10.C: Likewise.
	* g++.dg/ext/vla11.C: Likewise.
	* g++.dg/ext/vla12.C: Likewise.
	* g++.dg/ext/vla15.C: Likewise.
	* g++.dg/ext/vla16.C: Likewise.
	* g++.dg/ext/vla17.C: Likewise.
	* g++.dg/ext/vla23.C: Likewise.
	* g++.dg/ext/vla3.C: Likewise.
	* g++.dg/ext/vla6.C: Likewise.
	* g++.dg/ext/vla7.C: Likewise.
	* g++.dg/init/array24.C: Likewise.
	* g++.dg/init/new47.C: Likewise.
	* g++.dg/init/pr55497.C: Likewise.
	* g++.dg/opt/pr78201.C: Likewise.
	* g++.dg/template/vla2.C: Likewise.
	* g++.dg/torture/Wsizeof-pointer-memaccess1.C: Likewise.
	* g++.dg/torture/Wsizeof-pointer-memaccess2.C: Likewise.
	* g++.dg/torture/pr62127.C: Likewise.
	* g++.dg/torture/pr67055.C: Likewise.
	* g++.dg/torture/stackalign/eh-alloca-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-inline-2.C: Likewise.
	* g++.dg/torture/stackalign/eh-vararg-1.C: Likewise.
	* g++.dg/torture/stackalign/eh-vararg-2.C: Likewise.
	* g++.dg/warn/Wplacement-new-size-5.C: Likewise.
	* g++.dg/warn/Wsizeof-pointer-memaccess-1.C: Likewise.
	* g++.dg/warn/Wvla-1.C: Likewise.
	* g++.dg/warn/Wvla-3.C: Likewise.
	* g++.old-deja/g++.ext/array2.C: Likewise.
	* g++.old-deja/g++.ext/constructor.C: Likewise.
	* g++.old-deja/g++.law/builtin1.C: Likewise.
	* g++.old-deja/g++.other/crash12.C: Likewise.
	* g++.old-deja/g++.other/eh3.C: Likewise.
	* g++.old-deja/g++.pt/array6.C: Likewise.
	* g++.old-deja/g++.pt/dynarray.C: Likewise.
	* gcc.c-torture/compile/20000923-1.c: Likewise.
	* gcc.c-torture/compile/20030224-1.c: Likewise.
	* gcc.c-torture/compile/20071108-1.c: Likewise.
	* gcc.c-torture/compile/20071117-1.c: Likewise.
	* gcc.c-torture/compile/900313-1.c: Likewise.
	* gcc.c-torture/compile/parms.c: Likewise.
	* gcc.c-torture/compile/pr17397.c: Likewise.
	* gcc.c-torture/compile/pr35006.c: Likewise.
	* gcc.c-torture/compile/pr42956.c: Likewise.
	* gcc.c-torture/compile/pr51354.c: Likewise.
	* gcc.c-torture/compile/pr52714.c: Likewise.
	* gcc.c-torture/compile/pr55851.c: Likewise.
	* gcc.c-torture/compile/pr77754-1.c: Likewise.
	* gcc.c-torture/compile/pr77754-2.c: Likewise.
	* gcc.c-torture/compile/pr77754-3.c: Likewise.
	* gcc.c-torture/compile/pr77754-4.c: Likewise.
	* gcc.c-torture/compile/pr77754-5.c: Likewise.
	* gcc.c-torture/compile/pr77754-6.c: Likewise.
	* gcc.c-torture/compile/pr78439.c: Likewise.
	* gcc.c-torture/compile/pr79413.c: Likewise.
	* gcc.c-torture/compile/pr82564.c: Likewise.
	* gcc.c-torture/compile/pr87110.c: Likewise.
	* gcc.c-torture/compile/pr99787-1.c: Likewise.
	* gcc.c-torture/compile/vla-const-1.c: Likewise.
	* gcc.c-torture/compile/vla-const-2.c: Likewise.
	* gcc.c-torture/execute/20010209-1.c: Likewise.
	* gcc.c-torture/execute/20020314-1.c: Likewise.
	* gcc.c-torture/execute/20020412-1.c: Likewise.
	* gcc.c-torture/execute/20021113-1.c: Likewise.
	* gcc.c-torture/execute/20040223-1.c: Likewise.
	* gcc.c-torture/execute/20040308-1.c: Likewise.
	* gcc.c-torture/execute/20040811-1.c: Likewise.
	* gcc.c-torture/execute/20070824-1.c: Likewise.
	* gcc.c-torture/execute/20070919-1.c: Likewise.
	* gcc.c-torture/execute/built-in-setjmp.c: Likewise.
	* gcc.c-torture/execute/pr22061-1.c: Likewise.
	* gcc.c-torture/execute/pr43220.c: Likewise.
	* gcc.c-torture/execute/pr82210.c: Likewise.
	* gcc.c-torture/execute/pr86528.c: Likewise.
	* gcc.c-torture/execute/vla-dealloc-1.c: Likewise.
	* gcc.dg/20001012-2.c: Likewise.
	* gcc.dg/20020415-1.c: Likewise.
	* gcc.dg/20030331-2.c: Likewise.
	* gcc.dg/20101010-1.c: Likewise.
	* gcc.dg/Walloca-1.c: Likewise.
	* gcc.dg/Walloca-10.c: Likewise.
	* gcc.dg/Walloca-11.c: Likewise.
	* gcc.dg/Walloca-12.c: Likewise.
	* gcc.dg/Walloca-13.c: Likewise.
	* gcc.dg/Walloca-14.c: Likewise.
	* gcc.dg/Walloca-15.c: Likewise.
	* gcc.dg/Walloca-2.c: Likewise.
	* gcc.dg/Walloca-3.c: Likewise.
	* gcc.dg/Walloca-4.c: Likewise.
	* gcc.dg/Walloca-5.c: Likewise.
	* gcc.dg/Walloca-6.c: Likewise.
	* gcc.dg/Walloca-7.c: Likewise.
	* gcc.dg/Walloca-8.c: Likewise.
	* gcc.dg/Walloca-9.c: Likewise.
	* gcc.dg/Walloca-larger-than-2.c: Likewise.
	* gcc.dg/Walloca-larger-than-3.c: Likewise.
	* gcc.dg/Walloca-larger-than-4.c: Likewise.
	* gcc.dg/Walloca-larger-than.c: Likewise.
	* gcc.dg/Warray-bounds-22.c: Likewise.
	* gcc.dg/Warray-bounds-41.c: Likewise.
	* gcc.dg/Warray-bounds-46.c: Likewise.
	* gcc.dg/Warray-bounds-48-novec.c: Likewise.
	* gcc.dg/Warray-bounds-48.c: Likewise.
	* gcc.dg/Warray-bounds-50.c: Likewise.
	* gcc.dg/Warray-bounds-63.c: Likewise.
	* gcc.dg/Warray-bounds-66.c: Likewise.
	* gcc.dg/Wdangling-pointer.c: Likewise.
	* gcc.dg/Wfree-nonheap-object-2.c: Likewise.
	* gcc.dg/Wfree-nonheap-object.c: Likewise.
	* gcc.dg/Wrestrict-17.c: Likewise.
	* gcc.dg/Wrestrict.c: Likewise.
	* gcc.dg/Wreturn-local-addr-2.c: Likewise.
	* gcc.dg/Wreturn-local-addr-3.c: Likewise.
	* gcc.dg/Wreturn-local-addr-4.c: Likewise.
	* gcc.dg/Wreturn-local-addr-6.c: Likewise.
	* gcc.dg/Wsizeof-pointer-memaccess1.c: Likewise.
	* gcc.dg/Wstack-usage.c: Likewise.
	* gcc.dg/Wstrict-aliasing-bogus-vla-1.c: Likewise.
	* gcc.dg/Wstrict-overflow-27.c: Likewise.
	* gcc.dg/Wstringop-overflow-15.c: Likewise.
	* gcc.dg/Wstringop-overflow-23.c: Likewise.
	* gcc.dg/Wstringop-overflow-25.c: Likewise.
	* gcc.dg/Wstringop-overflow-27.c: Likewise.
	* gcc.dg/Wstringop-overflow-3.c: Likewise.
	* gcc.dg/Wstringop-overflow-39.c: Likewise.
	* gcc.dg/Wstringop-overflow-56.c: Likewise.
	* gcc.dg/Wstringop-overflow-57.c: Likewise.
	* gcc.dg/Wstringop-overflow-67.c: Likewise.
	* gcc.dg/Wstringop-overflow-71.c: Likewise.
	* gcc.dg/Wstringop-truncation-3.c: Likewise.
	* gcc.dg/Wvla-larger-than-1.c: Likewise.
	* gcc.dg/Wvla-larger-than-2.c: Likewise.
	* gcc.dg/Wvla-larger-than-3.c: Likewise.
	* gcc.dg/Wvla-larger-than-4.c: Likewise.
	* gcc.dg/Wvla-larger-than-5.c: Likewise.
	* gcc.dg/analyzer/boxed-malloc-1.c: Likewise.
	* gcc.dg/analyzer/call-summaries-2.c: Likewise.
	* gcc.dg/analyzer/malloc-1.c: Likewise.
	* gcc.dg/analyzer/malloc-reuse.c: Likewise.
	* gcc.dg/analyzer/out-of-bounds-diagram-12.c: Likewise.
	* gcc.dg/analyzer/pr93355-localealias.c: Likewise.
	* gcc.dg/analyzer/putenv-1.c: Likewise.
	* gcc.dg/analyzer/taint-alloc-1.c: Likewise.
	* gcc.dg/analyzer/torture/pr93373.c: Likewise.
	* gcc.dg/analyzer/torture/ubsan-1.c: Likewise.
	* gcc.dg/analyzer/vla-1.c: Likewise.
	* gcc.dg/atomic/stdatomic-vm.c: Likewise.
	* gcc.dg/attr-alloc_size-6.c: Likewise.
	* gcc.dg/attr-alloc_size-7.c: Likewise.
	* gcc.dg/attr-alloc_size-8.c: Likewise.
	* gcc.dg/attr-alloc_size-9.c: Likewise.
	* gcc.dg/attr-noipa.c: Likewise.
	* gcc.dg/auto-init-uninit-36.c: Likewise.
	* gcc.dg/auto-init-uninit-9.c: Likewise.
	* gcc.dg/auto-type-1.c: Likewise.
	* gcc.dg/builtin-alloc-size.c: Likewise.
	* gcc.dg/builtin-dynamic-alloc-size.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-1.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-2.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-3.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-4.c: Likewise.
	* gcc.dg/builtin-object-size-1.c: Likewise.
	* gcc.dg/builtin-object-size-2.c: Likewise.
	* gcc.dg/builtin-object-size-3.c: Likewise.
	* gcc.dg/builtin-object-size-4.c: Likewise.
	* gcc.dg/builtins-64.c: Likewise.
	* gcc.dg/builtins-68.c: Likewise.
	* gcc.dg/c23-auto-2.c: Likewise.
	* gcc.dg/c99-const-expr-13.c: Likewise.
	* gcc.dg/c99-vla-1.c: Likewise.
	* gcc.dg/fold-alloca-1.c: Likewise.
	* gcc.dg/gomp/pr30494.c: Likewise.
	* gcc.dg/gomp/vla-2.c: Likewise.
	* gcc.dg/gomp/vla-3.c: Likewise.
	* gcc.dg/gomp/vla-4.c: Likewise.
	* gcc.dg/gomp/vla-5.c: Likewise.
	* gcc.dg/graphite/pr99085.c: Likewise.
	* gcc.dg/guality/guality.c: Likewise.
	* gcc.dg/lto/pr80778_0.c: Likewise.
	* gcc.dg/nested-func-10.c: Likewise.
	* gcc.dg/nested-func-12.c: Likewise.
	* gcc.dg/nested-func-13.c: Likewise.
	* gcc.dg/nested-func-14.c: Likewise.
	* gcc.dg/nested-func-15.c: Likewise.
	* gcc.dg/nested-func-16.c: Likewise.
	* gcc.dg/nested-func-17.c: Likewise.
	* gcc.dg/nested-func-9.c: Likewise.
	* gcc.dg/packed-vla.c: Likewise.
	* gcc.dg/pr100225.c: Likewise.
	* gcc.dg/pr25682.c: Likewise.
	* gcc.dg/pr27301.c: Likewise.
	* gcc.dg/pr31507-1.c: Likewise.
	* gcc.dg/pr33238.c: Likewise.
	* gcc.dg/pr41470.c: Likewise.
	* gcc.dg/pr49120.c: Likewise.
	* gcc.dg/pr50764.c: Likewise.
	* gcc.dg/pr51491-2.c: Likewise.
	* gcc.dg/pr51990-2.c: Likewise.
	* gcc.dg/pr51990.c: Likewise.
	* gcc.dg/pr59011.c: Likewise.
	* gcc.dg/pr59523.c: Likewise.
	* gcc.dg/pr61561.c: Likewise.
	* gcc.dg/pr78468.c: Likewise.
	* gcc.dg/pr78902.c: Likewise.
	* gcc.dg/pr79972.c: Likewise.
	* gcc.dg/pr82875.c: Likewise.
	* gcc.dg/pr83844.c: Likewise.
	* gcc.dg/pr84131.c: Likewise.
	* gcc.dg/pr87099.c: Likewise.
	* gcc.dg/pr87320.c: Likewise.
	* gcc.dg/pr89045.c: Likewise.
	* gcc.dg/pr91014.c: Likewise.
	* gcc.dg/pr93986.c: Likewise.
	* gcc.dg/pr98721-1.c: Likewise.
	* gcc.dg/pr99122-2.c: Likewise.
	* gcc.dg/shrink-wrap-alloca.c: Likewise.
	* gcc.dg/sso-14.c: Likewise.
	* gcc.dg/strlenopt-62.c: Likewise.
	* gcc.dg/strlenopt-83.c: Likewise.
	* gcc.dg/strlenopt-84.c: Likewise.
	* gcc.dg/strlenopt-91.c: Likewise.
	* gcc.dg/torture/Wsizeof-pointer-memaccess1.c: Likewise.
	* gcc.dg/torture/calleesave-sse.c: Likewise.
	* gcc.dg/torture/pr48953.c: Likewise.
	* gcc.dg/torture/pr71881.c: Likewise.
	* gcc.dg/torture/pr71901.c: Likewise.
	* gcc.dg/torture/pr78742.c: Likewise.
	* gcc.dg/torture/pr92088-1.c: Likewise.
	* gcc.dg/torture/pr92088-2.c: Likewise.
	* gcc.dg/torture/pr93124.c: Likewise.
	* gcc.dg/torture/pr94479.c: Likewise.
	* gcc.dg/torture/stackalign/alloca-1.c: Likewise.
	* gcc.dg/torture/stackalign/inline-2.c: Likewise.
	* gcc.dg/torture/stackalign/nested-3.c: Likewise.
	* gcc.dg/torture/stackalign/vararg-1.c: Likewise.
	* gcc.dg/torture/stackalign/vararg-2.c: Likewise.
	* gcc.dg/tree-ssa/20030807-2.c: Likewise.
	* gcc.dg/tree-ssa/20080530.c: Likewise.
	* gcc.dg/tree-ssa/alias-37.c: Likewise.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-22.c: Likewise.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-25.c: Likewise.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Likewise.
	* gcc.dg/tree-ssa/loop-interchange-15.c: Likewise.
	* gcc.dg/tree-ssa/pr23848-1.c: Likewise.
	* gcc.dg/tree-ssa/pr23848-2.c: Likewise.
	* gcc.dg/tree-ssa/pr23848-3.c: Likewise.
	* gcc.dg/tree-ssa/pr23848-4.c: Likewise.
	* gcc.dg/uninit-32.c: Likewise.
	* gcc.dg/uninit-36.c: Likewise.
	* gcc.dg/uninit-39.c: Likewise.
	* gcc.dg/uninit-41.c: Likewise.
	* gcc.dg/uninit-9-O0.c: Likewise.
	* gcc.dg/uninit-9.c: Likewise.
	* gcc.dg/uninit-pr100250.c: Likewise.
	* gcc.dg/uninit-pr101300.c: Likewise.
	* gcc.dg/uninit-pr101494.c: Likewise.
	* gcc.dg/uninit-pr98583.c: Likewise.
	* gcc.dg/vla-2.c: Likewise.
	* gcc.dg/vla-22.c: Likewise.
	* gcc.dg/vla-24.c: Likewise.
	* gcc.dg/vla-3.c: Likewise.
	* gcc.dg/vla-4.c: Likewise.
	* gcc.dg/vla-stexp-1.c: Likewise.
	* gcc.dg/vla-stexp-2.c: Likewise.
	* gcc.dg/vla-stexp-4.c: Likewise.
	* gcc.dg/vla-stexp-5.c: Likewise.
	* gcc.dg/winline-7.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-1.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-10.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-2.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-3.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-4.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-5.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-6.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-7.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-8.c: Likewise.
	* gcc.target/aarch64/stack-check-alloca-9.c: Likewise.
	* gcc.target/arc/interrupt-6.c: Likewise.
	* gcc.target/i386/pr80969-3.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-1.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-2.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-3.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-4.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-5.c: Likewise.
	* gcc.target/loongarch/stack-check-alloca-6.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-1.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-10.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-2.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-3.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-4.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-5.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-6.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-7.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-8.c: Likewise.
	* gcc.target/riscv/stack-check-alloca-9.c: Likewise.
	* gcc.target/sparc/setjmp-1.c: Likewise.
	* gcc.target/x86_64/abi/ms-sysv/ms-sysv.c: Likewise.
	* gcc.c-torture/compile/20001221-1.c: Don't 'dg-skip-if'
	for '! alloca'.
	* gcc.c-torture/compile/20020807-1.c: Likewise.
	* gcc.c-torture/compile/20050801-2.c: Likewise.
	* gcc.c-torture/compile/920428-4.c: Likewise.
	* gcc.c-torture/compile/debugvlafunction-1.c: Likewise.
	* gcc.c-torture/compile/pr41469.c: Likewise.
	* gcc.c-torture/execute/920721-2.c: Likewise.
	* gcc.c-torture/execute/920929-1.c: Likewise.
	* gcc.c-torture/execute/921017-1.c: Likewise.
	* gcc.c-torture/execute/941202-1.c: Likewise.
	* gcc.c-torture/execute/align-nest.c: Likewise.
	* gcc.c-torture/execute/alloca-1.c: Likewise.
	* gcc.c-torture/execute/pr22061-4.c: Likewise.
	* gcc.c-torture/execute/pr36321.c: Likewise.
	* gcc.dg/torture/pr8081.c: Likewise.
	* gcc.dg/analyzer/data-model-1.c: Don't
	'dg-require-effective-target alloca'.  XFAIL relevant
	'dg-warning's for '! alloca'.
	* gcc.dg/uninit-38.c: Likewise.
	* gcc.dg/uninit-pr98578.c: Likewise.
	* gcc.dg/compat/struct-by-value-22_main.c: Comment on
	'dg-require-effective-target alloca'.
	libstdc++-v3/
	* testsuite/lib/prune.exp (proc libstdc++-dg-prune): Turn
	'sorry, unimplemented: dynamic stack allocation not supported' into
	UNSUPPORTED.
2025-02-22 22:37:51 +01:00
Thomas Schwinge
e8e228acff Gracefully handle the case that 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' has not been called (indirectly) from 'dg-test'
No change in behavior intended.

	gcc/testsuite/
	* lib/gcc-dg.exp (find-dg-do-what): Gracefully handle the case
	that we've not be called (indirectly) from 'dg-test'.
	* lib/target-supports.exp (check_effective_target_stack_size)
	(check_effective_target_alloca): Catch this.
2025-02-22 22:37:50 +01:00
Thomas Schwinge
f553b1aaa2 Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'
No change in behavior intended.

	gcc/testsuite/
	* lib/gcc-dg.exp (proc find-dg-do-what): New.
	* lib/target-supports.exp (check_effective_target_stack_size)
	(check_effective_target_alloca): Use it.
2025-02-22 22:37:50 +01:00
Thomas Schwinge
2abc942fd4 BPF, nvptx: Standardize on 'sorry, unimplemented: dynamic stack allocation not supported'
... instead of BPF: 'error: BPF does not support dynamic stack allocation', and
nvptx: 'sorry, unimplemented: target cannot support alloca'.

	gcc/
	* config/bpf/bpf.md (define_expand "allocate_stack"): Emit
	'sorry, unimplemented: dynamic stack allocation not supported'.
	* config/nvptx/nvptx.md (define_expand "allocate_stack")
	[!TARGET_SOFT_STACK && !(TARGET_PTX_7_3 && TARGET_SM52)]: Likewise.
	gcc/testsuite/
	* gcc.target/bpf/diag-alloca-1.c: Adjust 'dg-message'.
	* gcc.target/bpf/diag-alloca-2.c: Likewise.
	* gcc.target/nvptx/alloca-1-sm_30.c: Likewise.
	* gcc.target/nvptx/vla-1-sm_30.c: Likewise.
	* lib/target-supports.exp (proc check_effective_target_alloca):
	Adjust comment.
2025-02-22 22:37:50 +01:00
shynur
e759ff08e2 libgomp: Add '__attribute__((unused))' to variables used only in 'assert(...)'
Without this attribute, the building process will fail if GCC is configured
with 'CFLAGS=-DNDEBUG'.

libgomp/ChangeLog:

	* oacc-mem.c (acc_unmap_data, goacc_exit_datum_1, find_group_last,
	goacc_enter_data_internal): Add '__attribute__((unused))'.
	* target.c (gomp_unmap_vars_internal): Likewise.
2025-02-22 22:37:50 +01:00
Jonathan Wakely
4470229653 libstdc++: Remove misleading comment in __atomic_base<Int>
No conversion is needed because the type of _M_i is __int_type anyway.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (__atomic_base<_ITp>): Remove
	misleading comment.
2025-02-22 21:20:19 +00:00
Jonathan Wakely
a742b27bd2 libstdc++: Remove redundant cast in floating_from_chars.cc
In r15-7647-g32457bc25fea80 I added a cast and also changed the type of
the variable, making the cast redundant. This removes the cast.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (__floating_from_chars_hex):
	Remove redundant cast.
2025-02-22 21:20:18 +00:00
Sandra Loosemore
c978965b44 OpenMP: Silence uninitialized variable warning in C++ front end.
There's no actual problem with the code here, just a false-positive
warning emitted by some older GCC versions.

gcc/cp/ChangeLog
	* parser.cc (cp_finish_omp_declare_variant): Initialize
	append_args_last.
2025-02-22 17:08:35 +00:00
Gaius Mulley
a2f60c1ff5 PR modula2/118978 ICE when attempting to pass an incompatible parameter
This bugfix is for a an ICE which occurs if an incompatible parameter
is passed to a procedure.  In particular if a REAL constant actual
parameter is passed to INTEGER formal parameter then M2Range is invoked
to check the type and then M2Range is called to check the value range.

The value range check causes an ICE.  The bug fix introduces range
dependencies on type checks.  If the type check fails an
error message is generated and any future range check cancelled.
These range and type checks are tightly coupled when generating
parameter quad intermediate code.

gcc/m2/ChangeLog:

	PR modula2/118978
	* gm2-compiler/M2Check.mod (checkConstMeta): Add check for
	typed constants.
	* gm2-compiler/M2Quads.mod (BoolFrame): New field RangeDep.
	(CheckProcedureParameters): Call PutRangeDep to associate the
	range dependency with the parameter on the quad stack.
	Pass ParamCheckId to CheckParameter.
	(CheckProcTypeAndProcedure): Add ParamCheckId parameter.
	Pass ParamCheckId to BuildRange.
	(CheckParameter): New parameter ParamCheckId.
	Pass ParamCheckId to CheckProcTypeAndProcedure.
	(CheckParameterOrdinals): Add extra range dep parameter to the
	call of InitParameterRangeCheck.
	(ConvertBooleanToVariable): Initialize RangeDep field.
	(PushBacktok): Ditto.
	(OperandRangeDep): New procedure.
	(PutRangeDep): Ditto.
	* gm2-compiler/M2Range.def (InitTypesParameterCheck): Add new
	parameter depRangeId.
	(InitParameterRangeCheck): Add new parameter parentRangeId.
	(FoldRangeCheck): Add new parameter range.
	* gm2-compiler/M2Range.mod (InitTypesParameterCheck): Add new
	parameter depRangeId.
	(InitParameterRangeCheck): Add new parameter parentRangeId.
	(FoldRangeCheck): Add new parameter range and rewrite.
	(FoldRangeCheckLower): New procedure.
	(Range): New field cancelled.
	New field dependantid.
	(PutRangeParam): Initialize dependantid.
	(PutRangeParamAssign): Ditto.
	(CheckCancelled): New procedure.
	(Cancel): Ditto.
	(IsCancelled): New procedure function.
	(FoldTypeParam): Add depRangeId parameter.
	(WriteRangeCheck): Add dependent debugging.

gcc/testsuite/ChangeLog:

	PR modula2/118978
	* gm2/pim/fail/badparamtype.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-02-22 16:47:21 +00:00
GCC Administrator
4de2d2f80e Daily bump. 2025-02-22 00:17:38 +00:00
H.J. Lu
700f049b66 Append a newline in debug_edge
Append a newline in debug_edge so that we get

(gdb) call debug_edge (e)
edge (bb_9, bb_1)
(gdb)

instead of

(gdb) call debug_edge (e)
edge (bb_9, bb_1)(gdb)

	* sese.cc (debug_edge): Append a newline.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-02-22 04:30:21 +08:00
Richard Biener
ee30e2586a tree-optimization/118954 - avoid UB on ref created by predcom
When predicitive commoning moves an invariant ref it makes sure to
not build a MEM_REF with a base that is negatively offsetted from
an object.  But in trying to preserve some transforms it does not
consider association of a constant offset with the address computation
in DR_BASE_ADDRESS leading to exactly this problem again.  This is
arguably a problem in data-ref analysis producing such an out-of-bound
DR_BASE_ADDRESS, but this looks quite involved to fix, so the
following avoids the association in one more case.  This fixes the
testcase while preserving the desired transform in
gcc.dg/tree-ssa/predcom-1.c.

	PR tree-optimization/118954
	* tree-predcom.cc (ref_at_iteration): Make sure to not
	associate the constant offset with DR_BASE_ADDRESS when
	that is an offsetted pointer.

	* gcc.dg/torture/pr118954.c: New testcase.
2025-02-21 13:05:13 +01:00
Richard Biener
d2720051c4 Improve g++.dg/torture/pr118521.C
Alexander pointed out the way to do a dg-bogus in an included header.

	PR tree-optimization/118521
	* g++.dg/torture/pr118521.C: Use dg-bogus properly.
2025-02-21 10:08:24 +01:00
Harald Anlauf
7d383a7343 Fortran: initialize non-saved pointers with -fcheck=pointer [PR48958]
PR fortran/48958

gcc/fortran/ChangeLog:

	* trans-array.cc (gfc_trans_deferred_array): Initialize the data
	component of non-saved pointers when -fcheck=pointer is set.

gcc/testsuite/ChangeLog:

	* gfortran.dg/pointer_init_13.f90: New test.
2025-02-21 09:30:05 +01:00
Andre Vehreschild
08bdc2ac98 Fortran: Fix build on solaris [PR107635]
libgfortran/ChangeLog:

	PR fortran/107635
	* caf/single.c: Replace alloca with __builtin_alloca.
2025-02-21 09:13:50 +01:00
Tobias Burnus
8293b9e40f Fortran: Improve gfc_array_kind for assumed rank; gfc_tree_array_size on 'tree'
Improve the internal and debug representation of assumed-rank arrays by
honoring the pointer and allocatable property.

Permit obtaining the array size from only a tree (via the array descriptor)
besides obtaining it from the gfc_expr's array spec. This will be used
by a follow up OpenMP patch for mapping derived types with allocatable
components.

gcc/fortran/ChangeLog:

	* trans-array.cc (gfc_full_array_size): Obtain the rank from
	the array descriptor for assumed rank.
	(gfc_tree_array_size): Likewise; permit expr = NULL to operate
	only the tree.
	(gfc_conv_descriptor_stride_get): Update for added assumed-rank
	array types.
	* trans-openmp.cc (gfc_omp_finish_clause): Likewise.
	* trans-types.cc (gfc_build_array_type, gfc_get_derived_type,
	gfc_get_array_descr_info): Likewise.
	* trans.h (enum gfc_array_kind): Add
	GFC_ARRAY_ASSUMED_RANK_{ALLOCATABLE,POINTER{,_CONT}}.
2025-02-21 08:54:12 +01:00
GCC Administrator
fe4811fd19 Daily bump. 2025-02-21 00:17:36 +00:00
David Malcolm
4e9ee99647 diagnostics: add comments about global_dc
No functional change intended.

gcc/ChangeLog:
	* diagnostic-core.h: Add comments making clear that these
	functions implicitly use global_dc.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-02-20 17:10:54 -05:00
David Malcolm
c5f541e40a sarif-replay: add testcase for empty input file
gcc/testsuite/ChangeLog:
	* sarif-replay.dg/malformed-json/empty.sarif: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-02-20 17:10:54 -05:00
David Malcolm
5a30a3aba0 sarif-replay: improve error for unescaped braces in messages (§3.11.5)
Spotted via https://github.com/llvm/llvm-project/issues/128024

gcc/ChangeLog:
	* libsarifreplay.cc
	(sarif_replayer::make_plain_text_within_result_message): Capture
	which json::string was used.  When reporting on unescaped "{" or
	"}" in SARIF message strings, use that string rather than the
	message object, and refer the user to §3.11.5 ("Messages with
	placeholders") rather than §3.11.11 ("arguments").  Ideally we'd
	place the error at the precise character, but that can't be done
	without reworking json-parsing.cc's lexer::lex_string, which is
	too invasive for stage 4.
	(sarif_replayer::get_plain_text_from_mfms): Capture which
	json::string was used.
	(sarif_replayer::lookup_plain_text_within_result_message):
	Likewise.

gcc/testsuite/ChangeLog:
	* sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif:
	Rename to...
	* sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif:
	...this.  Update expected subsection in error message, and
	expected underline in quoted JSON.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-02-20 17:10:53 -05:00
Gerald Pfeifer
25fa8d6dc3 doc: Drop note for Binutils pre 2.24
Binutils 2.24 was released in 2013, so this is more than 11 years old.

gcc:
	PR target/69374
	* doc/install.texi (Specific, aarch64*-*-*): Drop note for
	Binutils pre 2.24.
2025-02-20 18:53:47 +01:00
Richard Sandiford
d7ff314282 aarch64: Remove old aarch64_expand_sve_vec_cmp_float code
While looking at PR118956, I noticed that we had some dead code
left over after the removal of the vcond patterns.  The can_invert_p
path is no longer used.

gcc/
	* config/aarch64/aarch64-protos.h (aarch64_expand_sve_vec_cmp_float):
	Remove can_invert_p argument and change return type to void.
	* config/aarch64/aarch64.cc (aarch64_expand_sve_vec_cmp_float):
	Likewise.
	* config/aarch64/aarch64-sve.md (vec_cmp<mode><vpred>): Update call
	accordingly.
2025-02-20 17:10:14 +00:00