Skip to content

Synchronize development branch with GCC's master branch #3761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10,000 commits into
base: master
Choose a base branch
from

Conversation

dkm
Copy link
Member

@dkm dkm commented Apr 22, 2025

This branch has a no-op merge as the last commit:

  • one arm is the "current" development branch from github
  • the other arm is a rebased version of the "current" master branch onto a recent GCC's master

The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.

@dkm dkm self-assigned this Apr 22, 2025
@dkm dkm marked this pull request as draft April 22, 2025 19:39
@dkm dkm force-pushed the dkm/master-rebased branch 2 times, most recently from 135065f to 64035a8 Compare April 28, 2025 20:07
@powerboat9
Copy link
Collaborator

powerboat9 commented Apr 28, 2025

Wouldn't it be easier to put commits adjusting the expected warnings after the merge commit? Doesn't really matter either way, of course.

@dkm dkm force-pushed the dkm/master-rebased branch 5 times, most recently from ae5132f to e57faeb Compare May 5, 2025 20:09
apinski-quic and others added 20 commits May 8, 2025 11:53
…PLE_COND

Since match and simplify will simplify `bool_var != 0` to just `bool_var` and
this is inside a GIMPLE_COND, fold_stmt will return true but nothing has changed.
So let's just reject the replacement if we are replacing with the same simplification
inside replace_stmt_with_simplification. This can speed up things slightly because
now fold_stmt won't return true on all GIMPLE_COND with `bool_var != 0` in it.

gcc/ChangeLog:

	* gimple-fold.cc (replace_stmt_with_simplification): Return false
	if replacing `bool_var != 0` with `bool_var` in GIMPLE_COND.

Signed-off-by: Andrew Pinski <[email protected]>
This tweak to CWG2369 has gotten more discussion lately in CWG, including in
P3606.  In those discussions, it occurred to me that having the check depend
on whether a class has been instantiated yet is unstable, that it should
only check for user-defined conversions.

Also, one commenter was surprised that adding an explicitly-declared default
constructor to a class changed things, so this patch also changes the
aggregate check to more narrowly checking for one-argument constructors
other than the copy/move constructors.

As a result, this early filter resembles how LOOKUP_DEFAULTED rejects any
candidate that would need a UDC: in both cases we want to avoid considering
arbitrary UDCs.  But here, rather than rejecting, we want the early filter
to let the candidate past without considering the conversion.

	PR c++/99599

gcc/cp/ChangeLog:

	* cp-tree.h (type_has_converting_constructor): Declare.
	* class.cc (type_has_converting_constructor): New.
	* pt.cc	(conversion_may_instantiate_p): Don't check completeness.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-recursive-sat4.C: Adjust again.
	* g++.dg/cpp2a/concepts-nondep5.C: New test.
	PR fortran/120179

gcc/fortran/ChangeLog:

	* match.cc (gfc_match_do): Do not attempt to match end-of-statement
	twice.

gcc/testsuite/ChangeLog:

	* gfortran.dg/do_concurrent_basic.f90: Extend testcase.
The default test running in rvv.exp takes the -fno-vect-cost-model
for most of these options.  It is not that suitable as the vx_vf
test depends on the cost-model.  Thus, separate the vx_vf test
cases without -fno-vect-cost-model in another options.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/rvv.exp: Separate test running of
	rvv vx_vf.

Signed-off-by: Pan Li <[email protected]>
This patch would like to rename the VX_BINARY within CASE_0 suffix, as
we have another case of VX_BINARY test code.  Aka case 1:

L1:
  vmv.v.x
  vadd.vv
  J L1

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Rename VX_BINARY
	to VX_BINARY_CASE_0 for underlying case 1.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i16.c: Take the
	new name for test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i8.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u16.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u32.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u64.c: Ditto
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u8.c: Ditto

Signed-off-by: Pan Li <[email protected]>
… GR2VR cost 0

Add asm dump check and for vec_duplicate + vadd.vv combine case 1 to vadd.vx.
The late-combine will take action when GR2VR cost is 0, because the vmv
and the vadd.vx will consume the same cost of GR2VR.  Aka:

Before:
L1:
  vmv.v.x
  vadd.vv
  J L1

After:
L1:
  vadd.vx
  J L1

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: Add test
	helper macros.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-i16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-i32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-i64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-i8.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-u16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-u32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-u64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-4-u8.c: New test.

Signed-off-by: Pan Li <[email protected]>
… GR2VR cost 1

Add asm dump check and for vec_duplicate + vadd.vv combine case 1 to vadd.vx
with the cost of GR2VR is 1.  The testcases is not that tidy according
to the result, but we will continue tuning the cost model for this.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-i16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-i32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-i64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-i8.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-u16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-u32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-u64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-5-u8.c: New test.

Signed-off-by: Pan Li <[email protected]>
… GR2VR cost 2

Add asm dump check and for vec_duplicate + vadd.vv combine case 1 to vadd.vx
with the cost of GR2VR is 2.  The testcases is not that tidy according
to the result, but we will continue tuning the cost model for this.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-i16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-i32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-i64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-i8.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-u16.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-u32.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-u64.c: New test.
	* gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-6-u8.c: New test.

Signed-off-by: Pan Li <[email protected]>
…ink [PR116792]

In r15-3752-g48261bd26df624 I added a test plugin that overrode the
regular output, instead emitting diagnostics in crude HTML form.

In r15-4760-g0b73e9382ab51c I added support for multiple kinds of
diagnostic output simultaneously, adding
 -fdiagnostics-add-output=DIAGNOSTICS-OUTPUT-SPEC
 -fdiagnostics-set-output=DIAGNOSTICS-OUTPUT-SPEC
for adding/changing the kind of diagnostics output, supporting
"text" and "sarif" output schemes.

This patch promotes the HTML output code from the test plugins so
that it is available from "-fdiagnostics-add-output=", using a
new "experimental-html" scheme, to allow simultaneous text, sarif
and html output, and to make it easier to experiment with.  The
patch adds Python-based testing of the emitted HTML.

The patch does not affect the generated HTML, which is still crude, and
not yet ready for end-users.  I hope to improve it in followups.

gcc/ChangeLog:
	PR other/116792
	* Makefile.in (OBJS-libcommon): Add diagnostic-format-html.o.
	* diagnostic-format-html.cc: Move here from
	testsuite/gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc.
	Simplify includes.  Rename "xhtml" to "html" throughout.
	(write_escaped_text): Drop.
	(class xhtml_stream_output_format): Drop.
	(class html_file_output_format): Reimplement using
	diagnostic_output_file.
	(diagnostic_output_format_init_xhtml): Drop.
	(diagnostic_output_format_init_xhtml_stderr): Drop.
	(diagnostic_output_format_init_xhtml_file): Drop.
	(diagnostic_output_format_open_html_file): New.
	(make_html_sink): New.
	(xhtml_format_selftests): Convert to...
	(diagnostic_format_html_cc_tests): ...this.
	(plugin_is_GPL_compatible): Drop.
	(plugin_init): Drop.
	* diagnostic-format-html.h: New file.
	* doc/invoke.texi (-fdiagnostics-add-output=): Add
	"experimental-html" scheme.
	* opts-diagnostic.cc: Include "diagnostic-format-html.h".
	(class html_scheme_handler): New.
	(output_factory::output_factory): Add html_scheme_handler.
	(html_scheme_handler::make_sink): New.
	* selftest-run-tests.cc (selftest::run_tests): Call the new
	selftests.
	* selftest.h (selftest::diagnostic_format_html_cc_tests): New
	decl.

