aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2025-04-01gimple-low: Diagnose assume attr expressions defining labels which are used ↵Jakub Jelinek4-2/+112
as unary && operands outside of those [PR119537] The following testcases ICE on invalid code which defines labels inside of statement expressions and then uses &&label from code outside of the statement expressions. The C++ FE diagnoses that with a warning (not specifically for assume attribute, genericallly about taking address of a label outside of a statement expression so computed goto could violate the requirement that statement expression is not entered from outside of it through a jump into it), the C FE doesn't diagnose anything. Normal direct gotos to such labels are diagnosed by both C and C++. In the assume attribute case it is actually worse than for addresses of labels in normal statement expressions, in that case the labels are still in the current function, so invalid program can still jump to those (and in case of OpenMP/OpenACC where it is also invalid and stuff is moved to a separate function, such movement is done post cfg discovery of FORCED_LABELs and worst case one can run into cases which fail to assemble, but I haven't succeeded in creating ICE for that). For assume at -O0 we'd just throw away the assume expression if it is not a simple condition and so the label is then not defined anywhere and we ICE during cfg pass. The gimplify.cc hunks fix that, as we don't have FORCED_LABELs discovery done yet, it preserves all assume expressions which contain used user labels. With that we ICE during IRA, which is upset about an indirect jump to a label which doesn't exist. So, the gimple-low.cc hunks add diagnostics of the problem, it gathers uids of all the user used labels inside of the assume expressions (usually none) and if it finds any, walks the IL to find uses of those from outside of those expressions now outlined into separate magic functions. 2025-04-01 Jakub Jelinek <jakub@redhat.com> PR middle-end/119537 * gimplify.cc (find_used_user_labels): New function. (gimplify_call_expr): Don't remove complex assume expression at -O0 if it defines any user labels. * gimple-low.cc: Include diagnostic-core.h. (assume_labels): New variable. (diagnose_assume_labels): New function. (lower_function_body): Call it via walk_gimple_seq if assume_labels is non-NULL, then BITMAP_FREE assume_labels. (find_assumption_locals_r): Record in assume_labels uids of user labels defined in assume attribute expressions. * c-c++-common/pr119537-1.c: New test. * c-c++-common/pr119537-2.c: New test.
2025-04-01GCN: Don't emit weak undefined symbols [PR119369]Thomas Schwinge15-0/+32
This resolves all instances of PR119369 "GCN: weak undefined symbols -> execution test FAIL, 'HSA_STATUS_ERROR_VARIABLE_UNDEFINED'"; for all affected test cases, the execution test status progresses FAIL -> PASS. This however also causes a small number of (expected) regressions, very similar to GCC/nvptx: [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C -std=c++17 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C -std=c++26 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/abi/pure-virtual1.C -std=c++98 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++11 scan-assembler .weak[ \t]*_?_ZTH11derived_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++11 scan-assembler .weak[ \t]*_?_ZTH13container_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++11 scan-assembler .weak[ \t]*_?_ZTH8base_obj PASS: g++.dg/cpp0x/pr84497.C -std=c++11 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++17 scan-assembler .weak[ \t]*_?_ZTH11derived_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++17 scan-assembler .weak[ \t]*_?_ZTH13container_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++17 scan-assembler .weak[ \t]*_?_ZTH8base_obj PASS: g++.dg/cpp0x/pr84497.C -std=c++17 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++26 scan-assembler .weak[ \t]*_?_ZTH11derived_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++26 scan-assembler .weak[ \t]*_?_ZTH13container_obj [-PASS:-]{+FAIL:+} g++.dg/cpp0x/pr84497.C -std=c++26 scan-assembler .weak[ \t]*_?_ZTH8base_obj PASS: g++.dg/cpp0x/pr84497.C -std=c++26 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C -std=gnu++17 scan-assembler weak[^ \t]*[ \t]_?_Z3foov PASS: g++.dg/ext/weak2.C -std=gnu++17 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C -std=gnu++26 scan-assembler weak[^ \t]*[ \t]_?_Z3foov PASS: g++.dg/ext/weak2.C -std=gnu++26 (test for excess errors) [-PASS:-]{+FAIL:+} g++.dg/ext/weak2.C -std=gnu++98 scan-assembler weak[^ \t]*[ \t]_?_Z3foov PASS: g++.dg/ext/weak2.C -std=gnu++98 (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/attr-weakref-1.c (test for excess errors) [-FAIL:-]{+UNRESOLVED:+} gcc.dg/attr-weakref-1.c [-execution test-]{+compilation failed to produce executable+} @@ -131211,25 +131211,25 @@ PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?c PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?d PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?e PASS: gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?g [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-1.c scan-assembler weak[^ \t]*[ \t]_?j PASS: gcc.dg/weak/weak-1.c scan-assembler-not weak[^ \t]*[ \t]_?i PASS: gcc.dg/weak/weak-12.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-12.c scan-assembler weak[^ \t]*[ \t]_?foo PASS: gcc.dg/weak/weak-15.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?a [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?c [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-15.c scan-assembler weak[^ \t]*[ \t]_?d PASS: gcc.dg/weak/weak-15.c scan-assembler-not weak[^ \t]*[ \t]_?b PASS: gcc.dg/weak/weak-16.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_index [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-16.c scan-assembler weak[^ \t]*[ \t]_?kallsyms_token_table PASS: gcc.dg/weak/weak-2.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-2.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e PASS: gcc.dg/weak/weak-2.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d PASS: gcc.dg/weak/weak-3.c (test for warnings, line 58) PASS: gcc.dg/weak/weak-3.c (test for warnings, line 73) PASS: gcc.dg/weak/weak-3.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1a [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1b [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1c [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1e PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1f PASS: gcc.dg/weak/weak-3.c scan-assembler weak[^ \t]*[ \t]_?ffoo1g PASS: gcc.dg/weak/weak-3.c scan-assembler-not weak[^ \t]*[ \t]_?ffoo1d PASS: gcc.dg/weak/weak-4.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f @@ -131267,16 +131267,16 @@ PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j PASS: gcc.dg/weak/weak-4.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k PASS: gcc.dg/weak/weak-5.c (test for excess errors) [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1a [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1b [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1c PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1d PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1e PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1f PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1g PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1h [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1i [-PASS:-]{+FAIL:+} gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1j PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1k PASS: gcc.dg/weak/weak-5.c scan-assembler weak[^ \t]*[ \t]_?vfoo1l These get 'dg-xfail-if'ed or 'dg-skip-if'ed, (mostly) similar to GCC/nvptx. PR target/119369 gcc/ * config/gcn/gcn-protos.h (gcn_asm_weaken_decl): Declare. * config/gcn/gcn.cc (gcn_asm_weaken_decl): New. * config/gcn/gcn-hsa.h (ASM_WEAKEN_DECL): '#define' to this. gcc/testsuite/ * g++.dg/abi/pure-virtual1.C: 'dg-xfail-if' GCN. * g++.dg/cpp0x/pr84497.C: 'dg-skip-if' GCN. * g++.dg/ext/weak2.C: Likewise. * gcc.dg/attr-weakref-1.c: Likewise. * gcc.dg/weak/weak-1.c: Likewise. * gcc.dg/weak/weak-12.c: Likewise. * gcc.dg/weak/weak-15.c: Likewise. * gcc.dg/weak/weak-16.c: Likewise. * gcc.dg/weak/weak-2.c: Likewise. * gcc.dg/weak/weak-3.c: Likewise. * gcc.dg/weak/weak-4.c: Likewise. * gcc.dg/weak/weak-5.c: Likewise.
2025-04-01target/119549 - fixup handling of -mno-sse4 in target attributeRichard Biener3-0/+24
The following fixes ix86_valid_target_attribute_inner_p to properly handle target("no-sse4") via OPT_mno_sse4 rather than as unset OPT_msse4. I've added asserts to ix86_handle_option that RejectNegative is honored for both. PR target/119549 * common/config/i386/i386-common.cc (ix86_handle_option): Assert that both OPT_msse4 and OPT_mno_sse4 are never unset. * config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p): Process negated OPT_msse4 as OPT_mno_sse4. * gcc.target/i386/pr119549.c: New testcase.
2025-04-01OpenMP: Reorder diagnostic in modify_call_for_omp_dispatch [PR119559]Tobias Burnus1-20/+16
gcc/ChangeLog: PR middle-end/119559 * gimplify.cc (modify_call_for_omp_dispatch): Reorder checks to avoid asserts and bogus diagnostic.
2025-04-01RISC-V: testsuite: Fix broken testsuite error of zicbopLiao Shihua4-4/+4
Fix broken testsuite like "ERROR: gcc.target/riscv/cmo-zicbop-2.c -Os : 1: too many arguments for " dg-do 1 compile target { { rv32-*-*}} " gcc/testsuite/ChangeLog: * gcc.target/riscv/cmo-zicbop-1.c: Fix missing { before target . * gcc.target/riscv/cmo-zicbop-2.c: Likewise. * gcc.target/riscv/prefetch-zicbop.c:Likewise. * gcc.target/riscv/prefetch-zihintntl.c:Likewise.
2025-04-01i386: Add attr_isa for vaes patterns to sync with attr gpr16. [pr119473]Hu, Lin12-4/+42
For vaes patterns with jm constraint and gpr16 attr, it requires "isa" attr to distinct avx/avx512 alternatives in ix86_memory_address_reg_class. Also adds missing type and mode attributes for those vaes patterns. gcc/ChangeLog: PR target/119473 * config/i386/sse.md (vaesdec_<mode>): Set attr "isa" as "avx,vaes_avx512vl", "type" as "sselog1", "mode" as "TI". (vaesdeclast_<mode>): Ditto. (vaesenc_<mode>): Ditto. (vaesenclast_<mode>): Ditto. gcc/testsuite/ChangeLog: PR target/119473 * gcc.target/i386/pr119473.c: New test. Co-authored-by: Hongyu Wang <hongyu.wang@intel.com>
2025-04-01RISC-V: Fix wrong LMUL when only implict zve32f.Monk Chiang10-482/+582
According to Section 3.4.2, Vector Register Grouping, in the RISC-V Vector Specification, the rule for LMUL is LMUL >= SEW/ELEN Changes since V2: - Add check on vector-iterators.md - Add one more testcase to check the VLS use correct mode. gcc/ChangeLog: * config/riscv/riscv-v.cc: Add restrict for insert LMUL. * config/riscv/riscv-vector-builtins-types.def: Use RVV_REQUIRE_ELEN_64 to check LMUL number. * config/riscv/riscv-vector-switch.def: Likewise. * config/riscv/vector-iterators.md: Check TARGET_VECTOR_ELEN_64 rather than "TARGET_MIN_VLEN > 32" for all iterator. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/pr111391-2.c: Update test. * gcc.target/riscv/rvv/base/abi-14.c: Update test. * gcc.target/riscv/rvv/base/abi-16.c: Update test. * gcc.target/riscv/rvv/base/abi-18.c: Update test. * gcc.target/riscv/rvv/base/vsetvl_zve32-1.c: New test. * gcc.target/riscv/rvv/base/vsetvl_zve32-2.c: New test. Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
2025-04-01LoongArch: doc: Put the '-mtls-dialect=opt' option description in the ↵Lulu Cheng1-8/+8
correct position. gcc/ChangeLog: * doc/invoke.texi: Corrected the position of '-mtls-dialect=opt' option.
2025-04-01Daily bump.GCC Administrator7-1/+511
2025-03-31Update gcc sv.poJoseph Myers1-423/+278
* sv.po: Update.
2025-03-31gccrs: Fix SEGV when type path resolver fails outrightPhilip Herron2-0/+25
When we resolve paths we resolve to Types first we walk each segment to the last module which has no type but then in the event that the child of a module is not found we have a null root_tyty which needs to be caught and turned into an ErrorType node. Fixes Rust-GCC#3613 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): catch nullptr root_tyty gcc/testsuite/ChangeLog: * rust/compile/issue-3613.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: fix crash in parse repr options and missing delete callPhilip Herron2-2/+24
Fixes Rust-GCC#3606 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): check for null and empty and add missing delete call gcc/testsuite/ChangeLog: * rust/compile/issue-3606.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: fix ice when setting up regionsPhilip Herron2-1/+6
num regions is based on the used arguments of regions which can be less than the substutions requirements. So lets check for that and allow anon regions to be created for them. Fixes Rust-GCC#3605 gcc/rust/ChangeLog: * typecheck/rust-tyty-subst.h: check for min range gcc/testsuite/ChangeLog: * rust/compile/issue-3605.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: FIX ICE for malformed repr attributePhilip Herron2-0/+9
Fixes Rust-GCC#3614 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): check for input gcc/testsuite/ChangeLog: * rust/compile/issue-3614.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: FIX ICE when working with HIR::BareFunctionTypePhilip Herron3-2/+12
Fixes Rust-GCC#3615 gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): check has type * hir/tree/rust-hir-type.cc (BareFunctionType::BareFunctionType): likewise gcc/testsuite/ChangeLog: * rust/compile/issue-3615.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE in array ref constexprPhilip Herron2-4/+19
Since 898d55ad7e2 was fixed to remove the VIEW_CONVERT_EXPR from array expressions we can now turn on the array element access const expr. Fixes Rust-GCC#3563 gcc/rust/ChangeLog: * backend/rust-constexpr.cc (eval_store_expression): turn this back on gcc/testsuite/ChangeLog: * rust/compile/issue-3563.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Add ending newline to rust-macro-builtins-log-debug.ccOwen Avery1-1/+1
gcc/rust/ChangeLog: * expand/rust-macro-builtins-log-debug.cc: Add newline to end of file. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31gccrs: nr2.0: Rename prelude to lang_preludeOwen Avery3-13/+14
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::get_prelude): Rename to... (ForeverStack::get_lang_prelude): ...here. (ForeverStack::prelude): Rename to... (ForeverStack::lang_prelude): ...here. (ForeverStack::ForeverStack): Handle renames. * resolve/rust-forever-stack.hxx (ForeverStack::push_inner): Likewise. (ForeverStack::resolve_segments): Likewise. (ForeverStack::resolve_path): Likewise. (ForeverStack::get_prelude): Rename to... (ForeverStack::get_lang_prelude): ...here and handle renames. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Handle renames. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31gccrs: nr2.0: Fix test macros/mbe/macro43.rsOwen Avery2-5/+11
gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/macro43.rs: Adjust test to pass with name resolution 2.0. * rust/compile/nr2/exclude: Remove macros/mbe/macro43.rs. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31gccrs: Fix ICE during const expr eval on array expressionsPhilip Herron3-1/+11
Array expressions are still getting turned into VIEW_CONVERT_EXPR's becuase TYPE_MAIN_VARIANT is not set so then we might as well reuse the type-hasher to sort this out. Fixes Rust-GCC#3588 gcc/rust/ChangeLog: * backend/rust-compile-context.h: only push named types * backend/rust-compile-type.cc (TyTyResolveCompile::visit): run the type hasher gcc/testsuite/ChangeLog: * rust/compile/issue-3588.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE when compiling path which resolves to trait constantPhilip Herron3-1/+38
Fixes Rust-GCC#3552 gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): check for Expr trait * hir/rust-hir-dump.cc (Dump::visit): expr is optional gcc/testsuite/ChangeLog: * rust/compile/issue-3552.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Add new test to highlight namespace for self importPierre-Emmanuel Patry1-0/+14
gcc/testsuite/ChangeLog: * rust/compile/self_import_namespace.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: Update exclusion listPierre-Emmanuel Patry1-6/+0
gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove now passing tests from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: Resolve module final self segment in use declsPierre-Emmanuel Patry3-8/+42
Lowercase self suffix with path was not resolved properly, this should point to the module right before. gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx: Add a new specialized function to retrieve the last "real" segment depending on the namespace. * resolve/rust-forever-stack.h: Add new function prototype. * resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import): Set declared name according to the selected segment, if there is a self suffix in the use declaration then select the previous segment. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: Give the builtin unit struct an actual locusPhilip Herron5-8/+17
This has been a pet peeve of mine for a while because the gimple never emitted the struct () name properly it was always empty which for record types they always require a real locus or they dont get a proper name. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::unit_expression): pass ctx * backend/rust-compile-base.h: cant be static * backend/rust-compile-intrinsic.cc (try_handler_inner): pass ctx * backend/rust-compile-type.cc (TyTyResolveCompile::get_unit_type): update to grab the first locus (TyTyResolveCompile::visit): pass ctx * backend/rust-compile-type.h: likewise Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE when doing method resolution on trait predicatesPhilip Herron3-2/+31
We need to ensure we are adding methods to the possible candidates. Fixes Rust-GCC#3554 gcc/rust/ChangeLog: * typecheck/rust-hir-dot-operator.cc: gcc/testsuite/ChangeLog: * rust/compile/issue-3554-1.rs: New test. * rust/compile/issue-3554-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE when using super mid way though pathPhilip Herron3-0/+14
Fixes Rust-GCC#3568 gcc/rust/ChangeLog: * resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): check for super mid path gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 puts out a different error multiple times * rust/compile/issue-3568.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE when compiling block expressions in array capacityPhilip Herron5-1/+59
We need to reuse the existing compile_constant_item helper which handles the case if this is a simple expression, fn-call or a block expression. The patch extracts out this helper as a static method so this can be used in more places. Fixes Rust-GCC#3566 gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::address_expression): new helper constexpr * backend/rust-compile-base.h: prototype * backend/rust-compile-type.cc (TyTyResolveCompile::visit): call constexpr helper gcc/testsuite/ChangeLog: * rust/compile/issue-3566-1.rs: New test. * rust/compile/issue-3566-2.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Add check for super traits being implemented by SelfPhilip Herron4-3/+95
We need to recursively check the super traits of the predicate the Self type is trying to implement. Otherwise its cannot implement it. Fixes Rust-GCC#3553 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::resolve_impl_block_substitutions): Track the polarity * typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::validate_type_implements_this): new validator * typecheck/rust-tyty.h: new prototypes gcc/testsuite/ChangeLog: * rust/compile/issue-3553.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix ICE when array elements are not a valuePhilip Herron2-0/+15
We need to check for error_mark_node when doing adjustments from coercion sites otherwise we hit assetions as part of the coercion. That fixes the ICE but the reason for the error_mark_node is because the array element value. Fixes Rust-GCC#3567 gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::array_value_expr): add value chk for array expr gcc/testsuite/ChangeLog: * rust/compile/issue-3567.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix core library test with proper canonical pathPierre-Emmanuel Patry1-4/+4
Import from core library was wrong, it misses several crate directives since we're no longer dealing with multiple files. gcc/testsuite/ChangeLog: * rust/compile/issue-2905-2.rs: Import from core library into a single file misses the crate directives. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: fix unconstrained infer vars on generic associated typePhilip Herron4-11/+9
The trick here is that when Bar::test is resolved it resolves to the trait method: fn <Bar<i32>, T> (placeholder) -> placeholder Which is fine so we need to setup the associated types for Bar<i32> which means looking up the associated impl block then setting up the projection of A = T so it becomes: fn <Bar<i32>, T> (placeholder: projection<T>:T) -> placeholder: projection<T>:T But previously it was auto injecting inference variables so it became: fn <Bar<i32>, T> (placeholder: projection<T>:?T) -> placeholder: projection<T>:?T The issue is that the binding of the generics was still T so this caused inference variables to be injected again but unlinked. A possible tweak would be that we are substituting again with new infer vars to actually just unify them enplace so they are all part of the chain. This still might be needed but lets hold off for now. So basically when we are Path probing we dont allow GAT's to generate new inference vars because they wont be bound to this current segment which just causes confusion. Fixes Rust-GCC#3242 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-reference.h: add default infer arg * typecheck/rust-hir-trait-resolve.cc: dont add new infer vars * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_segments): dont infer gcc/testsuite/ChangeLog: * rust/compile/issue-3242.rs: no longer skip the test Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-03-31gccrs: Fix validation of constant itemsOwen Avery3-1/+9
gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Allow constant items lacking expressions if and only if they're associated with a trait definition, not a trait implementation. gcc/testsuite/ChangeLog: * rust/compile/issue-3541-1.rs: New test. * rust/compile/issue-3541-2.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31gccrs: testsuite: Add more testcases for cfg() in coreArthur Cohen2-0/+24
gcc/testsuite/ChangeLog: * rust/compile/cfg-core1.rs: New test. * rust/compile/cfg-core2.rs: New test.
2025-03-31gccrs: Lower raw string literalsOwen Avery2-2/+5
gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_literal): Lower raw string literals into normal string literals. gcc/testsuite/ChangeLog: * rust/compile/issue-3549.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31rust: Lower minimum supported Rust version to 1.49Arthur Cohen5-156/+9
gcc/rust/ChangeLog: * checks/errors/borrowck/ffi-polonius/Cargo.lock: Regenerate. * checks/errors/borrowck/ffi-polonius/Cargo.toml: Update to use source patching instead of vendoring, lower edition to 2018. * checks/errors/borrowck/ffi-polonius/vendor/log/Cargo.toml: Change edition to 2018. * checks/errors/borrowck/ffi-polonius/vendor/log/src/lib.rs: Remove uses of unstable feature. * checks/errors/borrowck/ffi-polonius/.cargo/config.toml: Removed. libgrust/ChangeLog: * libformat_parser/Makefile.am: Avoid using --config as it is unsupported by cargo 1.49. * libformat_parser/Makefile.in: Regenerate. * libformat_parser/generic_format_parser/src/lib.rs: Use extension trait for missing features. * libformat_parser/src/lib.rs: Likewise. * libformat_parser/.cargo/config: Moved to... * libformat_parser/.cargo/config.toml: ...here.
2025-03-31gccrs: nr2.0: Fix test const_generics_3.rsOwen Avery2-4/+5
gcc/testsuite/ChangeLog: * rust/compile/const_generics_3.rs: Modify test to run with name resolution 2.0 only and to handle the absence of a bogus resolution error. * rust/compile/nr2/exclude: Remove const_generics_3.rs. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-03-31gccrs: lower: Handle let-else properlyArthur Cohen3-5/+37
gcc/rust/ChangeLog: * hir/tree/rust-hir-stmt.h (class LetStmt): Add optional diverging else expression. * hir/tree/rust-hir-stmt.cc: Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Add handling for lowering diverging else.
2025-03-31gccrs: name-resolution: Handle let-else properlyArthur Cohen2-3/+7
gcc/rust/ChangeLog: * resolve/rust-ast-resolve-stmt.h: Add handling for diverging else. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Likewise.
2025-03-31gccrs: dump: Handle let-else properlyArthur Cohen1-0/+8
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Add handling for diverging else expression.
2025-03-31gccrs: parser: Parse let-else statementsArthur Cohen1-1/+5
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_let_stmt): Add new parsing in case of `else` token.
2025-03-31gccrs: ast: Add optional diverging else to AST::LetStmtArthur Cohen2-2/+30
gcc/rust/ChangeLog: * ast/rust-stmt.h (class LetStmt): Add optional expression for diverging else. * ast/rust-ast-builder.cc (Builder::let): Use new API.
2025-03-31gccrs: Remove now passing test from exclusion listPierre-Emmanuel Patry1-5/+0
Those tests were malformed and failed with the new name resolution because of it. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove test from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: Fix testcase module pathPierre-Emmanuel Patry9-137/+139
Those tests are coming from libcore and module inlining was wrong, in libcore there was a use declaration to import those modules which was missing here. gcc/testsuite/ChangeLog: * rust/compile/issue-2330.rs: Use complete path from crate root. * rust/compile/issue-1901.rs: Likewise. * rust/compile/issue-1981.rs: Likewise. * rust/compile/iterators1.rs: Likewise. * rust/compile/sizeof-stray-infer-var-bug.rs: Likewise. * rust/compile/for-loop1.rs: Likewise. * rust/compile/for-loop2.rs: Likewise. * rust/compile/torture/builtin_abort.rs: Likewise. * rust/compile/torture/uninit-intrinsic-1.rs: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31gccrs: Fix function name to printfPierre-Emmanuel Patry2-2/+5
Function could not be found and triggered an error message. gcc/testsuite/ChangeLog: * rust/compile/feature_rust_attri0.rs: Add extern function declaration and change name to printf. * rust/compile/nr2/exclude: Remove now passing test from exclusion list. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-03-31d: Bump front-end language version to v2.111.0Iain Buclaw129-255/+255
Merges the front-end language implementation and runtime library with upstream dmd c6863be720, and the standard library with phobos 60034b56e. Synchronizing with the upstream release of v2.111.0. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd c6863be720. * dmd/VERSION: Bump version to v2.111.0. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c6863be720. * src/MERGE: Merge upstream phobos 60034b56e.
2025-03-31Only write gcov when file output is on [PR119553]Jørgen Kvalsvik2-11/+16
gcov_write_* functions must be guarded so they only are called when output_to_file is true, like for -fcondition-coverage, otherwise it triggers an invalid read as detected by valgrind. The gcno file is mostly written to from profile.cc, so it doesn't make too much sense to hide it in path-coverage.cc. The find_paths name was a bit imprecise, and is renamed to instrument_prime_paths. PR gcov-profile/119553 gcc/ChangeLog: * path-coverage.cc (find_paths): Return path count, don't write to gcno, and rename to ... (instrument_prime_paths): ... this. * profile.cc (branch_prob): Write path counts to gcno.
2025-03-31d: Fix error with -Warray-bounds and -O2 [PR117002]Iain Buclaw4-1/+38
The record layout of class types in D don't get any tail padding, so it is possible for the `classInstanceSize' to not be a multiple of the `classInstanceAlignment'. Rather than setting the instance alignment on the underlying RECORD_TYPE, instead give the type an alignment of 1, which will mark it as TYPE_PACKED. The value of `classInstanceAlignment' is instead applied to the DECL_ALIGN of both the static `init' symbol, and the stack allocated variable used when generating `new' for a `scope' class. PR d/117002 gcc/d/ChangeLog: * decl.cc (aggregate_initializer_decl): Set explicit decl alignment of class instance. * expr.cc (ExprVisitor::visit (NewExp *)): Likewise. * types.cc (TypeVisitor::visit (TypeClass *)): Mark the record type of classes as packed. gcc/testsuite/ChangeLog: * gdc.dg/torture/pr117002.d: New test.
2025-03-31c++: fix reporting routines re-entered [PR119303]Marek Polacek3-12/+36
We crash while we call warning_at ("inline function used but never defined") since it invokes dump_template_bindings -> tsubst -> ... -> convert_like -> ... -> c_common_truthvalue_conversion -> warning_at ("enum constant in boolean context") cp_truthvalue_conversion correctly gets complain=0 but it calls c_common_truthvalue_conversion from c-family which doesn't have a similar parameter. We can fix this by tweaking diagnostic_context::report_diagnostic to check for recursion after checking if the diagnostic was enabled. PR c++/116960 PR c++/119303 gcc/ChangeLog: * diagnostic.cc (diagnostic_context::report_diagnostic): Check for non-zero m_lock later, after checking diagnostic_enabled. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-uneval26.C: New test. * g++.dg/warn/undefined2.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-03-31aarch64: Remove +sme -> +sve2 feature flag dependencyAndre Simoes Dias Vieira39-42/+88
As per the AArch64 ISA FEAT_SME does not require FEAT_SVE2. However, we don't support SME without SVE2 and bail out with a 'sorry' if this configuration is encountered. We may choose to support this in the future. gcc/ChangeLog: * config/aarch64/aarch64-option-extensions.def (SME): Remove SVE2 as prerequisite and add in FCMA and F16FML. * config/aarch64/aarch64.cc (aarch64_override_options_internal): Diagnose use of SME without SVE2 and implicitly enable SVE2 when enabling SME after streaming mode diagnosis. * doc/invoke.texi (sme): Document that this can only be used with the sve2 extension. gcc/testsuite/ChangeLog: * gcc.target/aarch64/no-sve-with-sme-1.c: New. * gcc.target/aarch64/no-sve-with-sme-2.c: New. * gcc.target/aarch64/no-sve-with-sme-3.c: New. * gcc.target/aarch64/no-sve-with-sme-4.c: New. * gcc.target/aarch64/pragma_cpp_predefs_4.c: Pass +sve2 to existing +sme pragma. * gcc.target/aarch64/sve/acle/general-c/binary_int_opt_single_n_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_opt_single_n_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_single_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_int_opt_single_1.c: * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_3.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_lane_4.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_opt_single_3.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binary_za_slice_uint_opt_single_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/binaryxn_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/clamp_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/compare_scalar_count_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/dot_za_slice_int_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/dot_za_slice_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/dot_za_slice_lane_2.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/dot_za_slice_uint_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/shift_right_imm_narrowxn_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/storexn_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/ternary_mfloat8_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/ternary_mfloat8_lane_group_selection_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/ternary_qq_or_011_lane_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/unary_convertxn_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/unary_convertxn_narrow_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/unary_convertxn_narrowt_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/unary_za_slice_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/unaryxn_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/write_za_1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/write_za_slice_1.c: Likewise.