aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2025-08-05gccrs: Support compilation of IdentifierPattern's subpatternsZhi Heng2-0/+19
gcc/rust/ChangeLog: * backend/rust-compile-pattern.cc: Add CheckExpr compilation for IdentifierPattern with subpattern. * backend/rust-compile-pattern.h: Modify IdentifierPattern's visit func to support the above. * typecheck/rust-hir-type-check-pattern.cc: Add typechecking support for the changes above. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
2025-08-05gccrs: nr2.0: Improve handling of single segment pathsOwen Avery1-2/+0
gcc/rust/ChangeLog: * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Handle single segment paths "crate", "self", and "super". gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Adjust pub_restricted testsOwen Avery3-10/+10
gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. * rust/compile/pub_restricted_1.rs: Adjust expected error messages and only run with name resolution 2.0 enabled. * rust/compile/pub_restricted_2.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Separate out canonical path handlingOwen Avery1-1/+0
This should improve our canonical path handling, without requiring further tweaks to ForeverStack. This may also help if, in the future, we have to move canonical path calculation to later compilation phases for proper handling of generics. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::compile_function): Since canonical paths returned from nr2.0 now include the crate name, avoid prepending the crate name again. * backend/rust-compile-implitem.cc (CompileTraitItem::visit): Use NameResolutionContext::to_canonical_path instead of ForeverStack::to_canonical_path. * backend/rust-compile-item.cc (CompileItem::visit): Likewise. * typecheck/rust-hir-type-check-enumitem.cc (TypeCheckEnumItem::visit): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItem::visit): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Add Crate and EnumItem instance visitors, handle canonical path context scoping. * resolve/rust-default-resolver.h (DefaultResolver::visit): Add Crate and EnumItem instance visitors. * resolve/rust-early-name-resolver-2.0.cc (Early::go): Visit instances of Crate using the virtual member function visit. * resolve/rust-forever-stack.h (ForeverStack::to_canonical_path): Remove function declaration. * resolve/rust-forever-stack.hxx (ForeverStack::to_canonical_path): Remove function definition. * resolve/rust-late-name-resolver-2.0.cc (Late::go): Visit instances of Crate using the virtual member function visit. * resolve/rust-name-resolution-context.cc (CanonicalPathRecordCrateRoot::as_path): New function definition. (CanonicalPathRecordNormal::as_path): Likewise. (CanonicalPathRecordLookup::as_path): Likewise. (CanonicalPathRecordImpl::as_path): Likewise. (CanonicalPathRecordTraitImpl::as_path): Likewise. (NameResolutionContext::NameResolutionContext): Initialize member variable canonical_ctx. * resolve/rust-name-resolution-context.h: Include "rust-item.h". (class NameResolutionContext): Forward declare class. (class CanonicalPathRecord): New class. (class CanonicalPathRecordWithParent): Likewise. (class CanonicalPathRecordCrateRoot): Likewise. (class CanonicalPathRecordNormal): Likewise. (class CanonicalPathRecordLookup): Likewise. (class CanonicalPathRecordImpl): Likewise. (class CanonicalPathRecordTraitImpl): Likewise. (class CanonicalPathCtx): Likewise. (NameResolutionContext::canonical_ctx): New member variable. (NameResolutionContext::to_canonical_path): New member function. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Visit instances of Crate with the virtual member function visit. (TopLevel::visit): Handle canonical path context scoping for external crates, use DefaultResolver::visit when visiting instances of StructStruct. * util/rust-canonical-path.h (CanonicalPath::new_seg): Take path parameter by-value, as a duplicate instance will be constructed regardless. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove canonical_paths1.rs.
2025-08-05gccrs: fix: ICE when parsing unterminated raw byte stringsVishruth-Thimmaiah1-0/+6
Fixes an ICE when a raw byte string is not terminated Fixes Rust-GCC#3731 gcc/rust/ChangeLog: * lex/rust-lex.cc (Lexer::parse_raw_byte_string): Fix infinite looping when a raw byte string is not terminated. gcc/testsuite/ChangeLog: * rust/compile/torture/unended-raw-byte-string.rs: New test to ensure correct error message for unended raw byte string. Signed-off-by: Vishruth Thimmaiah <vishruththimmaiah@gmail.com>
2025-08-05gccrs: nr2.0: Catch Self in impl block self typesOwen Avery3-2/+18
gcc/rust/ChangeLog: * resolve/rust-default-resolver.cc (DefaultResolver::visit): Use visit_impl_type to visit the self types of impl blocks. * resolve/rust-default-resolver.h (DefaultResolver::visit_impl_type): New member function declaration. * resolve/rust-late-name-resolver-2.0.cc (Late::Late): Initialize member variable block_big_self. (Late::visit_impl_type): New member function definition. (Late::visit): Check for Self while inside impl block self types. * resolve/rust-late-name-resolver-2.0.h (Late::visit_impl_type): New member function. (Late::block_big_self): New member variable. gcc/testsuite/ChangeLog: * rust/compile/issue-3671.rs: Remove usage of Self. * rust/compile/nr2/exclude: Remove issue-3671.rs. * rust/compile/self-in-impl.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Improve visibility path handlingOwen Avery1-2/+0
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (enum ResolutionMode): New. (ForeverStack::get): Add a private overload that takes a starting node as a parameter. (ForeverStack::resolve_path): Replace boolean parameter has_opening_scope_resolution with ResolutionMode parameter mode. * resolve/rust-forever-stack.hxx (ForeverStack::resolve_path): Likewise. (ForeverStack::get): Add a private overload that takes a starting node as a parameter. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add Visibility visitor. * resolve/rust-late-name-resolver-2.0.h (Late::visit): Likewise. * resolve/rust-name-resolution-context.h (NameResolutionContext::resolve_path): Rework overloading a bit and accept ResolutionMode parameter. gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: Remove entries. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: parser: fix ICE std::out_of_range with path attrs to nonexisting pathVishruth-Thimmaiah1-0/+6
Stops an ICE from occuring when path attribute is empty Fixes Rust-GCC#3607. gcc/rust/ChangeLog: * parse/rust-parse.cc (Rust::extract_module_path): Handle empty or whitespace-only path attributes. gcc/testsuite/ChangeLog: * rust/compile/torture/extern_mod2.rs: New test to ensure an error is emitted for empty path attributes. Signed-off-by: Vishruth Thimmaiah <vishruththimmaiah@gmail.com>
2025-08-05gccrs: const-block: Add testcaseArthur Cohen1-0/+9
gcc/testsuite/ChangeLog: * rust/execute/torture/const_block1.rs: New test.
2025-08-05gccrs: Always emit the error highest in the type hierarchyPhilip Herron2-2/+50
The unify code was a bit dumb here where we always set emit_error to false for any subtypes for example in comparing tuples we always emitted the whole tuple didnt match the other tuple but really its much better to say expected bool got i32 because the element types didn't match. gcc/rust/ChangeLog: * typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsized): dont emit error here * typecheck/rust-unify.cc (UnifyRules::resolve_subtype): new helper to handle emit error (UnifyRules::expect_adt): call resolve_subtype (UnifyRules::expect_reference): likewise (UnifyRules::expect_pointer): likewise (UnifyRules::expect_array): likewise (UnifyRules::expect_slice): likewise (UnifyRules::expect_fndef): likewise (UnifyRules::expect_fnptr): likewise (UnifyRules::expect_tuple): likewise (UnifyRules::expect_closure): likewise (UnifyRules::expect_opaque): likeiwse * typecheck/rust-unify.h: add new helper to header gcc/testsuite/ChangeLog: * rust/compile/traits9.rs: update errors * rust/compile/unify-errors1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Initial support for Return Position Impl TraitPhilip Herron4-0/+115
This is the initial patch for RPIT, we can build on this to handle the more complex cases but there are enough distinct changes going on here that it should just get merged now. RPIT is really a sneaky generic so for example: fn foo() -> impl Bar { Baz } This is represented as: fn () -> OpaqueType Bar. But when we handle the coercion site for Baz on impl Bar when we type resolve the function we know that the underlying type is Baz. Note this function is _not_ generic so its using this special OpaqueType and keeping track of the underlying type in its ty_ref reference hir-id which will resolve to Baz. This also means if we have a case where maybe this was in an if statement: fn foo(a: i32) -> impl Bar { if a > 10 { Baz } else { Qux } } The rules of impl Bar is that Baz is handled but Baz and Qux are different underlying types so this is not allowed. The reason is impl traits are not generic and although from a programmer perspective the callers dont know what the underlying type is, the compiler _knows_ what it is. So really when you call a function and get its return position impl trait the compiler knows what to do and does all whats nessecary to handle calling functions using that type etc. gcc/rust/ChangeLog: * backend/rust-compile-type.cc (TyTyResolveCompile::visit): we need to resolve the underlying type * typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit): just clone * typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): ensure we monomphize to get the underlying * typecheck/rust-tyty.cc (BaseType::destructure): handle opaque types (OpaqueType::resolve): this is much simpler now (OpaqueType::handle_substitions): no longer needed * typecheck/rust-tyty.h: update header * typecheck/rust-unify.cc (UnifyRules::expect_opaque): unify rules for opaque gcc/testsuite/ChangeLog: * rust/compile/bad-rpit1.rs: New test. * rust/execute/torture/impl_rpit1.rs: New test. * rust/execute/torture/impl_rpit2.rs: New test. * rust/execute/torture/impl_rpit3.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: Revert 10-second timeout for each testParthib1-4/+1
gcc/testsuite/ChangeLog: * lib/rust.exp: Remove timeout. Signed-off-by: Parthib <parthibdutta02@gmail.com>
2025-08-05gccrs: nr2.0: Fix some paths in test filesOwen Avery3-57/+57
This is similar to 9faba024ef18b9c4d67f22bd3b020b5e445fad0a, but it applies to execute tests. gcc/testsuite/ChangeLog: * rust/execute/torture/for-loop1.rs: Adjust paths. * rust/execute/torture/for-loop2.rs: Likewise. * rust/execute/torture/iter1.rs: Likewise. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: nr2.0: Fix test builtin_abort.rsOwen Avery1-1/+1
gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_abort.rs: Fix path to intrinsics::abort. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Fix NR2 ICE in visit_attributesTom Schollenberger1-0/+10
Undefined attribute macros have no proc macro definition, which results in a failing `rust_assert`. This changes that assert to an if statement, that returns early if there is no proc macro definition. Fixes #3661. gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): rust_assert to if gcc/testsuite/ChangeLog: * rust/compile/issue-3661.rs: Test NR2 has expected behavior Signed-off-by: Tom Schollenberger <tss2344@g.rit.edu>
2025-08-05gccrs: Fix Attr metavariable bindingOwen Avery1-0/+7
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (Parser::parse_attr_input): Handle more delimeter tokens and the END_OF_FILE token. (Parser::skip_after_end_attribute): Handle the END_OF_FILE token. gcc/testsuite/ChangeLog: * rust/compile/macros/mbe/meta-param.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: Fix test same_field_name.rsOwen Avery1-1/+1
gcc/rust/ChangeLog: * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Keep going after a duplicate field is found. gcc/testsuite/ChangeLog: * rust/execute/same_field_name.rs: Move to... * rust/compile/same_field_name.rs: ...here and adjust expected errors. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2025-08-05gccrs: We cant clone types as it will dup the node-idPhilip Herron1-2/+0
This patch ensuers we reuse the Builder for new type to ensure we create a new type from scratch ensuring consistent new node-ids. gcc/rust/ChangeLog: * expand/rust-derive-default.cc (DeriveDefault::visit_struct): use builder (DeriveDefault::visit_tuple): likewise * expand/rust-derive-eq.cc (DeriveEq::visit_tuple): likewise (DeriveEq::visit_struct): likewise (DeriveEq::visit_enum): likewise (DeriveEq::visit_union): likewise gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: these are fixed now Signed-off-by: Philip Herron <herron.philip@googlemail.com>
2025-08-05gccrs: nr2.0: Adjust resolution of impl itemsOwen Avery1-2/+0
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 <powerboat9.gamer@gmail.com>
2025-08-05gccrs: fix ICE on empty constexpr loopsTom Schollenberger1-0/+1
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 <tss2344@g.rit.edu>
2025-08-05gccrs: Prevent passing generic arguments to impl traits in argument positionPhilip Herron2-0/+25
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 <herron.philip@googlemail.com>
2025-08-05gccrs: Improve struct pattern compilationOwen Avery1-0/+13
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 <powerboat9.gamer@gmail.com>
2025-08-05gccrs: desugar APIT impl traitsPhilip Herron11-1/+266
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 Rust-GCC#2015 Fixes Rust-GCC#1487 Fixes Rust-GCC#3454 Fixes Rust-GCC#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 <herron.philip@googlemail.com>
2025-08-05gccrs: Emit error diagnostic for bad impl type usagePhilip Herron2-0/+33
Rust only allows impl traits to be used in the return position of functions. Fixes Rust-GCC#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 <herron.philip@googlemail.com>
2025-08-05gccrs: derive(PartialEq): Fix raw strings in testCohenArthur1-2/+2
gcc/testsuite/ChangeLog: * rust/execute/torture/derive-partialeq2.rs: Add missing terminating nul char. Co-authored-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
2025-08-05gccrs: derive(PartialEq): Allow deriving enum structsArthur Cohen1-0/+66
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.
2025-08-05gccrs: backend: Compile struct rebinding patternsArthur Cohen1-0/+19
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.
2025-08-05AVR: target/121359: Remove -mlra and remains of reload.Georg-Johann Lay2-2/+2
PR target/121359 gcc/ * config/avr/avr.h: Remove -mlra and remains of reload. * config/avr/avr.cc: Same. * config/avr/avr.md: Same. * config/avr/avr-log.cc: Same. * config/avr/avr-protos.h: Same. * config/avr/avr.opt: Same. * config/avr/avr.opt.urls: Same. gcc/testsuite/ * gcc.target/avr/torture/pr118591-1.c: Remove -mlra. * gcc.target/avr/torture/pr118591-2.c: Same.
2025-08-05tree-optimization/121395 - SLP of SIMD calls w/o LHSRichard Biener1-0/+4
The following records the alternate SLP instance entries coming from stmts with stores that have no SSA def, like OMP SIMD calls without LHS. There's a bit of fallout with having a SLP tree with a NULL vectype, but nothing too gross. PR tree-optimization/121395 * tree-vectorizer.h (_loop_vec_info::alternate_defs): New member. (LOOP_VINFO_ALTERNATE_DEFS): New. * tree-vect-stmts.cc (vect_stmt_relevant_p): Populate it. (vectorizable_simd_clone_call): Do not register a SLP def when there is none. * tree-vect-slp.cc (vect_build_slp_tree_1): Allow a NULL vectype when there's no LHS. Allow all calls w/o LHS. (vect_analyze_slp): Process LOOP_VINFO_ALTERNATE_DEFS as SLP graph entries. (vect_make_slp_decision): Handle a NULL SLP_TREE_VECTYPE. (vect_slp_analyze_node_operations_1): Likewise. (vect_schedule_slp_node): Likewise. * gcc.dg/vect/pr59984.c: Adjust.
2025-08-05tree-optimization/121382 - avoid UB in IVOPTs inserted step computationRichard Biener1-0/+23
IVOPTs, when replacing an IV, inserts the computation of the new IVs step in the loop preheader without considering the case of the loop not iterating. This means we have to ensure the step computation does not invoke UB. There is also SCEV which does not care about signed arithmetic UB when re-associating expressions to form CHRECs, so even when we know the loop iterates this is required. PR tree-optimization/121382 * tree-ssa-loop-ivopts.cc (create_new_iv): Rewrite the IV step to defined form. * gcc.dg/torture/pr121382.c: New testcase.
2025-08-05tree-optimization/121370 - avoid UB in building a CHRECRichard Biener1-0/+25
When there is obvious UB involved in the process of re-associating a series of IV increments to build up a CHREC, fail. This catches a few degenerate cases where SCEV introduces UB with its inherent re-associating of IV increments. PR tree-optimization/121370 * tree-scalar-evolution.cc (scev_dfs::add_to_evolution_1): Avoid UB integer overflow in accumulating CHREC_RIGHT. * gcc.dg/torture/pr121370.c: New testcase.
2025-08-05bitint: Allow unused bits when testing extended _BitInt ABIsYang Yujie1-2/+20
In LoongArch psABI, large _BitInt(N) (N > 64) objects are only extended to fill the highest 8-byte chunk that contains any used bit, but the size of such a large _BitInt type is a multiple of their 16-byte alignment. So there may be an entire unused 8-byte chunk that is not filled by extension, and this chunk shouldn't be checked when testing if the object is properly extended. The original bitintext.h assumed that all bits within sizeof(_BitInt(N)) beyond used bits are filled by extension. This patch changes that for LoongArch and possibly any future ports with a similar behavior. P.S. For encoding this test as well as type-generic programming, it would be nice to have a builtin function to obtain "N" at compile time from _BitInt(N)-typed expressions. But here we stick to existing ones (__builtin_clrsbg / __builtin_clzg). * gcc.dg/bitintext.h (S, CEIL, PROMOTED_SIZE): Define. (BEXTC): Generalize to only check extension within PROMOTED_SIZE bits.
2025-08-05libcpp: Add testcase for CWG2579 [PR120778]Jakub Jelinek7-13/+22
Another easy part from the paper. Part of the CWG2579 has been already done in an earlier paper (with test commits by Marek) and the remaining part is implemented correctly, we diagnose as error when token pasting doesn't form a valid token. Except that message pasting """" and """" does not give a valid preprocessing token looked weird and so I've updated the message to use %< and %> instead of \" quoting. 2025-08-05 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * macro.cc (paste_tokens): Use %< and %> instead of \" in diagnostics around %.*s. * g++.dg/DRs/dr2579.C: New test. * c-c++-common/cpp/va-opt-6.c: Expect ' rather than \" around tokens in incorrect pasting diagnostics. * gcc.dg/c23-attr-syntax-6.c: Likewise. * gcc.dg/cpp/paste12.c: Likewise. * gcc.dg/cpp/paste12-2.c: Likewise. * gcc.dg/cpp/paste14.c: Likewise. * gcc.dg/cpp/paste14-2.c: Likewise.
2025-08-05RISC-V: Fix scalar code-gen of unsigned SAT_MULPan Li2-0/+3
The previous code-gen of scalar unsigned SAT_MUL, aka usmul. Leverage the mulhs by mistake, it should be mulhu for the hight bit result of mul. Thus, this patch would like to make it correct. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_expand_xmode_usmul): Take umulhu for high bits mul result. gcc/testsuite/ChangeLog: * gcc.target/riscv/sat/sat_u_mul-1-u32-from-u64.c: Add mulhu asm check. * gcc.target/riscv/sat/sat_u_mul-1-u64-from-u128.c: Ditto. Signed-off-by: Pan Li <pan2.li@intel.com>
2025-08-05Daily bump.GCC Administrator1-0/+190
2025-08-04c++: add another testcase [PR121351]Patrick Palka1-0/+20
Here's a previously accepted testcase that is now ambiguous after r16-2771-gb9f1cc4e119da, since the uninstantiated constraints are equivalent but the partially instantiated constraints aren't, so the two member functions no longer correspond. PR c++/121351 gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using6.C: New test.
2025-08-04c++: constrained memfn vs corresponding using [PR121351]Patrick Palka2-0/+39
The b.f(42) calls in the below testcases started to get rejected as ambiguous after r15-3740 which corrected our inheritedness tiebreaker to only apply to constructors (and not all member functions) as per CWG2273. But arguably these calls should still be valid regardless of the tiebreaker because B::f corresponds to and therefore hides A::f, so there should only be a single candidate in the first place. This doesn't happen because when determining correspondence we compare the members' uninstantiated constraints instead of their partially substituted constraints as in other declaration matching situations. It doesn't really make sense to compare uninstantiated constraints from two different template contexts. This patch fixes this by substituting in outer template arguments before comparing constraints of two potentially corresponding member functions. PR c++/121351 PR c++/119859 gcc/cp/ChangeLog: * class.cc (add_method): Substitute outer template arguments into constraints before comparing them if the declarations are from different classes. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-using5.C: New test. * g++.dg/cpp2a/concepts-using5a.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-04c++: constexpr evaluation of abi::__dynamic_cast [PR120620]Patrick Palka2-0/+16
r13-3299 changed our internal declaration of __dynamic_cast to reside inside the abi/__cxxabiv1:: namespace instead of the global namespace, matching the real declaration. This inadvertently made us now attempt constexpr evaluation of user-written calls to abi::__dynamic_cast since cxx_dynamic_cast_fn_p now also returns true for them, but we're not prepared to handle arbitrary calls to __dynamic_cast, and therefore ICE. This patch restores cxx_dynamic_cast_fn_p to return true only for synthesized calls to __dynamic_cast, which can be distinguished by DECL_ARTIFICIAL, since apparently the synthesized declaration of __dynamic_cast doesn't get merged with the actual declaration. PR c++/120620 gcc/cp/ChangeLog: * constexpr.cc (cxx_dynamic_cast_fn_p): Return true only for synthesized __dynamic_cast. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-dynamic19.C: New test. * g++.dg/cpp2a/constexpr-dynamic1a.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
2025-08-04diagnostics: improve support for nesting levels [PR116253]David Malcolm5-0/+248
This patch adds support to sarif-replay for "nestingLevel" from "P3358R0 SARIF for Structured Diagnostics" https://wg21.link/P3358R0 Doing so revealed a bug where libgdiagnostics was always creating new location_t values (and thus also diagnostic_physical_location instances), rather than reusing existing location_t values, leading to excess source printing. The patch also fixes this bug, adding a new flag to libgdiagnostics for debugging physical locations, and exposing this in sarif-replay via a new "-fdebug-physical-locations" maintainer option. Finally, the patch adds test coverage for the HTML sink's output of nested diagnostics (both from a GCC plugin, and from sarif-replay). gcc/ChangeLog: PR diagnostics/116253 * diagnostics/context.cc (context::set_nesting_level): New. * diagnostics/context.h (context::set_nesting_level): New decl. * doc/libgdiagnostics/topics/compatibility.rst (LIBGDIAGNOSTICS_ABI_5): New. * doc/libgdiagnostics/topics/physical-locations.rst (diagnostic_manager_set_debug_physical_locations): New. * libgdiagnostics++.h (manager::set_debug_physical_locations): New. * libgdiagnostics-private.h (private_diagnostic_set_nesting_level): New decl. * libgdiagnostics.cc (diagnostic_manager::diagnostic_manager): Initialize m_debug_physical_locations. (diagnostic_manager::new_location_from_file_and_line): Add debug printing. (diagnostic_manager::new_location_from_file_line_column): Likewise. (diagnostic_manager::new_location_from_range): Likewise. (diagnostic_manager::set_debug_physical_locations): New. (diagnostic_manager::ensure_linemap_for_file_and_line): Avoid redundant calls to linemap_add. (diagnostic_manager::new_location): Add debug printing. (diagnostic_manager::m_debug_physical_locations): New field. (diagnostic::diagnostic): Initialize m_nesting_level. (diagnostic::get_nesting_level): New accessor. (diagnostic::set_nesting_level): New. (diagnostic::m_nesting_level): New field. (diagnostic_manager::emit_va): Set and reset the nesting level of the context from that of the diagnostic. (diagnostic_manager_set_debug_physical_locations): New. (private_diagnostic_set_nesting_level): New. * libgdiagnostics.h (diagnostic_manager_set_debug_physical_locations): New decl. * libgdiagnostics.map (LIBGDIAGNOSTICS_ABI_5): New. * libsarifreplay.cc (sarif_replayer::handle_result_obj): Support the "nestingLevel" property. * libsarifreplay.h (replay_options::m_debug_physical_locations): New field. * sarif-replay.cc: Add -fdebug-physical-locations. gcc/testsuite/ChangeLog: PR diagnostics/116253 * gcc.dg/plugin/diagnostic-test-nesting-html.c: New test. * gcc.dg/plugin/diagnostic-test-nesting-html.py: New test script. * gcc.dg/plugin/plugin.exp: Add it. * libgdiagnostics.dg/test-multiple-lines.c: Update expected output to show fix-it hint. * sarif-replay.dg/2.1.0-valid/nested-diagnostics-1.sarif: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04diagnostics: avoid stray trailing space in html sink in sarif-replay [PR116792]David Malcolm3-3/+3
For the common case where a diagnostic has no metadata, sarif-replay's html output was adding a stray space followed by an empty <div> for the metadata. Fixed thusly. gcc/ChangeLog: PR diagnostics/116792 * diagnostics/html-sink.cc (html_builder::make_element_for_diagnostic): Don't add the metadata element if it's empty. (html_builder::make_element_for_metadata): Return null rather than an empty element. gcc/testsuite/ChangeLog: PR diagnostics/116792 * gcc.dg/plugin/diagnostic-test-graphs-html.py: Remove trailing space from expected text of message. * sarif-replay.dg/2.1.0-valid/embedded-links-check-html.py: Likewise. * sarif-replay.dg/2.1.0-valid/graphs-check-html.py: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-08-04asf: Fix null pointer dereference in is_store_forwarding [PR121303]Konstantinos Eleftheriou1-0/+26
We were calling `is_store_forwarding` with a NULL value for `off_val`, which was causing a null pointer dereference in `is_constant`, leading to an ICE. This patch updates the call to `is_constant` in `is_store_forwarding` and adds a check for `off_val`, in order to update it with the right value. Bootstrapped/regtested on AArch64 and x86_64. PR rtl-optimization/121303 gcc/ChangeLog: * avoid-store-forwarding.cc (is_store_forwarding): Add check for `off_val` in `is_store_forwarding`. gcc/testsuite/ChangeLog: * gcc.target/i386/pr121303.c: New test.
2025-08-04c++: Add #line testcase for CWG2580 [PR120778]Jakub Jelinek1-0/+87
Contrary to what the paper says, I think for #line directives we diagnose everything we should (sure, some diagnostics are pedwarns). 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * g++.dg/DRs/dr2580.C: New test.
2025-08-04libcpp: Use pedwarn instead of warning for CWG2578 diagnostics [PR120778]Jakub Jelinek1-0/+10
This is another case which changed from compile time undefined behavior to ill-formed, diagnostic required. Now, we warn on this, so pedantically that is good enough, maybe all we need is a testcase, but the following patch changes it to a pedwarn for C++26. 2025-08-04 Jakub Jelinek <jakub@redhat.com> PR preprocessor/120778 * macro.cc (stringify_arg): For C++26 emit a pedarn instead of warning for \ at the end of stringification. * g++.dg/DRs/dr2578.C: New test.
2025-08-04aarch64: Use VNx16BI for svdupq_b*Richard Sandiford1-0/+45
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdupq. The general predicate expansion builds an equivalent integer vector and then compares it with zero. This patch therefore relies on the earlier patches to the comparison patterns. gcc/ * config/aarch64/aarch64-protos.h (aarch64_convert_sve_data_to_pred): Remove the mode argument. * config/aarch64/aarch64.cc (aarch64_sve_emit_int_cmp): Allow PRED_MODE to be VNx16BI or the natural predicate mode for the data mode. (aarch64_convert_sve_data_to_pred): Remove the mode argument and instead always create a VNx16BI result. (aarch64_expand_sve_const_pred): Update call accordingly. * config/aarch64/aarch64-sve-builtins-base.cc (svdupq_impl::expand): Likewise, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dupq_13.c: New test.
2025-08-04aarch64: Use VNx16BI for svdup_b*Richard Sandiford1-0/+47
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the predicate forms of svdup. gcc/ * config/aarch64/aarch64-protos.h (aarch64_emit_sve_pred_vec_duplicate): Declare. * config/aarch64/aarch64.cc (aarch64_emit_sve_pred_vec_duplicate): New function. * config/aarch64/aarch64-sve.md (vec_duplicate<PRED_ALL:mode>): Use it. * config/aarch64/aarch64-sve-builtins-base.cc (svdup_impl::expand): Handle boolean values specially. Check for constants and fall back on aarch64_emit_sve_pred_vec_duplicate for the variable case, ensuring that the result has mode VNx16BI. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/dup_1.c: New test.
2025-08-04aarch64: Use VNx16BI for svpnext*Richard Sandiford1-0/+130
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svpnext* intrinsics. gcc/ * config/aarch64/iterators.md (PNEXT_ONLY): New int iterator. * config/aarch64/aarch64-sve.md (@aarch64_sve_<sve_pred_op><mode>): Restrict SVE_PITER pattern to VNx16BI_ONLY. (@aarch64_sve_<sve_pred_op><mode>): New PNEXT_ONLY pattern for PRED_HSD. (*aarch64_sve_<sve_pred_op><mode>): Likewise. (*aarch64_sve_<sve_pred_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/pnext_3.c: New test.
2025-08-04aarch64: Use VNx16BI for sv(n)match*Richard Sandiford2-0/+60
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svmatch* and svnmatch* intrinsics. gcc/ * config/aarch64/aarch64-sve2.md (@aarch64_pred_<sve_int_op><mode>): Split SVE2_MATCH pattern into a VNx16QI_ONLY define_ins and a VNx8HI_ONLY define_expand. Use a VNx16BI destination for the latter. (*aarch64_pred_<sve_int_op><mode>): New SVE2_MATCH pattern for VNx8HI_ONLY. (*aarch64_pred_<sve_int_op><mode>_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve2/acle/general/match_4.c: New test. * gcc.target/aarch64/sve2/acle/general/nmatch_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svac*Richard Sandiford4-0/+416
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svac* intrinsics (floating- point compare absolute). gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_fac<cmp_op><mode>): Replace with... (@aarch64_pred_fac<cmp_op><mode>_acle): ...this new expander. (*aarch64_pred_fac<cmp_op><mode>_strict_acle): New pattern. * config/aarch64/aarch64-sve-builtins-base.cc (svac_impl::expand): Update accordingly. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/acge_1.c: New test. * gcc.target/aarch64/sve/acle/general/acgt_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/acle_1.c: Likewise. * gcc.target/aarch64/sve/acle/general/aclt_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for floating-point svcmp*Richard Sandiford7-0/+728
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the floating-point forms of svcmp*. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_fcm<cmp_op><mode>_acle) (*aarch64_pred_fcm<cmp_op><mode>_acle, @aarch64_pred_fcmuo<mode>_acle) (*aarch64_pred_fcmuo<mode>_acle): New patterns. * config/aarch64/aarch64-sve-builtins-base.cc (svcmp_impl::expand, svcmpuo_impl::expand): Use them. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_6.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_9.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_5.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpuo_1.c: Likewise.
2025-08-04aarch64: Use VNx16BI for svcmp*_wideRichard Sandiford10-0/+520
This patch continues the work of making ACLE intrinsics use VNx16BI for svbool_t results. It deals with the svcmp*_wide intrinsics. Since the only uses of these patterns are for ACLE intrinsics, there didn't seem much point adding an "_acle" suffix. gcc/ * config/aarch64/aarch64-sve.md (@aarch64_pred_cmp<cmp_op><mode>_wide): Split into VNx16QI_ONLY and SVE_FULL_HSI patterns. Use VNx16BI results for both. (*aarch64_pred_cmp<cmp_op><mode>_wide): New pattern. (*aarch64_pred_cmp<cmp_op><mode>_wide_cc): Likewise. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general/cmpeq_5.c: New test. * gcc.target/aarch64/sve/acle/general/cmpge_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpge_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpgt_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmple_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_7.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmplt_8.c: Likewise. * gcc.target/aarch64/sve/acle/general/cmpne_4.c: Likewise.