gcc/testsuite/ChangeLog:
	PR other/116792
	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Move to
	gcc/diagnostic-format-html.cc.
	* gcc.dg/html-output/html-output.exp: New support script.
	* gcc.dg/html-output/missing-semicolon.c: New test.
	* gcc.dg/html-output/missing-semicolon.py: New test script.
	* gcc.dg/plugin/diagnostic-test-xhtml-1.c: Deleted test.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Drop moved plugin
	and its deleted test.
	* lib/gcc-dg.exp (load_lib): Add load_lib of scanhtml.exp.
	* lib/htmltest.py: New support script.
	* lib/scanhtml.exp: New support script, based on scansarif.exp.

libatomic/ChangeLog:
	PR other/116792
	* testsuite/lib/libatomic.exp: Add load_lib of scanhtml.exp.

libgomp/ChangeLog:
	PR other/116792
	* testsuite/lib/libgomp.exp: Add load_lib of scanhtml.exp.

libitm/ChangeLog:
	PR other/116792
	* testsuite/lib/libitm.exp: Add load_lib of scanhtml.exp.

libphobos/ChangeLog:
	PR other/116792
	* testsuite/lib/libphobos-dg.exp: Add load_lib of scanhtml.exp.

libvtv/ChangeLog:
	PR other/116792
	* testsuite/lib/libvtv-dg.exp: Add load_lib of scanhtml.exp.

Signed-off-by: David Malcolm <[email protected]>
This patch provides _M_discarding functiosn for _Sink_iter and _Sink function
that returns true, if any further writes to the _Sink_iter and underlying _Sink,
will be discared, and thus can be omitted.

Currently only the _Padding_sink reports discarding mode of if width of sequence
characters is greater than _M_maxwidth (precision), or underlying _Sink is
discarding characters. The _M_discarding override, is separate function from
_M_ignoring, that remain annotated with [[__gnu__::__always_inline__]].

Despite having notion of maximum characters to be written (_M_max), _Iter_sink
nevers discard characters, as the total number of characters that would be written
needs to be returned by format_to_n. This is documented in-source by providing an
_Iter_sink::_M_discarding override, that always returns false.

The function is currently queried only by the _Padding_sinks, that may be stacked
for example a range is formatted, with padding with being specified both for range
itself and it's elements. The state of underlying sink is checked during construction
and after each write (_M_sync_discarding).

libstdc++-v3/ChangeLog:

	* include/std/format (__Sink_iter<_CharT>::_M_discarding)
	(__Sink<_CharT>::_M_discarding, _Iter_sink<_CharT, _OutIter>::_M_discarding)
	(_Padding_sinl<_CharT, _Out>::_M_padwidth)
	(_Padding_sink<_CharT, _Out>::_M_maxwidth): Remove const.
	(_Padding_sink<_CharT, _Out>::_M_sync_discarding)
	(_Padding_sink<_CharT, _Out>::_M_discarding): Define.
	(_Padding_sink<_CharT, _Out>::_Padding_sink(_Out, size_t, size_t))
	(_Padding_sink<_CharT, _Out>::_M_force_update):
	(_Padding_sink<_CharT, _Out>::_M_flush): Call _M_sync_discarding.
	(_Padding_sink<_CharT, _Out>::_Padding_sink(_Out, size_t)): Delegate.

Reviewed-by: Jonathan Wakely <[email protected]>
Signed-off-by: Tomasz Kamiński <[email protected]>
…output.

Formatting code is extracted to _M_format_to function, that produced output
to specified iterator. This function is now invoked either with __fc.out()
directly (if width is not specified) or _Padding_sink::out().

This avoid formatting to temporary string if no padding is requested,
and minimize allocations otherwise. For more details see commit message of
r16-142-g01e5ef3e8b91288f5d387a27708f9f8979a50edf.

This should not increase number of instantiations, as implementation only
produce basic_format_context with _Sink_iter as iterator, which is also
_Padding_sink iterator.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (__formatter_chrono::_M_format_to):
	Extracted from _M_format.
	(__formatter_chrono::_M_format): Use _Padding_sink and delegate
	to _M_format_to.

Reviewed-by: Jonathan Wakely <[email protected]>
Signed-off-by: Tomasz Kamiński <[email protected]>
The path "b/binutils/dwarf.c" should be printed as binutils/dwarf.c",
not "inutils/dwarf.c".

contrib/ChangeLog:

	* check_GNU_style_lib.py: Remove literal prefix.

Signed-off-by: Torbjörn SVENSSON <[email protected]>
…ted instructions.

SVE loads and stores where the predicate is all-true can be optimized to
unpredicated instructions. For example,
svuint8_t foo (uint8_t *x)
{
  return svld1 (svptrue_b8 (), x);
}
was compiled to:
foo:
	ptrue	p3.b, all
	ld1b	z0.b, p3/z, [x0]
	ret
but can be compiled to:
foo:
	ldr	z0, [x0]
	ret

Late_combine2 had already been trying to do this, but was missing the
instruction:
(set (reg/i:VNx16QI 32 v0)
    (unspec:VNx16QI [
            (const_vector:VNx16BI repeat [
                    (const_int 1 [0x1])
                ])
            (mem:VNx16QI (reg/f:DI 0 x0 [orig:106 x ] [106])
	      [0 MEM <svuint8_t> [(unsigned char *)x_2(D)]+0 S[16, 16] A8])
        ] UNSPEC_PRED_X))

This patch adds a new define_insn_and_split that matches the missing
instruction and splits it to an unpredicated load/store. Because LDR
offers fewer addressing modes than LD1[BHWD], the pattern is
guarded under reload_completed to only apply the transform once the
address modes have been chosen during RA.

The patch was bootstrapped and tested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <[email protected]>

gcc/
	* config/aarch64/aarch64-sve.md (*aarch64_sve_ptrue<mode>_ldr_str):
	Add define_insn_and_split to fold predicated SVE loads/stores with
	ptrue predicates to unpredicated instructions.

gcc/testsuite/
	* gcc.target/aarch64/sve/ptrue_ldr_str.c: New test.
	* gcc.target/aarch64/sve/acle/general/attributes_6.c: Adjust
	expected outcome.
	* gcc.target/aarch64/sve/cost_model_14.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/cost_model_4.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/cost_model_5.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/cost_model_6.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/cost_model_7.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_f16.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_f32.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_f64.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_mf8.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_s16.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_s32.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_s64.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_s8.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_u16.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_u32.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_u64.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/pcs/varargs_2_u8.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/peel_ind_2.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/single_1.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/single_2.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/single_3.c: Adjust expected outcome.
	* gcc.target/aarch64/sve/single_4.c: Adjust expected outcome.
