Sync with upstream (2026-01-10): 00b6346d5374efab8dabbf99d2647ad69b1df706 #4371
Merged
Sync with upstream (2026-01-10): 00b6346d5374efab8dabbf99d2647ad69b1df706
#4371
Conversation
The error messages displayed in the modified example were changed in GNAT a while ago, but the example itself had not been updated. This patch also tweaks the reStructuredText markup in the example. gcc/ada/ChangeLog: * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Update example. * gnat-style.texi: Regenerate. * gnat_ugn.texi: Regenerate.
Instead of detecting exceptions by inlined ghost function calls we simply prevent ghost functions from being inlined. This change only affects SPARK. gcc/ada/ChangeLog: * inline.adb (Build_Body_To_Inline): Do not inline ghost functions.
This streamlines the code in the callers. No functional changes. gcc/ada/ChangeLog: * exp_ch9.ads (Build_Task_Allocate_Block): Change to function and remove first formal parameter. * exp_ch9.adb (Build_Task_Allocate_Block): Likewise. Return an anonymous list of nodes. * exp_aggr.adb (Convert_Aggr_In_Allocator): Adjust to above change. * exp_ch4.adb (Expand_N_Allocator): Likewise. * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.
…e component The predicate check may cause the creation of a temporary when it is applied to a function call and the temporary will be finalized, so any assignment of the temporary must be followed by an adjustment of the target. gcc/ada/ChangeLog: * exp_ch5.adb (Expand_N_Assignment_Statement): If a predicate check made on the RHS forced the capture of a function call to remove its side effects, demote No_Ctrl_Actions into No_Finalize_Actions on the N_Assignment_Statement node.
…iminants Before this patch, the compiler rejected record representation clauses when a component has a subtype with a non-static discriminant constraint. This is a somewhat coarse-grained since the size of such a component can be constant relatively to the discriminant. One such case in particular is when the component subtype is an unchecked union. This patch makes the compiler accept the unchecked union case. gcc/ada/ChangeLog: * freeze.adb (Size_Known): Modify rejection condition.
A recent change removed rewriting of address of a slice into address of first component of a slice. Now we need to explicitly detect overlying with slices. Together, both changes cause warnings to be emitted when slice of a constant object is overlaid by a variable. gcc/ada/ChangeLog: * sem_util.adb (Find_Overlaid_Entity): Detect overlying with slice.
The Ultimate_Overlaid_Entity function should return the root of the last precisely supported address clause as per the definition in the SPARK RM. gcc/ada/ChangeLog: * sem_util.ads (Overlaid_Entity): Return the root of the address clause of an object if it is precisely supported in SPARK. * sem_util.adb (Ultimate_Overlaid_Entity): Use Overlaid_Entity to match the SPARK RM semantics. * sem_prag.adb (Analyze_Global_Item): Only check for overlays on variables. (Analyze_Initialization_Item): Likewise. (Analyze_Input_Item): Likewise.
The Move_Activation_Chain routine is not available in all runtime libraries. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_N_Extended_Return_Statement): Do not call Move_Activation_Chain if it is not available in the runtime library.
We should avoid the check if the called entity cannot have formals gcc/ada/ChangeLog: * einfo-utils.adb (Can_Have_Formals): New function for checking if the entity can support formals. * einfo-utils.ads (Can_Have_Formals): Likewise. * ghost.adb (Check_Procedure_Call_Argument_Levels): Avoid checking the type of the formal if the called entity cannot hold formals.
The frontend reports a spurious warning when the type of some component of an untagged record type is a private record type that has an user-defined equality operator and the sources are compiled enabling warnings for ignored equality operators (that is, switch -gnatdw_q). The warning is spurious because it must not be reported when the full type declaration of the private type is a record type. gcc/ada/ChangeLog: * exp_ch3.adb (Build_Untagged_Record_Equality): Add missing support for incomplete and private types.
A SPARK RM rule 7.1.2(14) about Async_Writes being implicitly initialized is now removed; adjust references to subsequent rules in comments. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): Adjust references in comments for pragma Side_Effects and Volatile_Function.
Before this patch, procedures of the form "T'Constructor" without separate specs were incorrectly accepted in some cases. This patch fixes the issue. gcc/ada/ChangeLog: * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Check direct attribute definitions for specs.
The hook moniker is an obsolete reference to the previous implementation of object finalization, which used hooks (and counters) to manage the objects. gcc/ada/ChangeLog: * exp_util.ads (Find_Hook_Context): Rename to... (Find_Master_Context): ...this and alphabetize. * exp_util.adb (Find_Master_Context): Rename to... (Find_Master_Context): ...this and alphabetize. * exp_ch4.adb (Insert_Conditional_Object_Declaration): Adjust to above renaming. (Process_Transients_In_Expression): Likewise.
This updates the gnat-llvm debugging documentation to reflect the current status. gcc/ada/ChangeLog: * doc/gnat_ugn/building_executable_programs_with_gnat.rst (GNATLLVM): Update debugging documentation. * gnat_ugn.texi: Regenerate.
This patch replaces aspect-based version of the destructors extension with a new version that uses the "direct attribute definition" syntax that was recently introduced by the constructors extension. gcc/ada/ChangeLog: * snames.ads-tmpl: Make "Destructor" an attribute name. * snames.adb-tmpl: Allow direct attribute definition for Destructor. * gen_il-fields.ads (Destructor): New field. (Is_Destructor): Remove. * gen_il-gen-gen_entities.adb: (Destructor): New field. (Is_Destructor): Remove. * einfo.ads (Destructor): Document new field. (Is_Destructor): Remove documentation. * aspects.ads (Aspect_Destructor): Remove. * exp_attr.adb (Expand_N_Attribute_Reference): Adapt after aspect removal. * exp_ch7.adb (Build_Finalize_Statements): Adapt to new destructor representation. * freeze.adb (Freeze_Entity): Remove obsolete check. * sem_attr.adb (Analyze_Attribute, Eval_Attribute): Adapt to new attribute. * sem_ch13.adb (Analyze_Aspect_Specifications, Check_Aspect_At_End_Of_Declarations): Adapt after aspect removal. * sem_ch6.adb (Analyze_Direct_Attribute_Definition): Add handling of Destructor attribute. (Can_Be_Destructor_Of): New function. * doc/gnat_rm/gnat_language_extensions.rst: Adapt documentation to new syntax. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
…ributes Expansion of the Old attribute with anonymous access type is treated as a special case as the implicit constants need to be declared the same way as for conditionally evaluated Old attributes. However, this was implemented in a way that produced evaluation guards even when the attribute was supposed to be unconditionally evaluated. gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): For Old attribute, detect the anonymous access type case explicitly instead of implicitly within in Eligible_For_Conditional_Evaluation. * sem_util.ads: (Eligible_For_Conditional_Evaluation): Do not return True on anonymous access types. This was also breaking usage outside expansion (legality checks for Old). * sem_util.adb: (Conditional_Evaluation_Condition): Special case of no determiners for anonymous access types is no longer possible.
This patch implements the copy constructor as a particular type of constructor that copies its second parameter "From" into the first implicit "Self" parameter. The copy constructor is called via the 'Make attribute and is always available for tagged types. Internally, when missing an implicit copy constructor with default behavior is generated. Sometimes, when its behavior wouldn't differ from the default byte-wise copy, no entity is actually generated. In this case, whenever the copy constructor is called via the 'Make attribute, the call is rewritten simply as its parameter "From". gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): Do not expand copy constructor calls when unnecessary. * exp_ch3.adb (Build_Implicit_Copy_Constructor): If necessary, build the implicit copy constructor as part of the initialization procedures of its type. (Expand_N_Object_Declaration): Add implicit 'Make attribute calls for objects that may need construction. * exp_ch6.adb (Make_Parent_Constructor_Call): Constructor's procedure calls should be only generated from expansion of the 'Make attribute as there is hidden logic to handle copy constructors. * sem_attr.adb (Analyze_Attribute): Emit a specific error message if a non-copy constructor is called but no constructor is defined. * sem_ch13.adb (Analyze_Aspect_Specifications): The Ekind of the implicitly generated copy constructor is not a subprogram body. * sem_ch4.adb (Extended_Primitive_Ops): Extend the operation list that can be called via prefix notation to include constructors. * sem_ch6.adb (Check_For_Primitive_Subprogram): Skip constructors for primitive analysis. * sem_util.adb (Has_Matching_Constructor): Generic function to check for the existence of a constructor matching a given condition. (Has_Copy_Constructor): Check whether a type has an implicit or explicit copy constructor. (Has_Default_Constructor): Use Has_Matching_Constructor. (Is_Copy_Constructor): Check whether a subprogram is a copy constructor. (Is_Copy_Constructor_Call): Check whether an attribute call is call to a copy constructor. * sem_util.ads: Add specs for copy constructor utility functions. * snames.ads-tmpl (Snames): Add names Self and From.
This patch restores previous mapping of Ada to Win32 task priorities used when no pragma Task_Dispatching_Policy (FIFO_Within_Priorities) is present (except for wrong mapping to values that can only be used for processes with REALTIME_PRIORITY_CLASS). The new mapping is consistent with the one used when that pragma is present and provides distinct values for priorities in range of Default_Priority +/- 2. gcc/ada/ChangeLog: * libgnat/system-mingw.ads (Underlying_Priorities): Restore previous mapping with distinct values around Default_Priority.
Compiling under Ada 83 or Ada 95 mode, the warning reported under -gnatw_q is triggered by the compiler when a user-defined "=" on an untagged record type U is not used to compare a component C (of type U) of an outer record R. The warning is reported because it may be surprising that, under Ada 83 and Ada 95 modes, the predefined "=" of the component type C takes precedence over its user-defined "=" when objects of the record type R are compared. gcc/ada/ChangeLog: * exp_ch4.adb (Expand_Composite_Equality): Under Ada83 and Ada95 modes, and compiling under -gnatw_q, search for an user-defined equality and report a warning if found since it will not be called.
…ters When the discriminated type is declared with default discriminants, it is definite, so objects of the type can be declared without constraints, are thus unconstrained, and are allocated with the maximum size by GNAT. When these objects are passed as actuals of formal in out parameters, it makes sense for the 'Size computed for them from within the subprogram to also be the above "unconstrained" size instead of the "constrained" size computed from the value of the discriminants present in them. gcc/ada/ChangeLog: * exp_attr.adb (Expand_Size_Attribute): If the attribute is applied to a formal parameter allocated with an extra Constrained parameter, use the value of the latter to choose between the "unconstrained" or the "constrained" size of the formal parameter.
The compiler blows up when analyzing an illegal indexing of a container object (such as a vector) when the indexing expression has the form of a named actual parameter and the name given for the parameter does not match the name of the index formal of the corresponding indexing function that the compiler identifies for doing the generalized indexing. gcc/ada/ChangeLog: * sem_ch4.adb (Try_Container_Indexing): Conditionalize last actual of call to Error_Msg_NE to avoid blowup on N_Parameter_Association actuals.
Clean up various issues found while working on VAST. Fix uses of Token_Node, which was used in cases where it was documented as undefined, leading to strange behavior with respect to setting Parent nodes. Obey the comment about Validate_Subprogram_Calls in frontend.adb, "this work will be done by VAST". Remove conditionals on Debug_Flag_Underscore_XX. gcc/ada/ChangeLog: * debug.adb: Remove doc for gnatd_X; no longer used. * einfo.ads: Minor comment improvement. * exp_ch3.adb: Minor reformatting. * exp_ch6.adb (Check_BIP_Actuals): Export. (Validate_Subprogram_Calls): Move to Vast. * exp_ch6.ads (Check_BIP_Actuals): Export. * exp_ch7.adb (Make_Init_Call): Remove obsolete Set_Assignment_OK. * frontend.adb: Move Validate_Subprogram_Calls call to VAST, as the comment suggested. * par.adb: Minor comment improvements. * par-ch13.adb (Get_Aspect_Specifications): Misc cleanup, including removal of redundant setting of Aspects, and changing multiple 'if's to 'case'. * par-ch4.adb (P_Simple_Name_Resync): Do not refer to Token_Node when it is documented as not defined. * par-ch6.adb: Minor comment improvement. * par-util.adb (Bad_Spelling_Of): After setting Token from identifier to keyword, destroy Token_Node, so it doesn't get accidentally used. * scans.adb (Save_Scan_State, Restore_Scan_State): Put these in logical order. Make sure we're not saving and restoring bogus information in Token_Node. * scans.ads: Fix incorrect comment. * scn.ads: Minor comment improvements. Do not duplicate (wrong) information from Scans. * scng.adb: Set Token_Node to Empty initially, so we don't accidentally refer to bogus information from previous tokens. * scng.ads: Minor comment improvement (remove information about one actual from comment on the formal). * sem_aux.ads (Initialization_Suppressed): Minor comment improvement. * sem_ch6.adb: Remove usage of Debug_Flag_Underscore_XX. This code is pretty well tested by now, and anyway, it's only called from within pragmas Assert. * sem_util.adb (Enter_Name): Minor cleanup. * sprint.adb (Dump_Generated_Only): Fix incorrect comment. * vast.adb: Misc cleanup. Enable assertion about Errout.Compilation_Errors (should be False if back end is enabled). (Validate_Subprogram_Calls): Move here from frontend.adb. Move call to it here from frontend.adb.
…ild package The -gnatwu switch does not give any warning for a unused use clause when a use clause for a child package is present. It turns out that there are many occurrences in the compiler itself! gcc/ada/ChangeLog: PR ada/123003 * accessibility.adb: Remove unused clauses. * aspects.adb: Likewise. * checks.adb: Likewise. * comperr.adb: Likewise. * contracts.adb: Likewise. * cstand.adb: Likewise. * debug_a.adb: Likewise. * errout.adb: Likewise. * eval_fat.adb: Likewise. * exp_aggr.adb: Likewise. * exp_atag.adb: Likewise. * exp_attr.adb: Likewise. * exp_cg.adb: Likewise. * exp_ch11.adb: Likewise. * exp_ch12.adb: Likewise. * exp_ch13.adb: Likewise. * exp_ch2.adb: Likewise. * exp_ch3.adb: Likewise. * exp_ch4.adb: Likewise. * exp_ch5.adb: Likewise. * exp_ch6.adb: Likewise. * exp_ch7.adb: Likewise. * exp_ch8.adb: Likewise. * exp_ch9.adb: Likewise. * exp_code.adb: Likewise. * exp_dbug.adb: Likewise. * exp_disp.adb: Likewise. * exp_dist.adb: Likewise. * exp_fixd.adb: Likewise. * exp_imgv.adb: Likewise. * exp_intr.adb: Likewise. * exp_pakd.adb: Likewise. * exp_prag.adb: Likewise. * exp_put_image.adb: Likewise. * exp_sel.adb: Likewise. * exp_smem.adb: Likewise. * exp_spark.adb: Likewise. * exp_strm.adb: Likewise. * exp_tss.adb: Likewise. * exp_unst.adb: Likewise. * exp_util.adb: Likewise. * exp_util.ads: Likewise. * expander.adb: Likewise. * freeze.adb: Likewise. * frontend.adb: Likewise. * ghost.adb: Likewise. * gnat1drv.adb: Likewise. * gnat_cuda.adb: Likewise. * impunit.adb: Likewise. * inline.adb: Likewise. * itypes.adb: Likewise. * itypes.ads: Likewise. * layout.adb: Likewise. * lib.adb: Likewise. * libgnarl/s-tasuti.adb: Likewise. * live.adb: Likewise. * local_restrict.adb: Likewise. * mutably_tagged.adb: Likewise. * nlists.adb: Likewise. * par.adb: Likewise. * par_sco.adb: Likewise. * pprint.adb: Likewise. * repinfo.adb: Likewise. * restrict.adb: Likewise. * rtsfind.adb: Likewise. * scil_ll.adb: Likewise. * scn.adb: Likewise. * sem.adb: Likewise. * sem_aggr.adb: Likewise. * sem_attr.adb: Likewise. * sem_aux.adb: Likewise. * sem_case.adb: Likewise. * sem_cat.adb: Likewise. * sem_ch10.adb: Likewise. * sem_ch11.adb: Likewise. * sem_ch12.adb: Likewise. * sem_ch13.adb: Likewise. * sem_ch2.adb: Likewise. * sem_ch3.adb: Likewise. * sem_ch4.adb: Likewise. * sem_ch5.adb: Likewise. * sem_ch6.adb: Likewise. * sem_ch7.adb: Likewise. * sem_ch9.adb: Likewise. * sem_dim.adb: Likewise. * sem_disp.adb: Likewise. * sem_dist.adb: Likewise. * sem_elab.adb: Likewise. * sem_elim.adb: Likewise. * sem_eval.adb: Likewise. * sem_intr.adb: Likewise. * sem_mech.adb: Likewise. * sem_prag.adb: Likewise. * sem_res.adb: Likewise. * sem_scil.adb: Likewise. * sem_smem.adb: Likewise. * sem_type.adb: Likewise. * sem_util.adb: Likewise. * sem_util.ads: Likewise. * sem_warn.adb: Likewise. * sinput.adb: Likewise. * sprint.adb: Likewise. * strub.adb: Likewise. * style.adb: Likewise. * styleg.adb: Likewise. * tbuild.adb: Likewise. * tbuild.ads: Likewise. * treepr.adb: Likewise. * uname.adb: Likewise. * sem_ch8.adb: Likewise. (Mark_Use_Clauses.Mark_Use_Package): Do not recurse on the prefix for a package given by an expanded name.
Implement the predefined unit Ada.Containers.Bounded_Indefinite_Holders. gcc/ada/ChangeLog: * Makefile.rtl: add entry for new unit * impunit.adb: add entry for new unit * libgnat/a-cbinho.adb: new file with body for new unit * libgnat/a-cbinho.ads: new file with spec for new unit * libgnat/a-coboho.ads: add comment * libgnat/a-undesu.ads: add Preelaborate aspect specification, as per AI22-0050.
An expression provided as part of a Super or Initialize aspect specification is not allowed to reference the constructed object (that is, the first parameter of the constructor procedure). gcc/ada/ChangeLog: * sem_ch13.adb (Analyze_Aspect_Specifications): Add new legality checks for Super and Initialize aspect specifications, implemented by calling a new local procedure, Check_Constructor_Initialization_Expression.
Add support for the GNAT-defined From_Address attribute. gcc/ada/ChangeLog: * doc/gnat_rm/implementation_defined_attributes.rst: Document the From_Address attribute. * exp_attr.adb (Expand_N_Attribute_Reference): Implement expansion of a From_Address attribute reference. * sem_attr.adb (Analyze_Attribute): Implement analysis of a From_Address attribute reference. (Eval_Attribute): A From_Address attribute reference cannot be statically evaluated. * snames.ads-tmpl: Declare Name_From_Address and Attribute_From_Address. * gnat_rm.texi: Regenerate. * gnat_ugn.texi: Regenerate.
Previously the report for all of the available diagnostics and switches was given in a custom JSON format. This patch merges the two reports and includes them in a special SARIF report where all of the diagnostics and switches are presented as switches in the rules section of the report. Switches and diagnostics are linked with each other through the relationship node. Diagnostic rules will have a superset relation to a switch rule and a Switch rule will have a subset relation to each of its diagnostic rules. In order to facilitate those changes the errid and errsw packages were reorganized. Now errid will have the definitions for both all of the Diagnostic_Id-s and Switch_Id-s. The two new subpackages for errid - Diagnostic_Repository and Switch_Repository will hold the repository information that will be presented in the SARIF report. gcc/ada/ChangeLog: * errid-diagnostic_repository.ads: New package for storing information about diagnostics. * errid-switch_repository.adb: New package for storing information about switches. * errid-switch_repository.ads: Likewise. * errid.adb: Move common methods related to Diagnostic_Id-s and Switch_Id-s to this pacakge. * errid.ads: Likewise. * errout.adb (Add_Unique_Diagnostics_And_Switches): New method for gathering all of the unique Diagnostic_Id-s and Switch_Id-s among all of the error messages. (Output_Messages): Use the new SARIF printer interface for printing the report. * erroutc-sarif_emitter.adb (Print_Relationship): New method for printing relationship nodes. (Print_Rule): Support printing switches as rules. Add support for printing relationship nodes under rules. Remove brackets around the rule name. (Print_Runs): Add a printer argument to pass all of the switches and diagnostics as rules in the SARIF report. (Print_Tool): Likewise. (Free): New method. (Get_Unique_Rules): Removed. (Print_Result): Remove brackets around the rule name. (Print_Rules): Print switches as rules. * erroutc-sarif_emitter.ads (SARIF_Printer): New record type for storing and passing all of the diagnostic and switch information around in the SARIF printer. (Report_Kind): New type for indicating the different reports the SARIF emitter can produce. (Free): New method for releasing all of the dynamically allocated memory. (Print_SARIF_Report): Add a SARIF_Printer argument. * erroutc.adb (Get_Human_Id): Removed. (Get_Switch): Removed. (Get_Doc_Switch): Simplify code. * erroutc.ads: (Get_Human_Id): Removed. (Get_Switch): Removed. * errsw.adb: Replaced by errid-switch_repository.adb. * errsw.ads: Replaced by errid-switch_repository.ads. * errutil.adb: Remove dependecy to errsw pacakge. * par-endh.adb: Fix whitespace. * gcc-interface/Make-lang.in: Update the dependencies. * gcc-interface/Makefile.in: Likewise.
Remove the support for printing the diagnostic report in the compiler when -gnatd_E is used. Instead print it when the "gnat --diagnostics" command is used. gcc/ada/ChangeLog: * debug.adb: remove use case for -gnatd_E * errout.adb (Output_Messages): remove printing of the diagnostic repository when -gnatd_E is used. * gnatcmd.adb: Add support for printing the diagnostic repository.
Verify that every diagnostic that has a switch also has the same diagnostic marked as one of the diagnostics for that same switch. Additionally verify that for every diagnostic marked for a switch these diagnostics have the same switch marked as its switch. gcc/ada/ChangeLog: * errid.adb (Check_Diagnostic_To_Switch_Consistency): New subprogram for checking the consistency of diagnostics. (Check_Switch_To_Diagnostic_Consistency) New subprogram for checking the consistency of switches. (Add_All_Diagnostic_Rules): Check diagnostic consitency. (Add_All_Switch_Rules): Check switch consitency.
Add new entries to the Diagnostic_Id-s and entries to the diagnostic repository for error messages that are activated by -gnatwk. gcc/ada/ChangeLog: * errid-diagnostic_repository.ads: Update the diagnostic repository. * errid-switch_repository.ads: Update the switch repository. * errid.ads: Add new Diagnostic_Id-s. * sem_warn.adb (Check_References): Add Diagnostic_Id-s for error messages triggered by -gnatwk.
ChangeLog: * .github/workflows/commit-format.yml: adjust grep. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
ChangeLog: * README.md: Add Fedora WSL deps. Signed-off-by: Osama Albahrani <osalbahr@gmail.com>
Use github API through `gh` to get the related pull-request URL and add them in the comment section of the emails. ChangeLog: * .github/workflows/send-emails.yml<prepare patch series>: Add PR links. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Use dtolnay/rust-toolchain action to install rustc toolchain. Use a composite action for the various build/check on ubuntu. More cleanup possible (the 32/64bits builds could be simplified and only build 1 compiler and split the checks) ChangeLog: * .github/workflows/ccpp.yml: Refactor. * .github/actions/build-gcc/action.yml: New file. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Signed-off-by: Andrew V. Teylu <andrew.teylu@vector.com>
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::visit_attributes): Mention the name of the attribute macro that hasn't been found.
This patch refactors all uses of vector patterns since a vector of patterns would be considered as an alt pattern, a vector is considered useless. gcc/rust/ChangeLog: * ast/rust-ast-builder.cc (Builder::match_arm): Moves the vector of patterns to a single pattern. * ast/rust-ast-collector.cc (TokenCollector::visit):Likewise. * ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit):Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):Likewise. * ast/rust-ast.cc (IfLetExpr::as_string):Likewise. (WhileLetLoopExpr::as_string):Likewise. (MatchArm::as_string):Likewise. * ast/rust-desugar-question-mark.cc (make_match_arm):Likewise. * ast/rust-desugar-while-let.cc (DesugarWhileLet::desugar):Likewise. * ast/rust-expr.h (class WhileLetLoopExpr):Likewise. (class IfLetExpr):Likewise. * backend/rust-compile-expr.cc (CompileExpr::visit):Likewise. * checks/errors/rust-hir-pattern-analysis.cc (lower_arm):Likewise. * expand/rust-cfg-strip.cc (CfgStrip::visit):Likewise. * hir/rust-ast-lower.cc (ASTLoweringIfLetBlock::desugar_iflet):Likewise. (ASTLoweringExprWithBlock::visit):Likewise. * hir/rust-hir-dump.cc (Dump::do_matcharm):Likewise. (Dump::visit):Likewise. * hir/tree/rust-hir-expr.cc (OperatorExpr::operator=):Likewise. (ArithmeticOrLogicalExpr::operator=):Likewise. (ComparisonExpr::operator=):Likewise. (LazyBooleanExpr::operator=):Likewise. (TypeCastExpr::operator=):Likewise. (AssignmentExpr::operator=):Likewise. (CompoundAssignmentExpr::operator=):Likewise. (GroupedExpr::operator=):Likewise. (ArrayExpr::operator=):Likewise. (ArrayIndexExpr::operator=):Likewise. (CallExpr::operator=):Likewise. (MethodCallExpr::operator=):Likewise. (FieldAccessExpr::operator=):Likewise. (BlockExpr::operator=):Likewise. (BreakExpr::operator=):Likewise. (ReturnExpr::operator=):Likewise. (UnsafeBlockExpr::operator=):Likewise. (BaseLoopExpr::operator=):Likewise. (WhileLetLoopExpr::WhileLetLoopExpr):Likewise. (WhileLetLoopExpr::operator=):Likewise. (MatchArm::MatchArm):Likewise. (MatchArm::operator=):Likewise. (MatchExpr::operator=):Likewise. * hir/tree/rust-hir-expr.h (class WhileLetLoopExpr):Likewise. * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk):Likewise. (DefaultHIRVisitor::visit_match_arm):Likewise. * hir/tree/rust-hir.cc (WhileLetLoopExpr::as_string):Likewise. (MatchArm::as_string):Likewise. * parse/rust-parse-impl-expr.hxx: Likewise. * parse/rust-parse-impl.hxx: Likewise. * parse/rust-parse.h:Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit_if_let_patterns):Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit):Likewise. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):Likewise. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
When a macro expansion fails (e.g. due to a parsing error like invalid syntax in the macro body), the expander previously returned an error fragment but did not update the AST. This left the original macro invocation in place, which subsequently caused an ICE (rogue macro detected) during the lowering phase. This patch updates `expand_invoc` to replace the macro invocation with an empty fragment if expansion fails, ensuring the compiler can proceed (or exit gracefully) without crashing. Fixes #4213 gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_invoc): Handle error fragments by replacing them with empty fragments. gcc/testsuite/ChangeLog: * rust/compile/issue-4213.rs: New test. Signed-off-by: Harishankar <harishankarpp7@gmail.com>
A parser error header with Parse::Error namespace has recently been introduced. Move some old parser error classes to this namespace. gcc/rust/ChangeLog: * parse/rust-parse.h (class ParseLifetimeParamError): Move error from here ... (class ParseLifetimeError): Likewise. (enum class): Likewise. * parse/rust-parse-error.h (class LifetimeParam): ... to here. here. (class Lifetime): Likewise. (enum class): Likewise. (struct LoopLabel): Likewise and make it a full struct with ctors. (struct Self): Likewise. * parse/rust-parse-impl-expr.hxx: Make error point to new namespace. * parse/rust-parse-impl.hxx: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Errors in the parser needs to be collected instead of emitted directly. gcc/rust/ChangeLog: * parse/rust-parse-impl.hxx: Collect errors instead of emitting them. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog: * parse/rust-parse-error.h (struct BlockExpr): Add BlockExpr error type * parse/rust-parse-impl-expr.hxx: Update return types. * parse/rust-parse-impl.hxx: Likewise. * parse/rust-parse.h: Update function prototypes. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Some error types in the parser had the exact same meaning and could be grouped under one same type. gcc/rust/ChangeLog: * ast/rust-ast.cc (AttributeParser::parse_meta_item_lit): Use tl::expected * expand/rust-macro-builtins-helpers.cc (parse_single_string_literal): Likewise. * expand/rust-macro-expand.cc (MacroExpander::match_fragment): Likewise. * parse/rust-cfg-parser.cc (parse_cfg_option): Likewise. * parse/rust-parse-error.h (struct SimplePath): Remove error type. (struct DelimTokenTree): Likewise. (struct Token): Likewise. (struct TokenTree): Likewise. (class LifetimeParam): Move from here ... (struct LifetimeParam): ... to here. Add ctor. (class Lifetime): Add error type. (enum class): Remove AnonConst. (struct BlockExpr): Change BlockExpr to generic node error. * parse/rust-parse-impl-expr.hxx: Use tl::expected for errors. * parse/rust-parse-impl-path.hxx: Likewise. * parse/rust-parse-impl-ttree.hxx: Likewise. * parse/rust-parse-impl.hxx: Likewise. * parse/rust-parse.h: Update function return types with tl::expected to propagate errors. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Update function name. * ast/rust-ast-pointer-visitor.cc (PointerVisitor::visit): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast.cc (BreakExpr::as_string): Use getter function. (AttributeParser::parse_path_meta_item): Convert to expected type. (ReturnExpr::as_string): Change access to returned expr. * ast/rust-desugar-for-loops.cc (DesugarForLoops::DesugarCtx::make_break_arm): Likewise. * ast/rust-expr.h (class BreakExpr): Make expr in break optional. (class ReturnExpr): Make returned expr explicitely optional. Change the getters and introduce a const getter. * expand/rust-cfg-strip.cc (CfgStrip::visit): Convert to expected type. * expand/rust-macro-builtins-asm.cc (parse_reg_operand_in): Update constructor call to new expected types. (parse_reg_operand_out): Likewise. (parse_reg_operand_inout): Likewise. (parse_llvm_operands): Likewise. * expand/rust-macro-builtins-format-args.cc (format_args_parse_expr): Likewise. (format_args_parse_arguments): Likewise. * expand/rust-macro-builtins-helpers.cc (try_expand_many_expr): Update value for tl::expected. * expand/rust-macro-builtins-include.cc (MacroBuiltin::include_handler): Likewise. * expand/rust-macro-expand.cc (transcribe_expression): Update constructor call with expected value. * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Likewise. * parse/rust-parse-error.h (enum class): Add new error types for Expr and StructExprField. * parse/rust-parse-impl-expr.hxx: Explicitely handle return expr parsing failure. Update to fit new expected types. * parse/rust-parse-impl.hxx: Likewise. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Adapt to tl::expected. * ast/rust-desugar-while-let.cc (DesugarWhileLet::DesugarCtx::make_break_arm): Use optional for break expressions when missing instead of nullptr. * parse/rust-parse.h: Change function return type with expected. Remove error state from ExprOrStmt. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
GCC5 does not infer correctly the type to use within the template. gcc/rust/ChangeLog: * parse/rust-parse-impl-expr.hxx: Use explicit template. * parse/rust-parse-impl-path.hxx: Likewise. * parse/rust-parse-impl-ttree.hxx: Likewise. * parse/rust-parse-impl.hxx: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Add depth parameter to function. * resolve/rust-forever-stack.hxx: Likewise and use it.
gcc/rust/ChangeLog: * resolve/rust-early-name-resolver-2.0.cc (Early::finalize_glob_import): Save prelude if we find one. * resolve/rust-name-resolution-context.h: Add field. * resolve/rust-toplevel-name-resolver-2.0.cc (has_prelude_import): New function. (TopLevel::visit): Create a prelude glob import if necessary. * resolve/rust-toplevel-name-resolver-2.0.h: Allow glob imports to be prelude imports.
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Add new resolve_path function. * resolve/rust-forever-stack.hxx: Implement it.
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: New function. * resolve/rust-forever-stack.hxx: Implement it. * resolve/rust-late-name-resolver-2.0.cc (Late::visit): Call it if the prelude exists and we have an unresolved Identifier Call it if the prelude exists and we have an unresolved Identifier.
We only want to emit the ones from regular name resolution as otherwise they will be doubled for the user for no good reason. gcc/rust/ChangeLog: * resolve/rust-name-resolution-context.h: Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
Emit a diagnostic when #[link_name] is used without arguments, matching rustc behavior. This prevents silent acceptance of empty attributes and provides a helpful diagnostic that shows the expected form. Fixes #4228 gcc/rust/ChangeLog: * util/rust-attributes.cc: Emit diagnostic. gcc/testsuite/ChangeLog: * rust/compile/link_name-malformed.rs: New test. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
gcc/rust/ChangeLog: * checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit): Emit warning in empty statement visitor. * checks/lints/unused/rust-unused-checker.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/redundant-semicolons_0.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Emit a diagnostic when #[target_feature] is used without arguments, matching rustc behavior. This prevents silent acceptance of empty attributes and provides a helpful diagnostic that shows the expected form. Fixes #4233 gcc/rust/ChangeLog: * util/rust-attributes.cc (AttributeChecker::visit): Emit diagnostic. gcc/testsuite/ChangeLog: * rust/compile/target_feature-malformed-4233.rs: New test. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
Emit a diagnostic when #[no_mangle] is used with arguments, matching rustc behavior. The no_mangle attribute is a word attribute and should not accept any input values. Fixes #4230 gcc/rust/ChangeLog: * util/rust-attributes.cc (AttributeChecker::visit): Emit diagnostic. gcc/testsuite/ChangeLog: * rust/compile/no_mangle-malformed.rs: New test. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
gcc/rust/ChangeLog: * checks/lints/unused/rust-unused-checker.cc (UnusedChecker::visit_loop_label): Add warning for unused label in LoopLabel expr. * checks/lints/unused/rust-unused-checker.h: Likewise. * checks/lints/unused/rust-unused-collector.cc (UnusedCollector::visit): Check in BreakExpr and ContinueExpr if a label is used. * checks/lints/unused/rust-unused-collector.h: Likewise. * checks/lints/unused/rust-unused-context.cc (UnusedContext::add_label): Method helper. (UnusedContext::is_label_used): Likewise * checks/lints/unused/rust-unused-context.h: Likewise. gcc/testsuite/ChangeLog: * rust/compile/unused-label_0.rs: New test. Signed-off-by: Lucas Ly Ba <lucas.ly-ba@outlook.com>
Fix parsing of outer attributes in expressions. Fixes #3904 gcc/rust/ChangeLog: * parse/rust-parse-impl-expr.hxx(Parser::null_denotation): Add HASH case to handle outer attributes in expressions. Signed-off-by: lenny.chiadmi-delage <lenny.chiadmi-delage@epita.fr>
Adds test of issue 3904 and fix test of the issue 3874 to follows rust 1.49 behavior. Fixes GCC-Rust/gccrs#3904 gcc/testsuite/ChangeLog: * rust/compile/issue-3874.rs: Fixes test. * rust/compile/issue-3904.rs: New test. Signed-off-by: lenny.chiadmi-delage <lenny.chiadmi-delage@epita.fr>
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (visit(StructExprStruct)): Update to properly unwrap enum variants for type checking. * typecheck/rust-tyty.cc (VariantDef::get_fields) : Remove NUM assert. * backend/rust-compile-expr.cc: Update to properly unwrap enum variants for type resolution checking. Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
…se/2026-01-10 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
|
Both have: |
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: 00b6346
gccrs github: 32622b7
-- gerris 🦀