Sync with upstream (2026-09-29): d9d90129f6dd53d2375c5a13a1563c4365e43a2f - #4946
Merged
Merged
Conversation
…ctions Now that the implementation of freezing for expression functions is mostly in line with its semantic model, quirks of the previous implementation are obsolete and can be eliminated. The cleanup performed in Analyze_Declarations exposed a couple of glitches in the ad-hoc resolution implemented for aspect expressions: the prefixes of components were resolved, but not those of subcomponents, and selector names of expanded names were incorrectly resolved as direct names. gcc/ada/ * sinfo.ads (Selector_Name): Beef up description. * sem_ch3.adb (Contains_Lib_Incomplete_Type): Delete. (Analyze_Declarations): Remove obsolete code. * sem_ch13.adb (Resolve_Aspect_Expressions.Resolve_Name): Resolve only names that are not selector names.
The main part is the renaming of Freeze_Expr_Types to Freeze_Full_Expression and Freeze_Expr_Types_Before to Freeze_Full_Expression_Before to reflect the actual intent of the subprograms. gcc/ada/ * freeze.ads (Freeze_Entity): Move around. (Freeze_Before): Rename T parameter to E. (Freeze_Expression): Improve description. (Freeze_Expr_Types_Before): Rename to... (Freeze_Full_Expression_Before): ...this. * freeze.adb (Freeze_Expr_Types): Rename to... (Freeze_Full_Expression): ...this. (Freeze_Before): Rename T parameter to E and Pack variable to Scop. (Freeze_Entity): Adjust to above renaming. (Freeze_Expression): Likewise. (Freeze_Expr_Types_Before): Rename to... (Freeze_Full_Expression_Before): ...this. * contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Adjust to above renaming. (Expand_Subprogram_Contract): Likewise. * sem_ch6.adb (Analyze_Expression_Function): Likewise.
…125459] The RESULT_DECL of a function during constant evaluation has its value stored in the constexpr_global_ctx, and once its lifetime ends void_list_node is put in its place. If the same function is then called later during the same constant evaluation from within the scope of a modifiable_tracker (i.e., during speculative evaluation of a contract assertion, or evaluation of the predicate of an [[assume]]) the population of the return value will find an entry (void_list_node) already in the context and treat the call as an attempt to modify outside state, resulting in errors. This change updates the put_value member of constexpr_global_ctx to recognize void_list_node values in the map as not being a concern for what modifiable is tracking, and treats them the same way it treats not yet having a value in the map for that key. void_node is not treated the same way because that would indicate an object that has been destroyed but whose storage has not yet been deallocated. PR c++/125459 - [contracts] "contract condition is not constant" in constexpr function PR c++/125459 gcc/cp/ChangeLog: * constexpr.cc (constexpr_global_ctx::put_value): Treat void_list_node as not having been in the map for modifiable tracking. gcc/testsuite/ChangeLog: * g++.dg/contracts/cpp26/pr125459.C: New test. Signed-off-by: Joshua Berne <berne@notadragon.com>
…mpletion The problem is that the freezing of the expression function is incomplete and does not cause the freezing of stand-alone objects declared in the same declarative part as the expression function. gcc/ada/ * freeze.adb (Freeze_Full_Expression): Also freeze the stand-alone objects of the current scope when they are referenced. * sem_ch6.adb (Analyze_Expression_Function): Do not check the use of a dynamically tagged expression if an error has been posted.
Descendants of a mutably tagged type may have controlled components, unless the No_Controlled_Parts aspect is specified alongside the Size'Class aspect, but their finalization is not correctly performed by the implementation. The change also prevents finalization boilerplate code from being generated for class-wide objects of regular tagged types when the No_Controlled_Parts aspect is specified. It also contains a couple of fixes for Might_Have_Tasks and Find_Type_Name. gcc/ada/ * gen_il-gen-gen_entities.adb (Type_Kind): Set Base_Type_Only for Is_Mutably_Tagged_Type flag. Move Class_Wide_Equivalent_Type to... (Class_Wide_Kind): ...here. * einfo.ads (Class_Wide_Equivalent_Type): Adjust description. (Is_Controlled_Active): Likewise. (Is_Controlled): Likewise. (Is_Mutably_Tagged_Type): Likewise. * exp_ch3.adb (Expand_N_Full_Type_Declaration): Use an assignment to initialize an object of a mutably tagged type whose initial value is not the result of a function call. * exp_ch5.adb (Expand_N_Assignment_Statement): Do not dispatch to an _assign primitive for an initialization even in the class-wide case. For mutably tagged types, assign the tag unconditionally. (Make_Tag_Ctrl_Assignment): Deal with mutably tagged types. * exp_ch6.adb (Might_Have_Tasks): Invoke Has_Enabled_Aspect on the root type for a class-wide type. * exp_ch7.adb: Add clauses for Mutably_Tagged package. (Make_Adjust_Call): Deal with mutably tagged types. (Make_Final_Call): Likewise. (Make_Init_Call): Likewise. * exp_util.adb: Add clauses for Mutably_Tagged package. (Finalize_Address): Deal with mutably tagged types. (Make_CW_Equivalent_Type): Adjust comment. * freeze.adb (Freeze_Record_Type): Invoke Needs_Finalization on the type of the components to compute the Has_Controlled_Component flag. * mutably_tagged.ads (Get_Corresponding_Tagged_Type_If_Present): Adjust description. * mutably_tagged.adb (Is_Mutably_Tagged_CW_Equivalent_Type): Test Is_Mutably_Tagged_Type on the class-wide type of the parent subtype. * sem_ch3.adb (Find_Type_Name): Do not set the Is_Internal flag on the completion of an incomplete type. (Record_Type_Definition): Invoke Needs_Finalization on the type of the components to compute the Has_Controlled_Component flag. * sem_ch12.adb (Validate_Private_Type_Instance): Test the Is_Mutably_Tagged_Type flag instead of Class_Wide_Equivalent_Type. (Instantiate_Type): Likewise. * sem_util.adb (Needs_Finalization): Return False for a class-wide type if the root type has the No_Controlled_Parts aspect, and return True for a mutably tagged class-wide equivalent type unless the root type has the No_Controlled_Parts aspect.
This happens only when one of the operands is of a tagged type, because the handling of equality operators for tagged types is completely separate from that of equality operators for untagged types. But it turns out that this separate processing is intended to be used for symmetric equality operators only, so the fix is to redirect that of all asymmetric equality operators to the common processing instead. This also fixes a small glitch in this common processing, whereby a derived type would both inherit an implicit inequality operator from its parent type per the RM 6.6(6) rule and have another implicit inequality operator created from an equality operator inherited from its parent type. gcc/ada/ * exp_ch3.adb (Make_Predefined_Primitive_Eq_Spec): Fix pasto. * sem_ch4.adb (wpo): Also accept untagged types. * sem_ch6.adb (Make_Inequality_Operator): Also copy Is_Primitive. (New_Overloaded_Entity): Create the implicit inequality operator only for nonderived subprograms, but create it in the asymmetric case even for tagged types. Deal with the inheritance of such an implicit inequality operator. * sem_disp.adb: Add clauses for Stand. (Check_Dispatching_Operation): Bail out for inequality operators whose result type is Boolean.
This adds the same early return to Check_Return_Construct_Accessibility for static checks as the one present in Apply_Accessibility_Check_For_Return for dynamic checks. gcc/ada/ * accessibility.adb (Check_Return_Construct_Accessibility): Bail out for the return synthesized in a function whose body has been wrapped in a nested _Wrapped_Statements function.
…straint LRA correctly works for 'rm' constraint when register can not hold value of given mode. For 'g' constraint, LRA fails as it correctly considers the constraint can be satisfied but tries to use hard register which can not be in given mode. The patch fixes this. gcc/ChangeLog: PR rtl-optimization/127326 * lra-constraints.cc (process_alt_operands): Ignore register if constraint describes memory and register which can not hold the mode value. gcc/testsuite/ChangeLog: PR rtl-optimization/127326 * gcc.target/i386/pr127326.c: New.
The membership test is unreachable in the instance body. gcc/ada/ * sem_ch4.adb (Analyze_Membership_Op): Do not force an error to be given if the right operand is a Raise_Error node.
The expander already knows that special care must be taken for 'Valid in the presence of floating-point objects with reverse scalar storage order, but this was not done in this particular case. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference) <Attribute_Valid>: Call Is_Reverse_Storage_Order_Object to detect cases where a copy needs to be created for the prefix. * sem_util.ads (In_Reverse_Storage_Order_Object): Delete. (Is_Reverse_Storage_Order_Object): New predicate. * sem_util.adb (In_Reverse_Storage_Order_Object): Delete. (Is_Reverse_Storage_Order_Object): New predicate subsuming original In_Reverse_Storage_Order_Object predicate.
This attempts to make the various error messages given for failed static accessibility checks more consistent, by using a consistent "accessibility level of X is to deep" or "X has deeper accessibility level than" wording, augmented by a reference to the relevant rule of the Ada Reference Manual (latest version, in other words Ada 2022 with Amendment 1, when the rule is still present, otherwise the last version where the rule was present). The only exception is for illegal 'Access attribute references, where the existing "nonlocal access vs local object" viewpoint is preserved. gcc/ada/ * accessibility.adb (Accessibility_Message): Adjust wording. (Check_Return_Construct_Accessibility.Accessibility_Error): Ditto. * sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Likewise for the specific error message given for subprograms. * sem_ch3.adb (Analyze_Component_Declaration): Likewise for the specific error message given for access components. (Build_Derived_Record_Type): Add references to Ada 95 rules. * sem_ch6.adb (Analyze_Function_Return): Adjust wording for the error messages given for class-wide returns. * sem_ch9.adb (Analyze_Requeue): Likewise for requeue statements. * sem_ch13.adb (Analyze_Attribute_Definition_Clause) <Storage_Pool>: Add reference to Ada 2012 accessibility rule. * sem_res.adb (Resolve_Actuals.Check_Aliased_Parameter): Adjust wording for the error messages for actuals of aliased parameters. (Resolve_Allocator): Likewise for allocators. (Valid_Conversion): Likewise for conversions. (Valid_Array_Conversion): Add Opnd_Type parameter instead of using an up-level reference. gcc/testsuite/ * gnat.dg/access12.adb: Adjust error message. * gnat.dg/aliased3.adb: Likewise.
gcc/cobol/ChangeLog: * parse_ante.h (update_prior_invalid_field): Use is_figconst. (field_add): Always call update_prior_invalid_field.
The previous logic assumed that function 2 only returned the status information and program name for the program associated by cblte-gpi-handle. However, the documentation states function 2 must return the information from the caller program instead, also updating cblte-gpi-handle. [1] Therefore, the previous logic was flawed. For example, assuming program D allocates cblte-gpi-handle by calling function 0, and given the following call stack: A -> B -> C -> D It is then possible for function G, under the following call stack, to extract the call stack for D, one call to CBL_GET_PROGRAM_INFO at a time: A -> E -> F -> G Therefore, function 2 would return the information from function C on the first call, then F and so on, until returning a non-zero status code. [1]: https://docs.rocketsoftware.com/bundle/visualcoboldevhub_ug_110/page/lxm1742952203519.html libgcobol/ChangeLog: * compat/gnu/lib/cbl_gpi.cc (struct gpi_priv): Fix flawed logic. (getlastprog): Likewise. (callstack): Likewise. (cbl_gpi_cur_status): Likewise. (cbl_gpi_handle_status): Likewise. (cbl_gpi_parent_status): Likewise. (cbl_gpi_close_handle): Likewise. gcc/testsuite/ChangeLog: * cobol.dg/group2/CBL_GET_PROGRAM_INFO__get_program_name_-_functions_0_and_2_.cob: Update test to new behaviour. * cobol.dg/group2/CBL_GET_PROGRAM_INFO__get_program_name_-_functions_0_and_2_.out: Likewise.
This patch implements the local clause for omp declare target. The main effect is to avoid adding such 'local' variables to offload_vars in the middle/front ends. This effectively creates non-associated versions of the variable on the host/accel device. This is tested by modifying/returning the local-clause variable on the GPU, and testing if "omp target update" does NOT work. Internally, this is represented as an extension of the existing "omp declare target" attribute, with an additional "local" argument into TREE_VALUE(DECL_ATTRIBUTES(var)). This allows value_member() to work as expected when testing if "local" exists, while handling is the same as "omp declare target" in most places. gcc/c-family/ChangeLog: * c-pragma.h (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_LOCAL. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_name): Add "local" case. (c_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_LOCAL case. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_LOCAL. ( c_parser_omp_declare_target): Handle OMP_CLAUSE_LOCAL. * c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_LOCAL. Emit error if local clause variable appears in map clause. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_name): Add "local" case. (cp_parser_omp_all_clauses): Add PRAGMA_OMP_CLAUSE_LOCAL case. (handle_omp_declare_target_clause): Handle OMP_CLAUSE_LOCAL. (OMP_DECLARE_TARGET_CLAUSE_MASK): Add PRAGMA_OMP_CLAUSE_LOCAL. * semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_LOCAL. Emit error if local clause variable appears in map clause. gcc/fortran/ChangeLog: * openmp.cc (gfc_match_omp_declare_target): Adjust error handling to handle local clause. * trans-common.cc (build_common_decl): Adjust handling of device_type clause, remove sorry and FIXME of LOCAL clause, handle local clause. * trans-decl.cc (add_attributes_to_decl): Adjust handling of device_type clause, remove sorry of LOCAL clause, adjust creating of "omp declare target [link]" attribute between OpenACC/OpenMP. gcc/ChangeLog: * omp-offload.cc (omp_discover_implicit_declare_target): For self_maps/unified_shared_memory case, adjust to not convert 'omp declare target local' variables to 'link'. * tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_LOCAL. * tree.cc (omp_clause_num_ops): Add entry for OMP_CLAUSE_LOCAL. (omp_clause_code_name): Likewise. * varpool.cc (varpool_node::get_create): Do not add variable to offload_vars if "local" argument is present in "omp declare target". gcc/testsuite/ChangeLog: * c-c++-common/gomp/declare-target-1.c: Add local clause test. * c-c++-common/gomp/declare-target-8.c: New testcase. * gfortran.dg/gomp/declare-target-1.f90: Add local clause test. * gfortran.dg/gomp/declare-target-7.f90: New testcase. * gfortran.dg/gomp/groupprivate-2.f90: Adjust test. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/declare-target-local-1.c: New test. * testsuite/libgomp.c-c++-common/declare-target-local-2.c: New test. * testsuite/libgomp.c-c++-common/declare-target-local-3.c: New test. * testsuite/libgomp.c-c++-common/declare-target-local-4.c: New test. * testsuite/libgomp.fortran/declare-target-local-1.f90: New test.
When lowering a module-text two functions are synthesized: the one corresponding to the module's prelude and the one corresponding to the module's postlude. These declarations are artificial and need to be marke as such by setting DECL_ARTIFICIAL to 1. Signed-off-by: Jose E. Marchesi <jemarch@gnu.org> gcc/algol68/ChangeLog * a68-low.cc (lower_module_text): Mark prelude_decl an postlude_decl as artificial. gcc/testsuite/ChangeLog * algol68/compile/prepostlude-crash-1.a68: New test.
We can use deleted functions in C++98 mode if we use pragmas to disable the -Wc++11-extensions diagnostics. This works with both GCC and Clang. In some cases this makes the code more robust in C++98 mode because we were previously not making types copyable at all (e.g., _Reuse_or_alloc_node in bits/stl_tree.h) and just relying on testing in C++11 and later to know we didn't use those functions. In other cases it gives better diagnostics because we were defining copy constructors and assignment operators as private libstdc++-v3/ChangeLog: * config/io/basic_file_stdio.h (__basic_file): Define copy constructor and copy assignment operator as deleted for C++98. * include/bits/stl_bvector.h (vector<bool, A>::data): Define as deleted for C++98. * include/bits/stl_tree.h (_Reuse_or_alloc_node): Define copy constructor as deleted for C++98. * include/bits/stl_vector.h (_Asan<allocator<T>>::_Reinit): Define copy constructor and copy assignment operator as deleted for C++98. (_Asan<allocator<T>>::_Grow): Likewise. * testsuite/util/replacement_memory_operators.h (__gnu_test::counter::scope): Likewise. * testsuite/util/testsuite_iterators.h (operator,, operator&) (operator+=, operator-=, operator[]): Define deleted operators for C++98. Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Similar to nearbyint, floor, ceil, and trunc, use (v)roundp[sd] or vrndscalep[hsd] to vectorize calls to roundeven. gcc/ChangeLog: * config/i386/sse.md (roundeven<mode>2): New. gcc/testsuite/ChangeLog: * gcc.target/i386/avx-roundeven.c: New test. * gcc.target/i386/avx512f-roundeven.c: New test. * gcc.target/i386/avx512fp16-roundeven.c: New test. * gcc.target/i386/sse4_1-roundeven.c: New test. Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
Use the same VF cap in the AArch64 body-cost adjustment and in the main-loop comparison. Known fixed-trip loops can execute fewer lanes than the architectural VF. The body-cost path already wanted to account for that, but the main-loop comparison still used the uncapped VF. This made the two parts of the cost model rank the same loop differently. This factors the cap into a small helper and uses it in both places. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_vect_vf_for_cost): New function. (aarch64_vector_costs::adjust_body_cost): Use it. (aarch64_vector_costs::better_main_loop_than_p): Likewise.
Account for the real Adv.SIMD cost of SAD and ABD reductions. For SAD_EXPR, Adv.SIMD has to build a 128-bit result from two 64-bit halves. Account for that extra work when costing 128-bit Adv.SIMD vectors. For SAD-style ABD reductions, SVE can keep the byte absolute difference as uabd and then use udot for the widening sum. Without dot-product support, the Adv.SIMD fallback is a longer dependent sequence, using uabdl/uabal followed by the widening reduction. Charge that extra Adv.SIMD work in both the statement cost and the issue model, so scalar profitability and vector-loop comparison stay in sync. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_ifn_vect_stmt_p): New function. (aarch64_adjust_stmt_cost): Account for extra Adv.SIMD SAD and ABD reduction costs. (aarch64_vector_costs::count_ops): Likewise.
Fold integer VEC_UNPACK_LO_EXPR and VEC_UNPACK_HI_EXPR for suitable
variable-length VECTOR_CSTs.
The patch adds support for other _LO, _HI expressions but it's expected
that those be almost never use but the code unifies the VLA and VLS
paths.
The fixed-length case already folds. This extends the same idea to VLA
constants when the input has twice as many elements as the output and the
selected half can be represented as a valid VECTOR_CST. This helps fold
known predicate constants before RTL expansion, avoiding unnecessary
predicate unpack instructions.
The pattern should be a 1 or 2 alternatives repeating pattern in the
form of
{ a1,...,an,b1,...,bn,b1,...,bn,b1,...,bn,... }
where N == NPATTERNS and where ai == bi for NELTS_PER_PATTERN == 1
but not necessarily for NELTS_PER_PATTERN == 2.
This show up often with known iteration loops and folding these in gimple
allows us to fold away unrolled masks which end up being empty.
The selftests cover the foldable low/high cases and cases that should not
fold.
gcc/ChangeLog:
* fold-const.cc (const_unop): Fold VEC_UNPACK_LO_EXPR and
VEC_UNPACK_HI_EXPR for suitable variable-length VECTOR_CSTs.
(selftest::test_vec_unpack_folding): New function.
(selftest::fold_const_cc_tests): Call it.
…599] For null pointer to data member we use INTEGER_CST with OFFSET_TYPE and -1 value. When that is printed in diagnostics or in display_string_of, it is printed as -1, which is confusing to users and an implementation detail (well, part of ABI https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers A null data member pointer is represented as an offset of -1. ). Now, as the first testcase shows, if we have a non-null pointer to data member constant, it is actually PTRMEM_CST and is printed in a user-friendly way, the following patch just arranges to print the OFFSET_TYPE -1 INTEGER_CST similarly. 2026-09-23 Jakub Jelinek <jakub@redhat.com> PR c++/126599 * error.cc (dump_expr): Print OFFSET_TYPE -1 differently. * g++.dg/diagnostic/ptrtomem5.C: New test. * g++.dg/diagnostic/ptrtomem6.C: New test. * g++.dg/reflect/display_string_of1.C: Add 2 new tests. * g++.dg/reflect/u8display_string_of1.C: Likewise. Reviewed-by: Jason Merrill <jason@redhat.com>
The following testcase is incorrectly rejected on lp64 targets. The bug is that unify_array_domain uses forcefully integer_type_node/integer_one_node to add 1 to parm_max or arg_max, regardless of the type it has. From playing with testcases, at least arg_max seems to be pretty much always sizetype/size_t. 2026-09-23 Jakub Jelinek <jakub@redhat.com> PR c++/125536 * pt.cc (unify_array_domain): When adding 1 to parm_max or arg_max, perform the addition in the type of those trees rather than unconditionally in int type. * g++.dg/template/unify14.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
As the following testcase shows, error_mark_node can appear anywhere in the ctors, and with the asserts we ICE on those during error recovery. The following patch just returns error_mark_node in those cases. 2026-09-23 Jakub Jelinek <jakub@redhat.com> PR c++/127506 * constexpr.cc (is_within_lifetime): When val is error_mark_node, return it. * g++.dg/cpp26/within-lifetime13.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
…minants The problem is that the Has_Constrained_Partial_View flag is not inherited by derived types. Since it is set both on the partial and full views, both Build_Derived_Private_Type and Build_Derived_Record_Type need to be fixed. gcc/ada/ * sem_ch3.adb (Build_Derived_Private_Type): In the case where the partial view has none but the full view has discriminants, do not set again the Etype, propagate the Has_Constrained_Partial_View flag from the parent base type and the Is_Constrained flag from the partial view of the parent type. (Build_Derived_Record_Type): Propagate Has_Constrained_Partial_View from the parent base type.
This just adds a cut-off for broken subunits. gcc/ada/ * sem_elab.adb (Invocation_Graph.Process_Package_Declaration): Add cut-off for broken subunits.
The wrong name is passed to Generate_Reference from Resolve_Entry. gcc/ada/ * sem_res.adb (Resolve_Entry): Fix thinko.
This just adds a missing guard. gcc/ada/ * sem_res.adb (Resolve_Membership_Op): Add guard for generic type to the test on the RM size.
This occurs for the argument of pragma Assert, Check, Loop_Invariant, etc. The testcase trips on another issue for the renaming of a reference to the 'Old attribute, which is fixed by removing essentially unused code. gcc/ada/ * sem_ch8.adb (Get_Object_Name): Delete. (Analyze_Object_Renaming): Use Is_Entity_Name to detect names. * sem_prag.adb (Analyze_Pragma) <Pragma_Assert>: Detect ill-formed quantified expressions and give an error. <Pragma_Check>: Likewise. * sem_res.ads (Malformed_Quantified_Expression): New procedure. * sem_res.adb (Malformed_Quantified_Expression): Likewise. (Resolve): Call Malformed_Quantified_Expression to give the error about ill-formed quantified expressions.
The view conversion is constrained when its operand object is constrained. gcc/ada/ * checks.adb (Apply_Discriminant_Check): Build the actual subtype of the LHS for a view conversion of a constrained object.
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (ParamType::clone): add guard Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This patch fixes hanlding of substitutions of nested generics by taking into account the already used arguments in the adjust call. For example GenericSplitN< Split <T,P>> Fixes #4884 gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (normalize_projection): resolve through super traits * typecheck/rust-typecheck-context.cc: disable infer for trait-self * typecheck/rust-tyty-subst.cc: reuse to handle nested arguments * typecheck/rust-unify.cc (UnifyRules::go): relax infer on adts gcc/testsuite/ChangeLog: * rust/compile/generic-type-alias-subst-bug.rs: New test. * rust/compile/issues/4884.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Fixes #4918 gcc/rust/ChangeLog: * typecheck/rust-coercion.cc (TypeCoercionRules::TryCoerce): add flag (TypeCoercionRules::TypeCoercionRules): Likewise. (TypeCoercionRules::do_coercion): Likewise. (TypeCoercionRules::coerce_unsafe_ptr): Likewise. (TypeCoercionRules::coerce_borrowed_pointer): Likewise. (TypeCoercionRules::select): Likewise. * typecheck/rust-coercion.h: Likewise. * typecheck/rust-hir-dot-operator.cc (MethodResolver::try_select_predicate_candidates): Likewise. * typecheck/rust-type-util.cc (unify_site_and): Likewise. * typecheck/rust-type-util.h (unify_site_and): Likewise. * typecheck/rust-unify.cc (UnifyRules::UnifyRules): Likewise. (UnifyRules::Resolve): Likewise. (UnifyRules::resolve_subtype): Likewise. (UnifyRules::expect_never): Likewise. * typecheck/rust-unify.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/issues/4918.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This patch is used to address where constraints on projections for example
fn test<P: Deref)
where
P::Target: PartialOrd<Q::Target>
When we do fn test<P: Deref) we can specify the bound of Deref on P directly so its directly
available. But when we do where P::Target ... that P::Target resolves the trait position
Target of Deref but thats a trait position decl so this information is lost during path
resolution. This patch addes a scan so when we generate predicates we track them in the
type check context so we can look them up so it adds a loop to get any other associcated
predicates in this position. Its not performant but we can fix that later we just need
to progress libcore for now.
Fixes #4865
gcc/rust/ChangeLog:
* typecheck/rust-hir-dot-operator.cc (MethodResolver::try_hook): use new helper
* typecheck/rust-hir-path-probe-expr.cc (PathProbeExpr::probe_bounds): likewise
* typecheck/rust-hir-path-probe-type.cc (TypePathProbe::probe_generic): likewise
* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): likewise
(TypeResolveGenericParam::apply_trait_bounds): track new decl id
* typecheck/rust-hir-type-check.h: new helper
* typecheck/rust-typecheck-context.cc (TypeCheckContext::predicates_for_type): impl
* typecheck/rust-tyty.cc (ParamType::ParamType): new decl id
(ParamType::clone): likewise
* typecheck/rust-tyty.h: likewise
gcc/testsuite/ChangeLog:
* rust/compile/issues/4865-1.rs: New test.
* rust/compile/issues/4865-2.rs: New test.
* rust/compile/projection-bound-decl-id.rs: New test.
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Fixes #4912 gcc/rust/ChangeLog: * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): add missing gcc/testsuite/ChangeLog: * rust/compile/issues/4912.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Fixes #4911 gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-base.cc (walk_type_to_constrain): walk binding args gcc/testsuite/ChangeLog: * rust/compile/issues/4911.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
This is replaced with -frust-compat-version=<1.64 instead. gcc/rust/ChangeLog: * lang.opt: Remove frust-c-style-string-literals option. * rust-session-manager.h (Session): New should_support_cstr_parsing function. * parse/rust-parse-impl-expr.hxx (Parser<ManagedTokenSource>::parse_literal_expr): Replace old flag_c_style_string_literals check with should_support_cstr_parsing. (Parser<ManagedTokenSource>::null_denotation_not_path): Likewise. * parse/rust-parse.h: Import rust-session-manager.h to access Session class. gcc/testsuite/ChangeLog: * rust/compile/c_string_null_byte_check.rs: Remove frust-c-style-string-literals from compilation options. * rust/execute/torture/c_string_ensure_null_term.rs: Likewise. * rust/execute/torture/c_string.rs: Likewise. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
Functions without bodies can have different parameters with the same name. gcc/rust/ChangeLog: * resolve/rust-late-name-resolver-2.0.cc (Late::Late): Initialize in_bodyless_params. (Late::visit (FunctionParam)): New function definition, skip visiting the patterns of function parameters on bodyless functions. (Late::visit_function_params): Set in_bodyless_params. * resolve/rust-late-name-resolver-2.0.h (Late::visit (FunctionParam)): New function declaration. (Late::in_bodyless_params): New member variable. gcc/testsuite/ChangeLog: * rust/compile/multiple_bindings3.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Fn/FnMut/FnOnce bounds can produce FUNCTION segments, which new_type_param did not handle. Use reconstruct() for these segments instead of hitting rust_unreachable(). Fixes #3939 gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::new_type_param): Handle FUNCTION segments. gcc/testsuite/ChangeLog: * rust/compile/issues/3939.rs: New test. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit (Function)): Emit error on complex patterns in non-extern bodyless functions as well. gcc/testsuite/ChangeLog: * rust/compile/function-param-bodyless.rs: New test. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
The corrected atomic store & load intrinsics were using post-1.64.0 namings, this patch just adds back the 1.49.0 namings for the wrongly named intrinsics. gcc/rust/ChangeLog: * util/rust-intrinsic-values.h (Rust::Values::Intrinsics): Add entries for atomic_store, atomic_store_rel, atomic_load, atomic_load_acq. * backend/rust-compile-intrinsic.cc (generic_intrinsics): Likewise. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
gcc/testsuite/ChangeLog: * rust/core/core.exp: Switch from testing core until lowering to testing core until typecheck.
This should make it easier to upgrade libraries when we bump the target rustc version. libgrust/ChangeLog: * rustc-lib/version-info: Regenerate, now mentions stdarch. * contrib/vendor-libs.sh: New file. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
HIR mappings are getting bigger, this commit attempts to regroup crate related mappings within a single class. gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): Use sub category. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::get_unit_type): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_module_path): Likewise. * expand/rust-macro-substitute-ctx.cc: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Likewise. (ASTLoweringBase::lower_loop_label): Likewise. (ASTLoweringBase::lower_path_expr_seg): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::lower_extern_block): Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise. (ASTLoweringSimplePath::lower): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::desugar_iflet): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLowerPathInExpression::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::gather_export_data): Likewise. (PublicInterface::write_to_object_file): Likewise. (PublicInterface::write_to_path): Likewise. (PublicInterface::expected_metadata_filename): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-forever-stack.h: Likewise. * resolve/rust-name-resolution-context.h: Likewise. * rust-session-manager.cc (Session::handle_crate_name): Likewise. (Session::compile_crate): Likewise. (Session::load_extern_crate): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::resolve_function_signature): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context): Likewise. * typecheck/rust-tyty-util.cc (TyVar::monomorphized_clone): Likewise. * typecheck/rust-tyty.cc (InferType::clone): Likewise. (ConstInferType::clone): Likewise. * util/rust-hir-map.cc (CrateMappings::CrateMappings): Add a new specialized class to keep all crate related mappings. (Mappings::Mappings): Move some member functions to CrateMappings. (Mappings::get_next_crate_num): Likewise. (CrateMappings::get_next_crate_num): Likewise. (Mappings::set_current_crate): Likewise. (CrateMappings::set_current_crate): Likewise. (Mappings::get_current_crate): Likewise. (CrateMappings::get_current_crate): Likewise. (Mappings::get_crate_name): Likewise. (CrateMappings::get_crate_name): Likewise. (Mappings::lookup_crate_num): Likewise. (CrateMappings::lookup_crate_num): Likewise. (Mappings::set_crate_name): Likewise. (CrateMappings::set_crate_name): Likewise. (Mappings::get_current_crate_name): Likewise. (CrateMappings::get_current_crate_name): Likewise. (Mappings::lookup_crate_name): Likewise. (CrateMappings::lookup_crate_name): Likewise. (Mappings::crate_num_to_nodeid): Likewise. (CrateMappings::crate_num_to_nodeid): Likewise. (Mappings::node_is_crate): Likewise. (CrateMappings::node_is_crate): Likewise. (Mappings::get_ast_crate): Likewise. (CrateMappings::get_ast_crate): Likewise. (Mappings::get_ast_crate_by_node_id): Likewise. (Mappings::get_ast_crate_by_node_id_raw): Likewise. (CrateMappings::get_ast_crate_by_node_id_raw): Likewise. (Mappings::insert_ast_crate): Likewise. (CrateMappings::insert_ast_crate): Likewise. (Mappings::insert_macro_def): Likewise. (Mappings::insert_glob_container): Likewise. * util/rust-hir-map.h (class Mappings): Move some declarations from here... (class CrateMappings): ...to here. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
HIR map is getting bigger and harder to use. This commit regroup all proc macro related operations under one subclass. gcc/rust/ChangeLog: * expand/rust-macro-expand.h (struct MacroExpander): Use new macro category. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Likewise. (Early::visit_non_builtin_attribute): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit_extern_crate): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::insert_derive_proc_macros): Move to specialized macro class declartion. (Mappings::insert_bang_proc_macros): Move from here... (ProcMacroMappings::insert_bang_proc_macros): ... to here. (Mappings::insert_attribute_proc_macros): Likewise. (Mappings::lookup_derive_proc_macros): Likewise. (ProcMacroMappings::lookup_derive_proc_macros): Likewise. (Mappings::lookup_bang_proc_macros): Likewise. (ProcMacroMappings::lookup_bang_proc_macros): Likewise. (Mappings::lookup_attribute_proc_macros): Likewise. (ProcMacroMappings::lookup_attribute_proc_macros): Likewise. (Mappings::insert_derive_proc_macro_def): Likewise. (ProcMacroMappings::insert_derive_proc_macro_def): Likewise. (Mappings::insert_bang_proc_macro_def): Likewise. (ProcMacroMappings::insert_bang_proc_macro_def): Likewise. (Mappings::insert_attribute_proc_macro_def): Likewise. (ProcMacroMappings::insert_attribute_proc_macro_def): Likewise. (Mappings::lookup_derive_proc_macro_def): Likewise. (ProcMacroMappings::lookup_derive_proc_macro_def): Likewise. (Mappings::lookup_bang_proc_macro_def): Likewise. (ProcMacroMappings::lookup_bang_proc_macro_def): Likewise. (Mappings::lookup_attribute_proc_macro_def): Likewise. (ProcMacroMappings::lookup_attribute_proc_macro_def): Likewise. (Mappings::insert_derive_proc_macro_invocation): Likewise. (Mappings::lookup_derive_proc_macro_invocation): Likewise. (ProcMacroMappings::lookup_derive_proc_macro_invocation): Likewise. (Mappings::insert_bang_proc_macro_invocation): Likewise. (Mappings::lookup_bang_proc_macro_invocation): Likewise. (Mappings::insert_attribute_proc_macro_invocation): Likewise. (Mappings::lookup_attribute_proc_macro_invocation): Likewise. * util/rust-hir-map.h (class ProcMacroMappings): Add specialized class for macro mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Those functions are part of a proc macro context and no longer require an explicit long name about their context. gcc/rust/ChangeLog: * expand/rust-macro-expand.h (struct MacroExpander): Apply new name. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Likewise. (Early::visit_non_builtin_attribute): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit_extern_crate): Likewise. * util/rust-hir-map.cc (ProcMacroMappings::insert_bang_proc_macros): Use new member name. (ProcMacroMappings::lookup_derive_proc_macros): Likewise. (ProcMacroMappings::lookup_bang_proc_macros): Likewise. (ProcMacroMappings::lookup_attribute_proc_macros): Likewise. (ProcMacroMappings::insert_derive_proc_macro_def): Likewise. (ProcMacroMappings::insert_derive_def): Likewise. (ProcMacroMappings::insert_bang_proc_macro_def): Likewise. (ProcMacroMappings::insert_bang_def): Likewise. (ProcMacroMappings::insert_attribute_proc_macro_def): Likewise. (ProcMacroMappings::insert_attribute_def): Likewise. (ProcMacroMappings::lookup_derive_proc_macro_def): Likewise. (ProcMacroMappings::lookup_derive_def): Likewise. (ProcMacroMappings::lookup_bang_proc_macro_def): Likewise. (ProcMacroMappings::lookup_bang_def): Likewise. (ProcMacroMappings::lookup_attribute_proc_macro_def): Likewise. (ProcMacroMappings::lookup_attribute_def): Likewise. (ProcMacroMappings::insert_derive_invocation): Likewise. (ProcMacroMappings::lookup_derive_proc_macro_invocation): Likewise. (ProcMacroMappings::lookup_derive_invocation): Likewise. (ProcMacroMappings::insert_bang_invocation): Likewise. (ProcMacroMappings::lookup_bang_invocation): Likewise. (ProcMacroMappings::insert_attribute_invocation): Likewise. (ProcMacroMappings::lookup_attribute_invocation): Likewise. * util/rust-hir-map.h (class ProcMacroMappings): Rename member maps as well as some functions to remove the proc macro mention. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Rust hir map is too big, regroup some of ast item mappings within a specialized class. gcc/rust/ChangeLog: * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::check_violation_inner): Use ast category. * checks/errors/privacy/rust-pub-restricted-visitor.cc (PubRestrictedVisitor::is_restriction_valid): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::go): Likewise. (VisibilityResolver::resolve_and_update): Likewise. (VisibilityResolver::visit): Likewise. * util/rust-hir-map.cc (Mappings::insert_visibility): Move to ASTMappings. (Mappings::lookup_visibility): Likewise. * util/rust-hir-map.h (class ASTMappings): Add a mapping class dedicated to mapping an id to an Item. Add a specialized ASTMappings class to hold all ast related mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
HIR map is getting bigger and most lookup/insert functions are similar, this commit regroup all simple HIR related mappings under one field. gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): Use new hir category. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_module_path): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::check_function_call): Likewise. * checks/errors/rust-readonly-check.cc (ReadonlyChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static): Likewise. (UnsafeChecker::check_function_call): Likewise. (UnsafeChecker::check_function_attr): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. * checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_extern_block): Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLoweringType::translate): Likewise. (ASTLowerGenericParam::translate): Likewise. * hir/rust-ast-lower.cc (ASTLowerPathInExpression::visit): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * hir/tree/rust-hir-pattern-abstract.cc (PathPattern::is_refutable): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_item): Move to dedicated mappings within the hir category. (Mappings::lookup_hir_item): Likewise. (Mappings::insert_hir_trait_item): Likewise. (Mappings::lookup_hir_trait_item): Likewise. (Mappings::insert_hir_extern_block): Likewise. (Mappings::lookup_hir_extern_block): Likewise. (Mappings::insert_module): Likewise. (Mappings::lookup_module): Likewise. (Mappings::insert_hir_expr): Likewise. (Mappings::lookup_hir_expr): Likewise. (Mappings::insert_hir_path_expr_seg): Likewise. (Mappings::lookup_hir_path_expr_seg): Likewise. (Mappings::insert_hir_generic_param): Likewise. (Mappings::lookup_hir_generic_param): Likewise. (Mappings::insert_hir_type): Likewise. (Mappings::lookup_hir_type): Likewise. (Mappings::insert_hir_stmt): Likewise. (Mappings::lookup_hir_stmt): Likewise. (Mappings::insert_hir_param): Likewise. (Mappings::lookup_hir_param): Likewise. (Mappings::insert_hir_self_param): Likewise. (Mappings::lookup_hir_self_param): Likewise. (Mappings::insert_hir_struct_field): Likewise. (Mappings::lookup_hir_struct_field): Likewise. (Mappings::insert_hir_pattern): Likewise. (Mappings::lookup_hir_pattern): Likewise. (Mappings::resolve_nodeid_to_stmt): Likewise. (Mappings::build_impl_indexes): Likewise. (Mappings::insert_trait_item_mapping): Likewise. * util/rust-hir-map.h (class HIRMappings): Add new class for all hir related mappings. * util/rust-hir-map.hxx: New file. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Rename pmacro_mappings and crate_mappings to pmacro and crate respectively to stay consistent with the other members name. gcc/rust/ChangeLog: * ast/rust-collect-lang-items.cc (CollectLangItems::visit): Adapt name at call site. * backend/rust-compile-expr.cc: Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::get_unit_type): Likewise. * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_module_path): Likewise. * expand/rust-macro-expand.h (struct MacroExpander): Likewise. * expand/rust-macro-substitute-ctx.cc: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_lifetime): Likewise. (ASTLoweringBase::lower_loop_label): Likewise. (ASTLoweringBase::lower_path_expr_seg): Likewise. (ASTLoweringBase::lower_self): Likewise. (ASTLoweringBase::lower_extern_block): Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-enumitem.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * hir/rust-ast-lower-extern.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise. (ASTLoweringSimplePath::lower): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise. * hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise. (ASTLowerQualifiedPathInType::visit): Likewise. (ASTLoweringType::visit): Likewise. (ASTLowerGenericParam::visit): Likewise. (ASTLoweringTypeBounds::visit): Likewise. (ASTLowerWhereClauseItem::visit): Likewise. * hir/rust-ast-lower.cc (ASTLowering::go): Likewise. (ASTLoweringBlock::visit): Likewise. (ASTLoweringIfBlock::visit): Likewise. (ASTLoweringIfLetBlock::desugar_iflet): Likewise. (ASTLoweringIfLetBlock::visit): Likewise. (ASTLowerStructExprField::visit): Likewise. (ASTLoweringExprWithBlock::visit): Likewise. (ASTLowerPathInExpression::visit): Likewise. (ASTLoweringBase::lower_qual_path_type): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * metadata/rust-export-metadata.cc (PublicInterface::gather_export_data): Likewise. (PublicInterface::write_to_object_file): Likewise. (PublicInterface::write_to_path): Likewise. (PublicInterface::expected_metadata_filename): Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Likewise. (Early::visit_non_builtin_attribute): Likewise. * resolve/rust-forever-stack.h: Likewise. * resolve/rust-name-resolution-context.h: Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit_extern_crate): Likewise. * rust-session-manager.cc (Session::handle_crate_name): Likewise. (Session::compile_crate): Likewise. (Session::load_extern_crate): Likewise. * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::resolve_literal): Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_fn_trait_call): Likewise. * typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise. (TypeCheckImplItem::resolve_function_signature): Likewise. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Likewise. * typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::resolve): Likewise. * typecheck/rust-hir-type-check.cc (TraitItemReference::get_type_from_fn): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * typecheck/rust-tyty-bounds.cc: Likewise. * typecheck/rust-tyty-subst.cc (SubstitutionParamMapping::override_context): Likewise. * typecheck/rust-tyty-util.cc (TyVar::monomorphized_clone): Likewise. * typecheck/rust-tyty.cc (InferType::clone): Likewise. (VariantDef::clone): Likewise. (VariantDef::monomorphized_clone): Likewise. (ConstInferType::clone): Likewise. * util/rust-hir-map.cc (Mappings::get_ast_crate_by_node_id): Likewise. (Mappings::insert_macro_def): Likewise. (Mappings::insert_glob_container): Likewise. * util/rust-hir-map.h: Rename pmacro_mappings to pmacro and crate_mappings to crate. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
When using those mappings, the singular name feels weird and may deceive a developper. gcc/rust/ChangeLog: * backend/rust-compile-item.cc (CompileItem::visit): Adapt call name. * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::resolve_module_path): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::check_function_call): Likewise. * checks/errors/rust-readonly-check.cc (ReadonlyChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static): Likewise. (UnsafeChecker::check_function_call): Likewise. (UnsafeChecker::check_function_attr): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. * checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit): Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_extern_block): Likewise. * hir/rust-ast-lower-block.h: Likewise. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::visit): Likewise. (ASTLowerTraitItem::translate): Likewise. (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise. (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate): Likewise. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::translate): Likewise. * hir/rust-ast-lower-struct-field-expr.h: Likewise. * hir/rust-ast-lower-type.cc (ASTLoweringType::translate): Likewise. (ASTLowerGenericParam::translate): Likewise. * hir/rust-ast-lower.cc (ASTLowerPathInExpression::visit): Likewise. (ASTLowerQualPathInExpression::visit): Likewise. * hir/tree/rust-hir-pattern-abstract.cc (PathPattern::is_refutable): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::visit): Likewise. (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::resolve_nodeid_to_stmt): Likewise. (Mappings::build_impl_indexes): Likewise. (Mappings::insert_trait_item_mapping): Likewise. * util/rust-hir-map.h: Change HIR mapping name to their plural counterpart. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Some mapping getters were using the crate num for their key, just like any other mapping within the CrateMappings. Move them over there for consistency. Also modifies the crate mapping name to make use of the Mapping class instead of relying on separate insert/lookup function implementation. gcc/rust/ChangeLog: * checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go): Update function call name. * expand/rust-macro-substitute-ctx.cc: Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit_extern_crate): Likewise. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (CrateMappings::get_next_crate_num): Likewise. (CrateMappings::get_crate_name): Remove. (CrateMappings::set_crate_name): Remove. (CrateMappings::get_current_crate_name): Update with new lookup function. (CrateMappings::lookup_crate_name): Use internal storage getter. (ProcMacroMappings::insert_bang_proc_macros): Remove. (ProcMacroMappings::lookup_derive_proc_macros): Remove. (ProcMacroMappings::lookup_bang_proc_macros): Remove. (ProcMacroMappings::lookup_attribute_proc_macros): Remove. * util/rust-hir-map.h (enum class): Move enum. (class Mapping): Add a getter to const storage in order to allow iteration on existing mappings. Also add a const getter. (class CrateMappings): Add proc macro crate mappings. Convert crate_name getter/setter to Mapping. (class ProcMacroMappings): Remove crate related mappings. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Put macro invocations and definitions in their own container and reuse the Mapping infrastructure. gcc/rust/ChangeLog: * expand/rust-macro-expand.h (struct MacroExpander): Update call name. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Likewise. (Early::visit_non_builtin_attribute): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit_extern_crate): Likewise. * util/rust-hir-map.cc (ProcMacroMappings::insert_derive_def): Remove. (ProcMacroMappings::insert_bang_def): Remove. (ProcMacroMappings::insert_attribute_def): Remove. (ProcMacroMappings::lookup_derive_def): Remove. (ProcMacroMappings::lookup_bang_def): Remove. (ProcMacroMappings::lookup_attribute_def): Remove. (ProcMacroMappings::insert_derive_invocation): Remove. (ProcMacroMappings::lookup_derive_invocation): Remove. (ProcMacroMappings::insert_bang_invocation): Remove. (ProcMacroMappings::lookup_bang_invocation): Remove. (ProcMacroMappings::insert_attribute_invocation): Remove. (ProcMacroMappings::lookup_attribute_invocation): Remove. * util/rust-hir-map.h (class ProcMacroMappings): Convert to struct. (struct ProcMacroDefinitionMappings): Add definition mappings. (struct ProcMacroInvocationsMappings): Add invocation mappings. (struct ProcMacroMappings): Use two new separate fields for definitions and invocations. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Most variables in the rust front end use snake case instead of camel case. Also rename the ast_crate_mapping variable given we already are in a mapping context. gcc/rust/ChangeLog: * util/rust-hir-map.cc (CrateMappings::CrateMappings): Update variable name at call site. (CrateMappings::get_next_crate_num): Likewise. (CrateMappings::set_current_crate): Likewise. (CrateMappings::get_current_crate): Likewise. (CrateMappings::get_ast_crate): Likewise. (CrateMappings::get_ast_crate_by_node_id_raw): Likewise. (CrateMappings::insert_ast_crate): Likewise. * util/rust-hir-map.h (class CrateMappings): Rename variables. Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-gate.cc (FeatureGate::visit): Add missing call to default visitor for ExternType items.
Gate derive(CoercePointee) behind `#![feature(derive_coerce_pointee)` and start adding the infrastructure required to support it. Warn that it doesn't do anything yet. gcc/rust/ChangeLog: * checks/errors/feature/rust-feature-defs.h (FEATURE_ACTIVE): New feature. * expand/rust-derive.cc (DeriveVisitor::derive): Add base handling for CoercePointee derive. * expand/rust-macro-builtins.cc: Add CoercePointee as a built-in derive * expand/rust-macro-builtins.h (enum class): Likewise. * resolve/rust-early-name-resolver-2.0.cc (Early::visit_derive_attribute): Special case derive(CoercePointee). * rust-session-manager.h (should_support_coerce_pointee): New method. * expand/rust-derive-coerce-pointee.cc: New file. * expand/rust-derive-coerce-pointee.h: New file. * Make-lang.in: Compile it. gcc/testsuite/ChangeLog: * rust/compile/derive-coerce-pointee1.rs: New test. * rust/compile/derive-coerce-pointee2.rs: New test. * rust/compile/derive-coerce-pointee3.rs: New test.
Rust rejects overflow in const eval for signed and unsigned alike, but GCC only sets TREE_OVERFLOW for signed ops, so unsigned just wrapped silently. The signed case did get caught, but only after folding, against an INTEGER_CST that carries no location - hence the locationless error. So build arithmetic with build2_loc instead of folding it right away. The const folder then sees the operation and its operands, and can report overflow on both signednesses with a proper location. gcc/rust/ChangeLog: * rust-gcc.cc (arithmetic_or_logical_expression): Use build2_loc instead of fold_build2_loc. * backend/rust-constexpr.cc (eval_check_overflow_p): New function. (eval_binary_expression): Use it. gcc/testsuite/ChangeLog: * rust/compile/const_overflow_unsigned.rs: Rewrite for E0080. * rust/compile/const_overflow_signed.rs: New test. * rust/compile/torture/arrays5.rs: Require lp64 target. * rust/compile/torture/arrays6.rs: Likewise. Signed-off-by: Utkarsh Bahuguna <utkarshbahuguna10@gmail.com>
…se/2026-09-29 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.
Member
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a sync with upstream GCC:
upstream GCC revision: d9d9012
gccrs github: 1f3ce07
-- gerris 🦀