Limit option '-mgeneral-regs-only' to those in supported backends.

Version log:
https://patchwork.sourceware.org/project/gcc/patch/[email protected]/

gcc/testsuite/ChangeLog:

	* gcc.dg/pr119160.c: Limit backends.
Some systems don't support the %zu format modifier for size_t, such as
hppa64-hp-hpux. We don't really need the full width of size_t for
printing the number of prime paths as path counts of those sizes
would've already blown up the machine. For printing the vector size we
can use the formatting directives from hwint.h.

	PR gcov-profile/120086

gcc/ChangeLog:

	* gcov.cc (print_prime_path_lines): Use unsigned, format with
	%u.
	(print_prime_path_source): Likewise.
	(output_path_coverage): Format with HOST_SIZE_T_PRINT_UNSIGNED,
	use unsigned for pathno.
Since this test is a 'dg-do run', it requires tls_runtime rather than
just tls.

This makes the test UNSUPPORTED on targets such as arm-non-eabi,
instead of FAIL/UNRESOLVED because __aeabi_read_tp is not provided
(e.g. when GCC is configured with --enable-threads=no.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/decomp2.C: Require tls_runtime.
This test is 'dg-do compile', so require tls instead of tls_runtime.

This enables it on targets such as arm-none-eabi configured with
--enable-threads=no.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/constinit16.C: Require tls.
The following addresses a too conservative sanity check of SLP nodes
we want to promote external.  The issue lies in code generation
for such external which relies on get_later_stmt to figure an
insert location.  But get_later_stmt relies on the ability to
totally order stmts, specifically implementation-wise that they
are all from the same BB, which is what is verified at the moment.

The patch changes this to require stmts to be orderable by
dominance queries.  For simplicity and seemingly enough for the
testcase in PR119960, this handles the case of two distinct BBs.

	PR tree-optimization/119960
	* tree-vect-slp.cc (vect_slp_can_convert_to_external):
	Handle cases where defs from multiple BBs are ordered
	by their dominance relation.

	* gcc.dg/vect/bb-slp-pr119960-1.c: New testcase.
While the tests checked whether the CUDA/HIP runtime is available
before processing them, the execution was then done unconditionally,
leading to FAIL when the default device was the host (or the wrong
offload device).

Now the test is only executed ('run') when the default device is an
Nvidia or AMD GPU (depending on the test case, cf. the test file name).
Otherwise, only a 'link' test is done. (Except when the effective-target
check cannot find the runtime lib - then the test is skipped [as before].)

Note: The cublas/hipblas tests use variant functions and iterate over
all devices, such that the cublas or hipblas, respectively, is only
called when the active device is an AMD or Nvidia device, respectively,
while for the host and other device types the fallback is called.

libgomp/ChangeLog:

	* testsuite/libgomp.c/interop-cuda-full.c: Use 'link' instead
	of 'run' when the default device is "! offload_device_nvptx".
	* testsuite/libgomp.c/interop-cuda-libonly.c: Likewise.
	* testsuite/libgomp.c/interop-hip-nvidia-full.c: Likewise.
	* testsuite/libgomp.c/interop-hip-nvidia-no-headers.c: Likewise.
	* testsuite/libgomp.c/interop-hip-nvidia-no-hip-header.c: Likewise.
	* testsuite/libgomp.fortran/interop-hip-nvidia-full.F90: Likewise.
	* testsuite/libgomp.fortran/interop-hip-nvidia-no-module.F90: Likewise.
	* testsuite/libgomp.c/interop-hip-amd-full.c: Use 'link' instead
	of 'run' when the default device is "! offload_device_gcn".
	* testsuite/libgomp.c/interop-hip-amd-no-hip-header.c: Likewise.
	* testsuite/libgomp.fortran/interop-hip-amd-full.F90: Likewise.
	* testsuite/libgomp.fortran/interop-hip-amd-no-module.F90: Likewise.
CohenArthur and others added 19 commits May 12, 2025 22:42
Allow matching on a struct instance and rebinding its fields to new names:

match X {
	Foo {
		field0: new_name0,
		field1: new_name1,
	} => {
		do_something(new_name0, new_name1);
	},
}

This will enable us to finish derives for PartialEq and PartialOrd but
isn't a complete implementation of these patterns yet.

gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc (CompilePatternBindings::make_struct_access):
	New function.
	(CompilePatternBindings::visit): Properly implement patterns mentioned above
	and call make_struct_accesss.
	* backend/rust-compile-pattern.h: New declaration.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/struct_pattern1.rs: New test.
gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): Remove old invalid
	checks.
gcc/rust/ChangeLog:

	* ast/rust-ast-builder.cc (Builder::struct_pattern_ident_pattern): New.
	* ast/rust-ast-builder.h: New declaration.
gcc/rust/ChangeLog:

	* expand/rust-derive-partial-eq.cc (DerivePartialEq::match_enum_tuple): Remove debug call.
	(DerivePartialEq::match_enum_struct): Add proper implementation.
	(DerivePartialEq::visit_enum): Call it.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/derive-partialeq2.rs: New test.
gcc/testsuite/ChangeLog:

	* rust/execute/torture/derive-partialeq2.rs: Add missing terminating nul char.

Co-authored-by: Pierre-Emmanuel Patry <[email protected]>
Rust only allows impl traits to be used in the return position of
functions.

Fixes #1485

gcc/rust/ChangeLog:

	* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): allow impl type
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): likewise
	* hir/rust-ast-lower-type.cc (ASTLoweringType::ASTLoweringType): new flag for impl trait
	(ASTLoweringType::translate): pass flag
	(ASTLoweringType::visit): track impl trait tag
	(ASTLoweringType::emit_impl_trait_error): new diagnostic
	* hir/rust-ast-lower-type.h: add new field

gcc/testsuite/ChangeLog:

	* rust/compile/impl_trait_diag.rs: New test.
	* rust/compile/issue-1485.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Argument position impl traits are simply syntatic sugar for generics. This
adds a new desugar pass to do this. So for example:

    fn foo(a: impl Value, b: impl Value) -> i32

Is desugared into:

    fn foo<T: Value, U: Value> (a: T, b: U) -> i32

So it just works like any normal generic function. There are more complex cases such as:

    fn foo(_value: impl Bar<Baz = impl Foo>) -> i32

Which has a generic argument binding which needs to be turned into a where constraint:

    fn foo<T, U>(_value: T) -> i32
        where
            T: Bar<Baz = U>,
            U: Foo,

Fixes #2015
Fixes #1487
Fixes #3454
Fixes #1482

gcc/rust/ChangeLog:

	* Make-lang.in: new desugar file
	* ast/rust-ast.cc (ImplTraitTypeOneBound::as_string): its a unique_ptr now
	(FormatArgs::set_outer_attrs): reformat
	* ast/rust-path.h: remove has_generic_args assertion (can be empty because of desugar)
	* ast/rust-type.h (class ImplTraitTypeOneBound): add copy ctor and use unique_ptr
	* hir/rust-ast-lower-type.cc (ASTLoweringType::visit): update to use unique_ptr
	* parse/rust-parse-impl.h (Parser::parse_type): reuse the existing unique_ptr instead
	(Parser::parse_type_no_bounds): likewise
	(Parser::parse_pattern): likewise
	* resolve/rust-ast-resolve-type.cc (ResolveType::visit): its a unique_ptr now
	* rust-session-manager.cc (Session::compile_crate): call desugar
	* ast/rust-desugar-apit.cc: New file.
	* ast/rust-desugar-apit.h: New file.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-2015.rs: fully supported now
	* rust/compile/nr2/exclude: nr2 cant handle some of these
	* rust/compile/issue-1487.rs: New test.
	* rust/compile/issue-3454.rs: New test.
	* rust/execute/torture/impl_desugar-2.rs: New test.
	* rust/execute/torture/impl_desugar.rs: New test.
	* rust/execute/torture/impl_trait1.rs: New test.
	* rust/execute/torture/impl_trait2.rs: New test.
	* rust/execute/torture/impl_trait3.rs: New test.
	* rust/execute/torture/impl_trait4.rs: New test.
	* rust/execute/torture/issue-1482.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-item.cc
	(ResolveItem::visit): Use the return values of
	CanonicalPath::inherent_impl_seg and
	CanonicalPath::trait_impl_projection_seg more directly.
	* util/rust-canonical-path.h
	(CanonicalPath::trait_impl_projection_seg): Append "<impl "
	instead of "<" to the beginning of the returned path segment.
	(CanonicalPath::inherent_impl_seg): Likewise.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* backend/rust-compile-pattern.cc
	(CompilePatternCheckExpr::visit): Fix GENERIC generation in
	light of enum layout changes since this code was written.
	(CompilePatternBindings::handle_struct_pattern_ident_pat):
	Delegate handling of child patterns to another
	CompilePatternBindings::Compile call.
	(CompilePatternBindings::make_struct_access): Make field name
	parameter const qualified.
	* backend/rust-compile-pattern.h
	(CompilePatternBindings::make_struct_access): Likewise.

gcc/testsuite/ChangeLog:

	* rust/execute/torture/struct-pattern-match.rs: New test.

Signed-off-by: Owen Avery <[email protected]>
gcc/rust/ChangeLog:

	* ast/rust-ast-visitor.cc
	(DefaultASTVisitor::visit): Make call to EnumItem visitor from
	EnumItem derived class visitors non-virtual.
	* ast/rust-collect-lang-items.cc
	(CollectLangItems::visit): Handle visitation of classes derived
	from EnumItem.
	* ast/rust-collect-lang-items.h
	(CollectLangItems::visit): Likewise.
	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::visit): Call DefaultResolver::visit on EnumItem
	instances.

Signed-off-by: Owen Avery <[email protected]>
…osition

When using impl traits in argument position (APIT), they are desugared into generics,
and supplying explicit generic arguments is not allowed. This commit adds the error
diagnostic E0632 for attempting to pass generic arguments to impl traits, completing
the implementation of the APIT feature.

gcc/rust/ChangeLog:

	* ast/rust-desugar-apit.cc: track if this is a impl-trait generic
	* ast/rust-item.h (class TypeParam): add field to track if from impl trait
	* hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): likewise
	* hir/tree/rust-hir-item.cc (TypeParam::TypeParam): upate hir as well
	(TypeParam::operator=): likewise
	* hir/tree/rust-hir-item.h (class TypeParam): likewise
	* typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::get_generic_param): add error
	* typecheck/rust-tyty-subst.h: add const getter for the associated TypeParm

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/impl_trait_generic_arg.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
Empty loops have no body which means this is a NULL_TREE during const
evaluation which needs a check. Fixes Rust-GCC #3618.

gcc/rust/ChangeLog:

	* backend/rust-constexpr.cc (eval_constant_expression):  Check if t is a NULL_TREE

gcc/testsuite/ChangeLog:

	* rust/compile/issue-3618.rs: Test empty loops error properly.

Signed-off-by: Tom Schollenberger <[email protected]>
gcc/rust/ChangeLog:

	* ast/rust-ast-collector.cc (TokenCollector::visit): Implement for InlineAsm.
	* ast/rust-ast-full-decls.h (enum class): Move InlineAsmOption enum inside InlineAsm.
	* ast/rust-expr.h (enum class): Likewise.
	(class InlineAsm): Likewise.
	* expand/rust-macro-builtins-asm.cc (check_and_set): Likewise.
	(parse_options): Likewise.
	* expand/rust-macro-builtins-asm.h (check_and_set): Likewise.
	* hir/tree/rust-hir-expr.cc (InlineAsm::InlineAsm): Likewise.
	* hir/tree/rust-hir-expr.h: Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
gcc/rust/ChangeLog:

	* ast/rust-path.cc
	(TypePath::make_debug_string): Add definition.
	* ast/rust-path.h
	(TypePath::make_debug_string): Add declaration.
	* resolve/rust-default-resolver.cc
	(DefaultResolver::visit): Adjust InherentImpl and TraitImpl
	visitors to better handle associated item scope.
	* resolve/rust-default-resolver.h
	(DefaultResolver::maybe_insert_big_self): Add.
	* resolve/rust-late-name-resolver-2.0.cc
	(Late::visit): Adjust type path resolution errors.
	* resolve/rust-rib.h
	(Rib::Kind): Add Generics kind.
	* resolve/rust-toplevel-name-resolver-2.0.cc
	(TopLevel::visit): Remove InherentImpl and TraitImpl visitor
	overrides.
	(TopLevel::maybe_insert_big_self): Add override in order to add
	a definition of 'Self'.
	* resolve/rust-toplevel-name-resolver-2.0.h
	(TopLevel::visit): Remove InherentImpl and TraitImpl visitor
	overrides.
	(TopLevel::maybe_insert_big_self): Add override.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
Since r14-6076, the LANG_HOOKS_COMMON_ATTRIBUTE_TABLE should not be used and
LANG_HOOKS_ATTRIBUTE_TABLE replaces it.

Add the "cold" attribute to fix PR120018 (and the matching "hot" attribute).

Replace some gcc_assert() by explicit warnings (same as D frontend).

Add some clang-format off/on comment around code that's not correctly
formatted.

gcc/rust/ChangeLog:
	PR rust/120018

	* rust-attribs.cc (handle_noreturn_attribute): Reindent declaration.
	(handle_leaf_attribute): Likewise.
	(handle_const_attribute): Likewise.
	(handle_malloc_attribute): Likewise.
	(handle_pure_attribute): Likewise.
	(handle_novops_attribute): Likewise.
	(handle_nonnull_attribute): Likewise.
	(handle_nothrow_attribute): Likewise.
	(handle_type_generic_attribute): Likewise.
	(handle_transaction_pure_attribute): Likewise.
	(handle_returns_twice_attribute): Likewise.
	(handle_fnspec_attribute): Likewise.
	(handle_omp_declare_simd_attribute): Likewise.
	(handle_cold_attribute): New.
	(handle_hot_attribute): New.
	(attribute_spec::exclusions attr_cold_hot_exclusions): New.
	(grs_langhook_common_attributes): Make it static.
	(grs_langhook_common_attribute_table): New.
	(grs_langhook_gnu_attributes): New.
	(grs_langhook_gnu_attribute_table): New.
	(handle_malloc_attribute): Make it static.
	(handle_fnspec_attribute): Likewise.
	(handle_pure_attribute): Replace gcc_assert by explicit warning.
	(handle_novops_attribute): Likewise.
	(handle_nothrow_attribute): Likewise.
	(handle_returns_twice_attribute): Likewise.
	(handle_omp_declare_simd_attribute): Likewise and make it static.
	* rust-lang.cc (grs_langhook_gnu_attribute_table): New.
	(grs_langhook_common_attribute_table): Adjust type to new hook.
	(LANG_HOOKS_COMMON_ATTRIBUTE_TABLE): Remove.
	(LANG_HOOKS_ATTRIBUTE_TABLE): New.

Signed-off-by: Marc Poulhiès <[email protected]>
Bump clang-format version to 16. This is needed as upstream has updated
the config and clang-format 10 doesn't support it.

gcc/rust/ChangeLog:
    * .github/workflows/clang-format.yml: Bump clang-format version.
It changes declaration and switch case indentation to follow GNU coding
style.

gcc/rust/ChangeLog:

	* ast/rust-ast-builder-type.cc (ASTTypeBuilder::visit): Reindent.
	* ast/rust-ast-builder.cc (Builder::new_generic_args): Likewise.
	* ast/rust-ast-collector.cc (TokenCollector::visit): Likewise.
	* ast/rust-ast-dump.h (debug): Likewise.
	* ast/rust-ast-formatting.h (indent_spaces): Likewise.
	(get_string_in_delims): Likewise.
	(get_mode_dump_desc): Likewise.
	(append_attributes): Likewise.
	(unquote_string): Likewise.
	* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise.
	* ast/rust-ast.cc (Attribute::get_traits_to_derive): Likewise.
	(UseTreeGlob::as_string): Likewise.
	(UseTreeList::as_string): Likewise.
	(AttributeParser::parse_path_meta_item): Likewise.
	(FormatArgs::set_outer_attrs): Likewise.
	* ast/rust-ast.h (operator<<): Likewise.
	* ast/rust-cond-compilation.h: Likewise.
	* ast/rust-desugar-apit.cc: Likewise.
	* ast/rust-fmt.h (collect_pieces): Likewise.
	(clone_pieces): Likewise.
	* ast/rust-macro.cc: Likewise.
	* ast/rust-pattern.h (tokenid_to_rangekind): Likewise.
	* backend/rust-compile-context.cc (Context::type_hasher): Likewise.
	* backend/rust-compile-expr.cc (CompileExpr::visit): Likewise.
	* backend/rust-compile-intrinsic.cc (get_identifier): Likewise.
	(offset_handler): Likewise.
	(sizeof_handler): Likewise.
	(transmute_handler): Likewise.
	(rotate_handler): Likewise.
	(wrapping_op_handler_inner): Likewise.
	(op_with_overflow_inner): Likewise.
	(uninit_handler): Likewise.
	(move_val_init_handler): Likewise.
	(assume_handler): Likewise.
	(discriminant_value_handler): Likewise.
	(variant_count_handler): Likewise.
	(prefetch_data_handler): Likewise.
	(atomic_store_handler_inner): Likewise.
	(atomic_load_handler_inner): Likewise.
	(unchecked_op_inner): Likewise.
	(copy_handler_inner): Likewise.
	(expect_handler_inner): Likewise.
	(try_handler_inner): Likewise.
	* backend/rust-compile-pattern.cc (compile_range_pattern_bound): Likewise.
	(CompilePatternCheckExpr::visit): Likewise.
	(CompilePatternBindings::visit): Likewise.
	(CompilePatternLet::visit): Likewise.
	* backend/rust-compile-var-decl.h: Likewise.
	* backend/rust-constexpr.cc (verify_constant): Likewise.
	(find_array_ctor_elt): Likewise.
	(array_index_cmp): Likewise.
	(potential_constant_expression_1): Likewise.
	(unshare_constructor): Likewise.
	(maybe_save_constexpr_fundef): Likewise.
	(returns): Likewise.
	(breaks): Likewise.
	(continues): Likewise.
	(switches): Likewise.
	(constant_value_1): Likewise.
	(decl_constant_value): Likewise.
	(non_const_var_error): Likewise.
	(eval_constant_expression): Likewise.
	(constexpr_fn_retval): Likewise.
	(eval_store_expression): Likewise.
	(eval_call_expression): Likewise.
	(eval_binary_expression): Likewise.
	(get_function_named_in_call): Likewise.
	(eval_statement_list): Likewise.
	(extract_string_elt): Likewise.
	(eval_conditional_expression): Likewise.
	(eval_bit_field_ref): Likewise.
	(eval_loop_expr): Likewise.
	(eval_switch_expr): Likewise.
	(eval_unary_expression): Likewise.
	(get_or_insert_ctor_field): Likewise.
	(eval_and_check_array_index): Likewise.
	* backend/rust-constexpr.h (maybe_save_constexpr_fundef): Likewise.
	* backend/rust-mangle-v0.cc (v0_path): Likewise.
	(v0_complex_type_prefix): Likewise.
	* backend/rust-mangle.h (legacy_mangle_item): Likewise.
	(v0_mangle_item): Likewise.
	* backend/rust-tree.cc (convert_to_void): Likewise.
	(find_parameter_packs_r): Likewise.
	(rs_tree_equal): Likewise.
	(publicly_uniquely_derived_p): Likewise.
	(instantiation_dependent_expression_p): Likewise.
	(type_has_nontrivial_copy_init): Likewise.
	(is_normal_capture_proxy): Likewise.
	(is_bitfield_expr_with_lowered_type): Likewise.
	(undeduced_auto_decl): Likewise.
	(require_deduced_type): Likewise.
	(gt_pch_nx): Likewise.
	(lvalue_kind): Likewise.
	* backend/rust-tree.h (LANG_DECL_MIN_CHECK): Likewise.
	(LANG_DECL_FN_CHECK): Likewise.
	(LANG_DECL_NS_CHECK): Likewise.
	(LANG_DECL_PARM_CHECK): Likewise.
	(LANG_DECL_DECOMP_CHECK): Likewise.
	(resort_type_member_vec): Likewise.
	(convert_to_void): Likewise.
	(mark_discarded_use): Likewise.
	(mark_exp_read): Likewise.
	(mark_use): Likewise.
	(mark_rvalue_use): Likewise.
	(mark_lvalue_use): Likewise.
	(mark_lvalue_use_nonread): Likewise.
	(convert_from_reference): Likewise.
	(maybe_warn_nodiscard): Likewise.
	(expr_loc_or_loc): Likewise.
	(expr_loc_or_input_loc): Likewise.
	(get_fndecl_from_callee): Likewise.
	(pointer_offset_expression): Likewise.
	(is_empty_class): Likewise.
	(is_really_empty_class): Likewise.
	(rs_type_quals): Likewise.
	(init_modules): Likewise.
	(lookup_add): Likewise.
	(ovl_make): Likewise.
	(struct c_fileinfo): Likewise.
	(get_fileinfo): Likewise.
	(cxx_make_type): Likewise.
	(build_cplus_array_type): Likewise.
	(comptypes): Likewise.
	(rs_build_qualified_type_real): Likewise.
	(vector_targets_convertible_p): Likewise.
	(get_class_binding_direct): Likewise.
	(lang_check_failed): Likewise.
	(check_for_uninitialized_const_var): Likewise.
	(cp_fold_maybe_rvalue): Likewise.
	(fold_offsetof): Likewise.
	(fold_non_dependent_expr): Likewise.
	(in_immediate_context): Likewise.
	(cxx_mark_addressable): Likewise.
	(decl_constant_value): Likewise.
	(is_class_type): Likewise.
	(fold_builtin_is_pointer_inverconvertible_with_class): Likewise.
	(c_common_type_for_mode): Likewise.
	(next_common_initial_seqence): Likewise.
	(fold_builtin_is_corresponding_member): Likewise.
	(maybe_constant_value): Likewise.
	(rs_walk_subtrees): Likewise.
	(make_tree_vector): Likewise.
	(release_tree_vector): Likewise.
	(location_of): Likewise.
	(maybe_constant_init): Likewise.
	(explain_invalid_constexpr_fn): Likewise.
	(literal_type_p): Likewise.
	(maybe_constexpr_fn): Likewise.
	(fold_non_dependent_init): Likewise.
	* checks/errors/borrowck/polonius/rust-polonius.h (polonius_run): Likewise.
	(FFIVector__new): Likewise.
	(FFIVector__new_vec_pair): Likewise.
	(FFIVector__new_vec_triple): Likewise.
	(FFIVector__push): Likewise.
	(FFIVector__push_vec_triple): Likewise.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise.
	* checks/errors/borrowck/rust-bir-builder-pattern.cc (PatternBindingBuilder::visit): Likewise.
	* checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): Likewise.
	* checks/errors/borrowck/rust-bir-fact-collector.h (points): Likewise.
	* checks/errors/borrowck/rust-bir-place.h: Likewise.
	* checks/errors/borrowck/rust-bir-visitor.h: Likewise.
	* checks/errors/privacy/rust-privacy-check.cc (saw_errors): Likewise.
	* checks/errors/privacy/rust-privacy-ctx.h (rust_privacy_ctx_test): Likewise.
	* checks/errors/privacy/rust-privacy-reporter.cc
	* Likewise. (PrivacyReporter::check_for_privacy_violation): Likewise.
	(PrivacyReporter::check_base_type_privacy): Likewise.
	(PrivacyReporter::visit): Likewise.
	* checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise.
	* checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_visibility): Likewise.
	* checks/errors/rust-hir-pattern-analysis.cc (Constructor::is_covered_by): Likewise.
	(PlaceInfo::specialize): Likewise.
	(WitnessPat::to_string): Likewise.
	(WitnessMatrix::apply_constructor): Likewise.
	(lower_pattern): Likewise.
	(lower_tuple_pattern): Likewise.
	(lower_struct_pattern): Likewise.
	* checks/errors/rust-hir-pattern-analysis.h (check_match_usefulness): Likewise.
	* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_generic_args): Likewise.
	* expand/rust-derive-eq.cc (DeriveEq::visit_enum): Likewise.
	* expand/rust-derive.cc: Likewise.
	* expand/rust-expand-format-args.cc (expand_format_args): Likewise.
	* expand/rust-expand-visitor.h (is_derive): Likewise.
	(is_builtin): Likewise.
	* expand/rust-macro-builtins-asm.cc (expand_inline_asm_strings): Likewise.
	* expand/rust-macro-builtins-asm.h (parse_asm): Likewise.
	(check_identifier): Likewise.
	(check_and_set): Likewise.
	(parse_label): Likewise.
	(parse_llvm_outputs): Likewise.
	(parse_llvm_inputs): Likewise.
	(parse_llvm_clobbers): Likewise.
	(parse_llvm_options): Likewise.
	* expand/rust-macro-builtins-helpers.h (make_macro_path_str): Likewise.
	(make_token): Likewise.
	(make_string): Likewise.
	(macro_end_token): Likewise.
	(parse_single_string_literal): Likewise.
	(source_relative_path): Likewise.
	(load_file_bytes): Likewise.
	* expand/rust-macro-expand.cc (MacroExpander::match_fragment): Likewise.
	(MacroExpander::match_matcher): Likewise.
	(MacroExpander::match_n_matches): Likewise.
	* expand/rust-macro-substitute-ctx.cc (SubstituteCtx::substitute_token): Likewise.
	* expand/rust-proc-macro.h (load_macros): Likewise.
	(generate_proc_macro_decls_symbol): Likewise.
	* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_generic_args): Likewise.
	(ASTLoweringBase::lower_range_pattern_bound): Likewise.
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise.
	* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise.
	* hir/rust-ast-lower.h (struct_field_name_exists): Likewise.
	(translate_visibility): Likewise.
	* hir/rust-hir-dump.cc (Dump::visit): Likewise.
	* hir/rust-hir-dump.h (debug): Likewise.
	* hir/tree/rust-hir.cc (UseTreeGlob::as_string): Likewise.
	(UseTreeList::as_string): Likewise.
	* lex/rust-lex.cc (Lexer::parse_escape): Likewise.
	(Lexer::parse_utf8_escape): Likewise.
	* lex/rust-lex.h (rust_input_source_test): Likewise.
	* lex/rust-token.cc (RS_TOKEN_KEYWORD_2015): Likewise.
	* lex/rust-token.h (get_token_description): Likewise.
	(token_id_to_str): Likewise.
	(token_id_is_keyword): Likewise.
	(token_id_keyword_string): Likewise.
	(get_type_hint_string): Likewise.
	(nfc_normalize_token_string): Likewise.
	* metadata/rust-export-metadata.cc (PublicInterface::write_to_path): Likewise.
	* metadata/rust-import-archive.cc: Likewise.
	* metadata/rust-imports.h (add_search_path): Likewise.
	* parse/rust-cfg-parser.h (parse_cfg_option): Likewise.
	(rust_cfg_parser_test): Likewise.
	* parse/rust-parse-impl.h (Parser::skip_generics_right_angle): Likewise.
	(Parser::parse_attr_input): Likewise.
	(Parser::parse_macro_match): Likewise.
	(Parser::parse_visibility): Likewise.
	(Parser::parse_module): Likewise.
	(Parser::parse_use_tree): Likewise.
	(Parser::parse_generic_param): Likewise.
	(Parser::parse_struct): Likewise.
	(Parser::parse_enum_item): Likewise.
	(Parser::parse_inherent_impl_item): Likewise.
	(Parser::parse_external_item): Likewise.
	(Parser::parse_generic_arg): Likewise.
	(Parser::parse_type_path_segment): Likewise.
	(Parser::parse_expr_stmt): Likewise.
	(Parser::parse_if_expr): Likewise.
	(Parser::parse_if_let_expr): Likewise.
	(Parser::parse_type): Likewise.
	(Parser::parse_for_prefixed_type): Likewise.
	(Parser::parse_slice_or_array_type): Likewise.
	(Parser::parse_type_no_bounds): Likewise.
	(Parser::parse_range_pattern_bound): Likewise.
	(Parser::parse_pattern_no_alt): Likewise.
	(Parser::parse_grouped_or_tuple_pattern): Likewise.
	(Parser::parse_ident_leading_pattern): Likewise.
	(Parser::parse_tuple_struct_items): Likewise.
	(Parser::parse_stmt_or_expr): Likewise.
	(Parser::parse_struct_expr_field): Likewise.
	(Parser::null_denotation): Likewise.
	(Parser::left_denotation): Likewise.
	(Parser::parse_closure_expr_pratt): Likewise.
	* parse/rust-parse.cc (peculiar_fragment_match_compatible): Likewise.
	(is_match_compatible): Likewise.
	* parse/rust-parse.h (extract_module_path): Likewise.
	(is_match_compatible): Likewise.
	* resolve/rust-ast-resolve-expr.cc (translate_operand): Likewise.
	* resolve/rust-ast-resolve-item.cc (flatten_glob): Likewise.
	(flatten_rebind): Likewise.
	(flatten_list): Likewise.
	(flatten): Likewise.
	* resolve/rust-ast-resolve-item.h (rust_simple_path_resolve_test): Likewise.
	* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::visit): Likewise.
	(resolve_range_pattern_bound): Likewise.
	* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Likewise.
	(ResolveTypeToCanonicalPath::visit): Likewise.
	* resolve/rust-ast-resolve.cc (saw_errors): Likewise.
	* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import): Likewise.
	* resolve/rust-ice-finalizer.h (funny_ice_text_finalizer): Likewise.
	* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
	* resolve/rust-toplevel-name-resolver-2.0.cc (flatten_glob): Likewise.
	* rust-backend.h (init): Likewise.
	(debug): Likewise.
	(get_identifier_node): Likewise.
	(wchar_type): Likewise.
	(get_pointer_size): Likewise.
	(raw_str_type): Likewise.
	(integer_type): Likewise.
	(float_type): Likewise.
	(pointer_type): Likewise.
	(reference_type): Likewise.
	(immutable_type): Likewise.
	(function_type): Likewise.
	(function_type_variadic): Likewise.
	(function_ptr_type): Likewise.
	(struct_type): Likewise.
	(union_type): Likewise.
	(array_type): Likewise.
	(named_type): Likewise.
	(type_field_offset): Likewise.
	(var_expression): Likewise.
	(float_constant_expression): Likewise.
	(string_constant_expression): Likewise.
	(char_constant_expression): Likewise.
	(wchar_constant_expression): Likewise.
	(boolean_constant_expression): Likewise.
	(convert_expression): Likewise.
	(struct_field_expression): Likewise.
	(compound_expression): Likewise.
	(conditional_expression): Likewise.
	(negation_expression): Likewise.
	(arithmetic_or_logical_expression): Likewise.
	(arithmetic_or_logical_expression_checked): Likewise.
	(comparison_expression): Likewise.
	(lazy_boolean_expression): Likewise.
	(constructor_expression): Likewise.
	(array_constructor_expression): Likewise.
	(array_initializer): Likewise.
	(array_index_expression): Likewise.
	(call_expression): Likewise.
	(init_statement): Likewise.
	(assignment_statement): Likewise.
	(return_statement): Likewise.
	(if_statement): Likewise.
	(loop_expression): Likewise.
	(exit_expression): Likewise.
	(statement_list): Likewise.
	(exception_handler_statement): Likewise.
	(block): Likewise.
	(block_add_statements): Likewise.
	(global_variable): Likewise.
	(global_variable_set_init): Likewise.
	(local_variable): Likewise.
	(parameter_variable): Likewise.
	(static_chain_variable): Likewise.
	(temporary_variable): Likewise.
	(label): Likewise.
	(function): Likewise.
	(function_defer_statement): Likewise.
	(function_set_parameters): Likewise.
	(write_global_definitions): Likewise.
	(fill_in_fields): Likewise.
	* rust-diagnostics.cc (expand_format): Likewise.
	(expand_message): Likewise.
	(va_constructor): Likewise.
	* rust-diagnostics.h (RUST_ATTRIBUTE_GCC_DIAG): Likewise.
	(rust_open_quote): Likewise.
	(rust_close_quote): Likewise.
	(rust_debug_loc): Likewise.
	* rust-gcc.cc (non_zero_size_type): Likewise.
	* rust-object-export.h (rust_field_alignment): Likewise.
	(rust_read_export_data): Likewise.
	(rust_write_export_data): Likewise.
	* rust-session-manager.cc (saw_errors): Likewise.
	(rust_get_linemap): Likewise.
	(validate_crate_name): Likewise.
	(Session::load_extern_crate): Likewise.
	* rust-session-manager.h (rust_crate_name_validation_test): Likewise.
	* rust-system.h (rust_preserve_from_gc): Likewise.
	(rust_localize_identifier): Likewise.
	* rust-target.h (rust_add_target_info): Likewise.
	* typecheck/rust-autoderef.cc:
	* typecheck/rust-casts.cc (TypeCastRules::cast_rules): Likewise.
	* typecheck/rust-coercion.cc (TypeCoercionRules::do_coercion): Likewise.
	(TypeCoercionRules::coerce_unsafe_ptr): Likewise.
	(TypeCoercionRules::coerce_borrowed_pointer): Likewise.
	* typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): Likewise.
	(TraitItemReference::is_object_safe): Likewise.
	* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise.
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
	(typecheck_inline_asm_operand): Likewise.
	* typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise.
	(TypeCheckImplItemWithTrait::visit): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise.
	* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::visit): Likewise.
	* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::apply_trait_bounds): Likewise.
	(ResolveWhereClauseItem::visit): Likewise.
	* typecheck/rust-hir-type-check.cc (saw_errors): Likewise.
	(TraitItemReference::get_type_from_fn): Likewise.
	* typecheck/rust-type-util.h (query_type): Likewise.
	(types_compatable): Likewise.
	(unify_site): Likewise.
	(unify_site_and): Likewise.
	(coercion_site): Likewise.
	(try_coercion): Likewise.
	(cast_site): Likewise.
	* typecheck/rust-tyty-bounds.cc:
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Likewise.
	* typecheck/rust-tyty-cmp.h:
	* typecheck/rust-tyty-variance-analysis.h (query_field_regions): Likewise.
	* typecheck/rust-tyty.cc (BaseType::is_unit): Likewise.
	(BaseType::has_substitutions_defined): Likewise.
	(BaseType::needs_generic_substitutions): Likewise.
	(BaseType::get_subst_argument_mappings): Likewise.
	(InferType::default_type): Likewise.
	(InferType::apply_primitive_type_hint): Likewise.
	* typecheck/rust-tyty.h (is_primitive_type_kind): Likewise.
	* typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): Likewise.
	(UnifyRules::expect_adt): Likewise.
	(UnifyRules::expect_str): Likewise.
	(UnifyRules::expect_reference): Likewise.
	(UnifyRules::expect_pointer): Likewise.
	(UnifyRules::expect_param): Likewise.
	(UnifyRules::expect_array): Likewise.
	(UnifyRules::expect_slice): Likewise.
	(UnifyRules::expect_fndef): Likewise.
	(UnifyRules::expect_fnptr): Likewise.
	(UnifyRules::expect_tuple): Likewise.
	(UnifyRules::expect_bool): Likewise.
	(UnifyRules::expect_char): Likewise.
	(UnifyRules::expect_int): Likewise.
	(UnifyRules::expect_uint): Likewise.
	(UnifyRules::expect_float): Likewise.
	(UnifyRules::expect_isize): Likewise.
	(UnifyRules::expect_usize): Likewise.
	(UnifyRules::expect_never): Likewise.
	(UnifyRules::expect_placeholder): Likewise.
	(UnifyRules::expect_projection): Likewise.
	(UnifyRules::expect_dyn): Likewise.
	(UnifyRules::expect_closure): Likewise.
	(UnifyRules::expect_opaque): Likewise.
	* util/rust-abi.h (get_abi_from_string): Likewise.
	(get_string_from_abi): Likewise.
	* util/rust-attributes.cc (check_doc_attribute): Likewise.
	* util/rust-base62.h (base62_integer): Likewise.
	* util/rust-dir-owner.h (get_file_subdir): Likewise.
	* util/rust-edition.h (get_rust_edition): Likewise.
	* util/rust-punycode.h (encode_punycode): Likewise.
	(rust_punycode_encode_test): Likewise.
	* util/rust-token-converter.cc (convert): Likewise.
	(from_tokenstream): Likewise.
	* util/rust-token-converter.h (convert): Likewise.
	(convert_literal): Likewise.
	* util/rust-unicode.h (is_alphabetic): Likewise.
	(is_ascii_only): Likewise.
	(is_numeric): Likewise.
	(is_nfc_qc_no): Likewise.
	(is_nfc_qc_maybe): Likewise.
	(nfc_quick_check): Likewise.
	(rust_nfc_qc_test): Likewise.
	(rust_utf8_normalize_test): Likewise.
	(rust_utf8_property_test): Likewise.
	* util/rust-unwrap-segment.h (unwrap_segment_node_id): Likewise.

libgrust/ChangeLog:

	* libproc_macro_internal/ffistring.h (FFIString__new): Likewise.
	(FFIString__drop): Likewise.
	* libproc_macro_internal/ident.h (Ident__new): Likewise.
	(Ident__new_raw): Likewise.
	(Ident__drop): Likewise.
	(Ident__clone): Likewise.
	* libproc_macro_internal/literal.h (Literal__from_string): Likewise.
	* libproc_macro_internal/proc_macro.h (bridge_is_available): Likewise.
	* libproc_macro_internal/tokenstream.h (TokenStream__new): Likewise.
	(TokenStream__with_capacity): Likewise.
	(TokenSream__push): Likewise.
	(TokenStream__from_string): Likewise.
	(TokenStream__clone): Likewise.
	(TokenStream__drop): Likewise.
@dkm dkm force-pushed the dkm/master-rebased branch from ad76a74 to 7808bcd Compare May 12, 2025 20:42
@powerboat9
Copy link
Collaborator

What should the .gitignore look like? Should we have every entry from both upstream and downstream, modify our downstream to match upstream exactly, keep only some entries from upstream and downstream, or something else?

@powerboat9
Copy link
Collaborator

It looks like the formatting for ast/rust-macro.cc is a bit odd, probably since it doesn't contain any function definitions. Should we just remove the file?

@powerboat9
Copy link
Collaborator

Are some of the clang-format-off sections added to rust-attribs.cc still relevant, with the clang-format upgrade?

@powerboat9
Copy link
Collaborator

powerboat9 commented May 13, 2025

Also, it looks like there are some non-trivial changes to the headers included by rust-lang.cc. Idk if the changes are good/bad though, would require further investigation.

@dkm
Copy link
Member Author

dkm commented May 13, 2025

It looks like the formatting for ast/rust-macro.cc is a bit odd, probably since it doesn't contain any function definitions. Should we just remove the file?

I guess we could yes, good catch.

Also, it looks like there are some non-trivial changes to the headers included by rust-lang.cc. Idk if the changes are good/bad though, would require further investigation.

Erm, you've already mentioned that on the Zulip, here's my copy of the answer for completeness :)

[snip snip 8<---8<----]

.... I think it has not been discarded, but more squashed with other changes with the initial upstreaming, and we may have introduced this small change in the process:

diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc
index df06026387c..f3a155dbad1 100644
--- a/gcc/rust/rust-lang.cc
+++ b/gcc/rust/rust-lang.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2024 Free Software Foundation, Inc.
+// Copyright (C) 2020-2025 Free Software Foundation, Inc.
 
 // This file is part of GCC.
 
@@ -16,9 +16,8 @@
 // along with GCC; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+#include "rust-system.h"
 #include "rust-diagnostics.h"
-#include "config.h"
-#include "system.h"
 #include "coretypes.h"
 #include "target.h"
 #include "tree.h"
@@ -32,7 +31,6 @@
 #include "convert.h"
 #include "langhooks.h"
 #include "langhooks-def.h"
-
 #include "selftest.h"
 #include "rust-cfg-parser.h"
 #include "rust-privacy-ctx.h"
@@ -66,7 +64,6 @@
  * e.g. HIR conversion.
  */
 
-#include "rust-system.h"
 #include "rust-session-manager.h"
 #include "rust-tree.h"

I think it's OK.

@dkm
Copy link
Member Author

dkm commented May 13, 2025

What should the .gitignore look like? Should we have every entry from both upstream and downstream, modify our downstream to match upstream exactly, keep only some entries from upstream and downstream, or something else?

I think it's not very important, as long as we add stuff at the end. The vscode part could be dropped as it has been added upstream.

@dkm
Copy link
Member Author

dkm commented May 13, 2025

The gitignore change looks like:

 # ADDITIONS from GCCRS front-end
-.vscode/*
-test.code-workspace
-
-gcc/rust/test3-tiny/*
-.clang-format.swap

vscode has been moved up (upstream change).
The others entries are very old and probably not relevant anymore. So now we only have:

# ADDITIONS from GCCRS front-end
libgrust/*/target/

which can probably be removed as I don't think we are building rust crate in the source tree anymore (cc @P-E-P ?)

dkm added 2 commits May 13, 2025 21:44
Config has been updated upstream to correctly indent declaration.

gcc/rust/ChangeLog:

	* rust-attribs.cc (handle_hot_attribute): Remove clang-format comment.

Signed-off-by: Marc Poulhiès <[email protected]>
…rebased

This branch has a no-op merge as the last commit:

- one arm is the current development branch from github

- the other arm is a rebased version of the "current" master branch onto a recent GCC's master

The merge is obtained with "git merge --strategy=ours" to only keep the changes from second arm.
@dkm dkm force-pushed the dkm/master-rebased branch from 7808bcd to 28d5521 Compare May 13, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.