https://gcc.gnu.org/g:dadcb54f7642d754f71a870e69c3b93f100b9633
commit r17-784-gdadcb54f7642d754f71a870e69c3b93f100b9633 Author: Viljar Indus <[email protected]> Date: Wed Jan 7 10:55:56 2026 +0200 ada: Print restrictions in the SARIF report gcc/ada/ChangeLog: * errid-diagnostic_repository.ads: Add new diagnostics to the repository. Map diagnostics to restrictions. * errid-restriction_repository.ads: New pacakges for mapping restricitions to diagnostics. * errid.adb (heck_Diagnostic_To_Restriction_Consistency): New method for repository consistency. (Check_Diagnostic_To_Restriction_Consistency): New method for repository consistency. (Add_All_Restriction_Rules): New method for adding all of the restrictions. * errid.ads: Add new Diagnostic_Id-s. * errout.adb (Add_Unique_Diagnostics_And_Switches): Add restrictions to the SARIF_Printer. * erroutc.ads: Add restrictions to the Error_Msg_Object. * erroutc-sarif_emitter.adb (Print_Rule): Add method for printing rules for restrictions. * erroutc-sarif_emitter.ads: add restrictions as part of the printer. * errutil.adb (Error_Msg): Update diagnostic element creation. * restrict.adb (Restriction_Msg): Add diagnostic id based on the restriction id. * gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS): Add new files. * gcc-interface/Makefile.in (GNATMAKE_OBJS): Likewise. Diff: --- gcc/ada/errid-diagnostic_repository.ads | 658 +++++++++++++++++++++++++++++-- gcc/ada/errid-restriction_repository.ads | 178 +++++++++ gcc/ada/errid.adb | 85 +++- gcc/ada/errid.ads | 102 ++++- gcc/ada/errout.adb | 38 ++ gcc/ada/erroutc-sarif_emitter.adb | 80 ++++ gcc/ada/erroutc-sarif_emitter.ads | 14 +- gcc/ada/erroutc.ads | 10 +- gcc/ada/errutil.adb | 2 + gcc/ada/gcc-interface/Make-lang.in | 2 + gcc/ada/gcc-interface/Makefile.in | 1 + gcc/ada/restrict.adb | 50 ++- 12 files changed, 1161 insertions(+), 59 deletions(-) diff --git a/gcc/ada/errid-diagnostic_repository.ads b/gcc/ada/errid-diagnostic_repository.ads index d8365fee3a3a..a49fbbaffcec 100644 --- a/gcc/ada/errid-diagnostic_repository.ads +++ b/gcc/ada/errid-diagnostic_repository.ads @@ -23,7 +23,8 @@ -- -- ------------------------------------------------------------------------------ -with Types; use Types; +with Rident; use Rident; +with Types; use Types; package Errid.Diagnostic_Repository is type Diagnostic_Entry_Type is record @@ -36,6 +37,9 @@ package Errid.Diagnostic_Repository is Switch : Switch_Id := No_Switch_Id; -- The switch that controls the diagnostic message. + + Restriction : Restriction_Id := Not_A_Restriction_Id; + -- The restriction associated with the diagnostic message. end record; type Diagnostics_Registry_Type is @@ -60,39 +64,631 @@ package Errid.Diagnostic_Repository is Diagnostic_Entries : constant Diagnostics_Registry_Type := (No_Diagnostic_Id => <>, GNAT0001 => - (Status => Active, - Human_Id => new String'("Default_Iterator_Not_Primitive_Error"), - Switch => No_Switch_Id), + (Status => Active, + Human_Id => new String'("Default_Iterator_Not_Primitive_Error"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), GNAT0002 => - (Status => Active, - Human_Id => new String'("Invalid_Operand_Types_General_Error"), - Switch => No_Switch_Id), + (Status => Active, + Human_Id => new String'("Invalid_Operand_Types_General_Error"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), GNAT0003 => - (Status => Active, - Human_Id => new String'("Pragma_No_Effect_With_Lock_Free_Warning"), - Switch => No_Switch_Id), + (Status => Active, + Human_Id => new String'("Pragma_No_Effect_With_Lock_Free_Warning"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), GNAT0004 => - (Status => Active, - Human_Id => new String'("End_Loop_Expected_Error"), - Switch => No_Switch_Id), + (Status => Active, + Human_Id => new String'("End_Loop_Expected_Error"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), GNAT0005 => - (Status => Active, - Human_Id => new String'("Representation_Too_Late_Error"), - Switch => No_Switch_Id), + (Status => Active, + Human_Id => new String'("Representation_Too_Late_Error"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), GNAT0006 => - (Status => Active, - Human_Id => new String'("Mixed_Container_Aggregate_Error"), - Switch => No_Switch_Id), - GNAT0007 => - (Status => Active, - Human_Id => new String'("Volatile_Not_Modifed_Warning"), - Switch => gnatwk), - GNAT0008 => - (Status => Active, - Human_Id => new String'("Variable_Not_Modifed_Warning"), - Switch => gnatwk), - GNAT0009 => - (Status => Active, - Human_Id => new String'("In_Out_Not_Modifed_Warning"), - Switch => gnatwk)); + (Status => Active, + Human_Id => new String'("Mixed_Container_Aggregate_Error"), + Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id), + GNAT0007 => + (Status => Active, + Human_Id => new String'("Volatile_Not_Modifed_Warning"), + Switch => gnatwk, + Restriction => Not_A_Restriction_Id), + GNAT0008 => + (Status => Active, + Human_Id => new String'("Variable_Not_Modifed_Warning"), + Switch => gnatwk, + Restriction => Not_A_Restriction_Id), + GNAT0009 => + (Status => Active, + Human_Id => new String'("In_Out_Not_Modifed_Warning"), + Switch => gnatwk, + Restriction => Not_A_Restriction_Id), + GNAT0010 => + (Status => Active, + Human_Id => new String'("Simple_Barriers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Simple_Barriers), + GNAT0011 => + (Status => Active, + Human_Id => new String'("Pure_Barriers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Pure_Barriers), + GNAT0012 => + (Status => Active, + Human_Id => + new String'("No_Abort_Statements_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Abort_Statements), + GNAT0013 => + (Status => Active, + Human_Id => + new String'("No_Access_Parameter_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Access_Parameter_Allocators), + GNAT0014 => + (Status => Active, + Human_Id => + new String'("No_Access_Subprograms_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Access_Subprograms), + GNAT0015 => + (Status => Active, + Human_Id => new String'("No_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Allocators), + GNAT0016 => + (Status => Active, + Human_Id => + new String'("No_Anonymous_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Anonymous_Allocators), + GNAT0017 => + (Status => Active, + Human_Id => + new String'("No_Asynchronous_Control_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Asynchronous_Control), + GNAT0018 => + (Status => Active, + Human_Id => new String'("No_Calendar_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Calendar), + GNAT0019 => + (Status => Active, + Human_Id => new String'("No_Coextensions_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Coextensions), + GNAT0020 => + (Status => Active, + Human_Id => + new String'("No_Default_Stream_Attributes_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Default_Stream_Attributes), + GNAT0021 => + (Status => Active, + Human_Id => new String'("No_Delay_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Delay), + GNAT0022 => + (Status => Active, + Human_Id => + new String'("No_Direct_Boolean_Operators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Direct_Boolean_Operators), + GNAT0023 => + (Status => Active, + Human_Id => new String'("No_Dispatch_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dispatch), + GNAT0024 => + (Status => Active, + Human_Id => + new String'("No_Dispatching_Calls_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dispatching_Calls), + GNAT0025 => + (Status => Active, + Human_Id => + new String' + ("No_Dynamic_Accessibility_Checks_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dynamic_Accessibility_Checks), + GNAT0026 => + (Status => Active, + Human_Id => + new String'("No_Dynamic_Attachment_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dynamic_Attachment), + GNAT0027 => + (Status => Active, + Human_Id => + new String'("No_Dynamic_CPU_Assignment_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dynamic_CPU_Assignment), + GNAT0028 => + (Status => Active, + Human_Id => + new String'("No_Dynamic_Priorities_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dynamic_Priorities), + GNAT0029 => + (Status => Active, + Human_Id => + new String'("No_Enumeration_Maps_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Enumeration_Maps), + GNAT0030 => + (Status => Active, + Human_Id => + new String' + ("No_Entry_Calls_In_Elaboration_Code_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Entry_Calls_In_Elaboration_Code), + GNAT0031 => + (Status => Active, + Human_Id => new String'("No_Entry_Queue_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Entry_Queue), + GNAT0032 => + (Status => Active, + Human_Id => + new String'("No_Exception_Handlers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Exception_Handlers), + GNAT0033 => + (Status => Active, + Human_Id => + new String'("No_Exception_Propagation_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Exception_Propagation), + GNAT0034 => + (Status => Active, + Human_Id => + new String'("No_Exception_Registration_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Exception_Registration), + GNAT0035 => + (Status => Active, + Human_Id => new String'("No_Exceptions_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Exceptions), + GNAT0036 => + (Status => Active, + Human_Id => new String'("No_Finalization_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Finalization), + GNAT0037 => + (Status => Active, + Human_Id => new String'("No_Fixed_IO_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Fixed_IO), + GNAT0038 => + (Status => Active, + Human_Id => new String'("No_Fixed_Point_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Fixed_Point), + GNAT0039 => + (Status => Active, + Human_Id => new String'("No_Floating_Point_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Floating_Point), + GNAT0040 => + (Status => Active, + Human_Id => new String'("No_IO_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_IO), + GNAT0041 => + (Status => Active, + Human_Id => + new String'("No_Implicit_Conditionals_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Conditionals), + GNAT0042 => + (Status => Active, + Human_Id => + new String'("No_Implicit_Dynamic_Code_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Dynamic_Code), + GNAT0043 => + (Status => Active, + Human_Id => + new String'("No_Implicit_Heap_Allocations_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Heap_Allocations), + GNAT0044 => + (Status => Active, + Human_Id => + new String'("No_Implicit_Task_Allocations_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Task_Allocations), + GNAT0045 => + (Status => Active, + Human_Id => + new String' + ("No_Implicit_Protected_Object_Allocations" + & "_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Protected_Object_Allocations), + GNAT0046 => + (Status => Active, + Human_Id => + new String'("No_Initialize_Scalars_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Initialize_Scalars), + GNAT0047 => + (Status => Active, + Human_Id => + new String'("No_Local_Tagged_Types_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Local_Tagged_Types), + GNAT0048 => + (Status => Active, + Human_Id => + new String'("No_Local_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Local_Allocators), + GNAT0049 => + (Status => Active, + Human_Id => + new String'("No_Local_Timing_Events_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Local_Timing_Events), + GNAT0050 => + (Status => Active, + Human_Id => + new String'("No_Local_Protected_Objects_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Local_Protected_Objects), + GNAT0051 => + (Status => Active, + Human_Id => + new String'("No_Long_Long_Integers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Long_Long_Integers), + GNAT0052 => + (Status => Active, + Human_Id => + new String'("No_Multiple_Elaboration_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Multiple_Elaboration), + GNAT0053 => + (Status => Active, + Human_Id => + new String'("No_Nested_Finalization_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Nested_Finalization), + GNAT0054 => + (Status => Active, + Human_Id => + new String'("No_Protected_Type_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Protected_Type_Allocators), + GNAT0055 => + (Status => Active, + Human_Id => + new String'("No_Protected_Types_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Protected_Types), + GNAT0056 => + (Status => Active, + Human_Id => new String'("No_Recursion_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Recursion), + GNAT0057 => + (Status => Active, + Human_Id => new String'("No_Reentrancy_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Reentrancy), + GNAT0058 => + (Status => Active, + Human_Id => new String'("No_Relative_Delay_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Relative_Delay), + GNAT0059 => + (Status => Active, + Human_Id => + new String'("No_Requeue_Statements_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Requeue_Statements), + GNAT0060 => + (Status => Active, + Human_Id => + new String'("No_Secondary_Stack_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Secondary_Stack), + GNAT0061 => + (Status => Active, + Human_Id => + new String'("No_Select_Statements_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Select_Statements), + GNAT0062 => + (Status => Active, + Human_Id => + new String' + ("No_Specific_Termination_Handlers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Specific_Termination_Handlers), + GNAT0063 => + (Status => Active, + Human_Id => + new String' + ("No_Standard_Allocators_After_Elaboration" + & "_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Standard_Allocators_After_Elaboration), + GNAT0064 => + (Status => Active, + Human_Id => + new String'("No_Standard_Storage_Pools_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Standard_Storage_Pools), + GNAT0065 => + (Status => Active, + Human_Id => + new String'("No_Stream_Optimizations_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Stream_Optimizations), + GNAT0066 => + (Status => Active, + Human_Id => new String'("No_Streams_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Streams), + GNAT0067 => + (Status => Active, + Human_Id => + new String'("No_Tagged_Type_Registration_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Tagged_Type_Registration), + GNAT0068 => + (Status => Active, + Human_Id => + new String'("No_Task_Allocators_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_Allocators), + GNAT0069 => + (Status => Active, + Human_Id => + new String'("No_Task_Attributes_Package_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_Attributes_Package), + GNAT0070 => + (Status => Active, + Human_Id => + new String'("No_Task_At_Interrupt_Priority_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_At_Interrupt_Priority), + GNAT0071 => + (Status => Active, + Human_Id => new String'("No_Task_Hierarchy_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_Hierarchy), + GNAT0072 => + (Status => Active, + Human_Id => + new String'("No_Task_Hierarchy_Implicit_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_Hierarchy_Implicit), + GNAT0073 => + (Status => Active, + Human_Id => + new String'("No_Task_Termination_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Task_Termination), + GNAT0074 => + (Status => Active, + Human_Id => + new String'("No_Tasks_Unassigned_To_CPU_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Tasks_Unassigned_To_CPU), + GNAT0075 => + (Status => Active, + Human_Id => new String'("No_Tasking_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Tasking), + GNAT0076 => + (Status => Active, + Human_Id => + new String'("No_Terminate_Alternatives_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Terminate_Alternatives), + GNAT0077 => + (Status => Active, + Human_Id => + new String'("No_Unchecked_Access_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Unchecked_Access), + GNAT0078 => + (Status => Active, + Human_Id => + new String'("No_Unchecked_Conversion_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Unchecked_Conversion), + GNAT0079 => + (Status => Active, + Human_Id => + new String'("No_Unchecked_Deallocation_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Unchecked_Deallocation), + GNAT0080 => + (Status => Active, + Human_Id => new String'("Static_Priorities_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Static_Priorities), + GNAT0081 => + (Status => Active, + Human_Id => + new String'("Static_Storage_Size_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Static_Storage_Size), + GNAT0082 => + (Status => Active, + Human_Id => + new String'("No_Default_Initialization_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Default_Initialization), + GNAT0083 => + (Status => Active, + Human_Id => + new String'("Immediate_Reclamation_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Immediate_Reclamation), + GNAT0084 => + (Status => Active, + Human_Id => + new String'("No_Dynamic_Sized_Objects_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Dynamic_Sized_Objects), + GNAT0085 => + (Status => Active, + Human_Id => + new String' + ("No_Implementation_Aspect_Specifications_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Aspect_Specifications), + GNAT0086 => + (Status => Active, + Human_Id => + new String'("No_Implementation_Attributes_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Attributes), + GNAT0087 => + (Status => Active, + Human_Id => + new String'("No_Implementation_Identifiers_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Identifiers), + GNAT0088 => + (Status => Active, + Human_Id => + new String'("No_Implementation_Pragmas_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Pragmas), + GNAT0089 => + (Status => Active, + Human_Id => + new String'("No_Implementation_Restrictions_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Restrictions), + GNAT0090 => + (Status => Active, + Human_Id => + new String'("No_Implementation_Units_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implementation_Units), + GNAT0091 => + (Status => Active, + Human_Id => + new String'("No_Implicit_Aliasing_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Aliasing), + GNAT0092 => + (Status => Active, + Human_Id => new String'("No_Implicit_Loops_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Implicit_Loops), + GNAT0093 => + (Status => Active, + Human_Id => + new String'("No_Elaboration_Code_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Elaboration_Code), + GNAT0094 => + (Status => Active, + Human_Id => + new String'("No_Obsolescent_Features_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Obsolescent_Features), + GNAT0095 => + (Status => Active, + Human_Id => + new String'("No_Unrecognized_Aspects_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Unrecognized_Aspects), + GNAT0096 => + (Status => Active, + Human_Id => + new String'("No_Unrecognized_Pragmas_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Unrecognized_Pragmas), + GNAT0097 => + (Status => Active, + Human_Id => + new String'("No_Wide_Characters_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Wide_Characters), + GNAT0098 => + (Status => Active, + Human_Id => + new String'("Static_Dispatch_Tables_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Static_Dispatch_Tables), + GNAT0099 => + (Status => Active, + Human_Id => new String'("SPARK_05_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => SPARK_05), + GNAT0100 => + (Status => Active, + Human_Id => + new String'("No_Specification_Of_Aspect_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Specification_Of_Aspect), + GNAT0101 => + (Status => Active, + Human_Id => + new String'("No_Use_Of_Attribute_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Use_Of_Attribute), + GNAT0102 => + (Status => Active, + Human_Id => new String'("No_Use_Of_Pragma_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => No_Use_Of_Pragma), + GNAT0103 => + (Status => Active, + Human_Id => + new String'("Max_Protected_Entries_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Protected_Entries), + GNAT0104 => + (Status => Active, + Human_Id => + new String'("Max_Select_Alternatives_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Select_Alternatives), + GNAT0105 => + (Status => Active, + Human_Id => new String'("Max_Task_Entries_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Task_Entries), + GNAT0106 => + (Status => Active, + Human_Id => new String'("Max_Tasks_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Tasks), + GNAT0107 => + (Status => Active, + Human_Id => + new String' + ("Max_Asynchronous_Select_Nesting_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Asynchronous_Select_Nesting), + GNAT0108 => + (Status => Active, + Human_Id => + new String'("Max_Entry_Queue_Length_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Entry_Queue_Length), + GNAT0109 => + (Status => Active, + Human_Id => + new String'("Max_Storage_At_Blocking_Restriction_Violation"), + Switch => No_Switch_Id, + Restriction => Max_Storage_At_Blocking)); end Errid.Diagnostic_Repository; diff --git a/gcc/ada/errid-restriction_repository.ads b/gcc/ada/errid-restriction_repository.ads new file mode 100644 index 000000000000..c44abd0d6b27 --- /dev/null +++ b/gcc/ada/errid-restriction_repository.ads @@ -0,0 +1,178 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT COMPILER COMPONENTS -- +-- -- +-- E R R I D . R E S T R I C T I O N _ R E P O S I T O R Y -- +-- -- +-- S p e c -- +-- -- +-- Copyright (C) 1992-2026, Free Software Foundation, Inc. -- +-- -- +-- GNAT is free software; you can redistribute it and/or modify it under -- +-- terms of the GNU General Public License as published by the Free Soft- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- +-- for more details. You should have received a copy of the GNU General -- +-- Public License distributed with GNAT; see file COPYING3. If not, go to -- +-- http://www.gnu.org/licenses for a complete copy of the license. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +with Rident; use Rident; + +package Errid.Restriction_Repository is + + type Restriction_To_Diagnostic_Mapping is + array (Restriction_Id) of Diagnostic_Id; + + Rest_To_Diag_Mappping : constant Restriction_To_Diagnostic_Mapping := + (Simple_Barriers => GNAT0010, + Pure_Barriers => GNAT0011, + No_Abort_Statements => GNAT0012, + No_Access_Parameter_Allocators => GNAT0013, + No_Access_Subprograms => GNAT0014, + No_Allocators => GNAT0015, + No_Anonymous_Allocators => GNAT0016, + No_Asynchronous_Control => GNAT0017, + No_Calendar => GNAT0018, + No_Coextensions => GNAT0019, + No_Default_Stream_Attributes => GNAT0020, + No_Delay => GNAT0021, + No_Direct_Boolean_Operators => GNAT0022, + No_Dispatch => GNAT0023, + No_Dispatching_Calls => GNAT0024, + No_Dynamic_Accessibility_Checks => GNAT0025, + No_Dynamic_Attachment => GNAT0026, + No_Dynamic_CPU_Assignment => GNAT0027, + No_Dynamic_Priorities => GNAT0028, + No_Enumeration_Maps => GNAT0029, + No_Entry_Calls_In_Elaboration_Code => GNAT0030, + No_Entry_Queue => GNAT0031, + No_Exception_Handlers => GNAT0032, + No_Exception_Propagation => GNAT0033, + No_Exception_Registration => GNAT0034, + No_Exceptions => GNAT0035, + No_Finalization => GNAT0036, + No_Fixed_IO => GNAT0037, + No_Fixed_Point => GNAT0038, + No_Floating_Point => GNAT0039, + No_IO => GNAT0040, + No_Implicit_Conditionals => GNAT0041, + No_Implicit_Dynamic_Code => GNAT0042, + No_Implicit_Heap_Allocations => GNAT0043, + No_Implicit_Task_Allocations => GNAT0044, + No_Implicit_Protected_Object_Allocations => GNAT0045, + No_Initialize_Scalars => GNAT0046, + No_Local_Tagged_Types => GNAT0047, + No_Local_Allocators => GNAT0048, + No_Local_Timing_Events => GNAT0049, + No_Local_Protected_Objects => GNAT0050, + No_Long_Long_Integers => GNAT0051, + No_Multiple_Elaboration => GNAT0052, + No_Nested_Finalization => GNAT0053, + No_Protected_Type_Allocators => GNAT0054, + No_Protected_Types => GNAT0055, + No_Recursion => GNAT0056, + No_Reentrancy => GNAT0057, + No_Relative_Delay => GNAT0058, + No_Requeue_Statements => GNAT0059, + No_Secondary_Stack => GNAT0060, + No_Select_Statements => GNAT0061, + No_Specific_Termination_Handlers => GNAT0062, + No_Standard_Allocators_After_Elaboration => GNAT0063, + No_Standard_Storage_Pools => GNAT0064, + No_Stream_Optimizations => GNAT0065, + No_Streams => GNAT0066, + No_Tagged_Type_Registration => GNAT0067, + No_Task_Allocators => GNAT0068, + No_Task_Attributes_Package => GNAT0069, + No_Task_At_Interrupt_Priority => GNAT0070, + No_Task_Hierarchy => GNAT0071, + No_Task_Hierarchy_Implicit => GNAT0072, + No_Task_Termination => GNAT0073, + No_Tasks_Unassigned_To_CPU => GNAT0074, + No_Tasking => GNAT0075, + No_Terminate_Alternatives => GNAT0076, + No_Unchecked_Access => GNAT0077, + No_Unchecked_Conversion => GNAT0078, + No_Unchecked_Deallocation => GNAT0079, + Static_Priorities => GNAT0080, + Static_Storage_Size => GNAT0081, + + -- The following require consistency checking with special rules. See + -- individual routines in unit Bcheck for details of what is required. + + No_Default_Initialization => GNAT0082, + + -- The following cases do not require consistency checking and if used + -- as a configuration pragma within a specific unit, apply only to that + -- unit (e.g. if used in the package spec, do not apply to the body) + + -- Note: No_Elaboration_Code is handled specially. Like the other + -- non-partition-wide restrictions, it can only be set in a unit that + -- is part of the extended main source unit (body/spec/subunits). But + -- it is sticky, in that if it is found anywhere within any of these + -- units, it applies to all units in this extended main source. + + Immediate_Reclamation => GNAT0083, + No_Dynamic_Sized_Objects => GNAT0084, + No_Implementation_Aspect_Specifications => GNAT0085, + No_Implementation_Attributes => GNAT0086, + No_Implementation_Identifiers => GNAT0087, + No_Implementation_Pragmas => GNAT0088, + No_Implementation_Restrictions => GNAT0089, + No_Implementation_Units => GNAT0090, + No_Implicit_Aliasing => GNAT0091, + No_Implicit_Loops => GNAT0092, + No_Elaboration_Code => GNAT0093, + No_Obsolescent_Features => GNAT0094, + No_Unrecognized_Aspects => GNAT0095, + No_Unrecognized_Pragmas => GNAT0096, + No_Wide_Characters => GNAT0097, + Static_Dispatch_Tables => GNAT0098, + SPARK_05 => GNAT0099, + + -- The following cases require a parameter value + + No_Specification_Of_Aspect => GNAT0100, + No_Use_Of_Attribute => GNAT0101, + No_Use_Of_Pragma => GNAT0102, + + -- The following entries are fully checked at compile/bind time, which + -- means that the compiler can in general tell the minimum value which + -- could be used with a restrictions pragma. The binder can deduce the + -- appropriate minimum value for the partition by taking the maximum + -- value required by any unit. + + Max_Protected_Entries => GNAT0103, + Max_Select_Alternatives => GNAT0104, + Max_Task_Entries => GNAT0105, + + -- The following entries are also fully checked at compile/bind time, + -- and the compiler can also at least in some cases tell the minimum + -- value which could be used with a restriction pragma. The difference + -- is that the contributions are additive, so the binder deduces this + -- value by adding the unit contributions. + + Max_Tasks => GNAT0106, + + -- The following entries are checked at compile time only for zero/ + -- nonzero entries. This means that the compiler can tell at compile + -- time if a restriction value of zero is (would be) violated, but that + -- the compiler cannot distinguish between different non-zero values. + + Max_Asynchronous_Select_Nesting => GNAT0107, + Max_Entry_Queue_Length => GNAT0108, + + -- The remaining entries are not checked at compile/bind time + + Max_Storage_At_Blocking => GNAT0109, + + Not_A_Restriction_Id => No_Diagnostic_Id); + +end Errid.Restriction_Repository; diff --git a/gcc/ada/errid.adb b/gcc/ada/errid.adb index 7a786f3292ae..e3218be80068 100644 --- a/gcc/ada/errid.adb +++ b/gcc/ada/errid.adb @@ -23,9 +23,11 @@ -- -- ------------------------------------------------------------------------------ -with Errid.Diagnostic_Repository; use Errid.Diagnostic_Repository; -with Errid.Switch_Repository; use Errid.Switch_Repository; -with Erroutc.SARIF_Emitter; use Erroutc.SARIF_Emitter; +with Errid.Diagnostic_Repository; use Errid.Diagnostic_Repository; +with Errid.Restriction_Repository; use Errid.Restriction_Repository; +with Errid.Switch_Repository; use Errid.Switch_Repository; +with Erroutc.SARIF_Emitter; use Erroutc.SARIF_Emitter; +with Rident; use Rident; package body Errid is @@ -37,6 +39,9 @@ package body Errid is procedure Add_All_Diagnostic_Rules (Printer : in out SARIF_Printer); -- Add all active Diagnostic_Id-s to the SARIF_Printer + procedure Add_All_Restriction_Rules (Printer : in out SARIF_Printer); + -- Add all active Restriction_Id-s to the SARIF_Printer + procedure Add_All_Switch_Rules (Printer : in out SARIF_Printer); -- Add all active Switch_Id-s to the SARIF_Printer @@ -44,6 +49,16 @@ package body Errid is -- Check that if a diagnostic has a switch then that diagnostic is also -- included in the list of diagnostics for that switch. + procedure Check_Diagnostic_To_Restriction_Consistency + (D_Id : Diagnostic_Id); + -- Check that if a diagnostic has a restriction then that diagnostic is + -- also included as the diagnostic for that restriction. + + procedure Check_Restriction_To_Diagnostic_Consistency + (R_Id : Restriction_Id); + -- Check that the diagnostic set for a restriction has that restriction as + -- its restriction in the repository. + procedure Check_Switch_To_Diagnostic_Consistency (S_Id : Switch_Id); -- Check that if a Switch has diagnostics then that diagnostic has the same -- switch marked as its switch. @@ -77,6 +92,55 @@ package body Errid is raise Diagnostic_Inconsistency with Err_Msg; end Check_Diagnostic_To_Switch_Consistency; + ------------------------------------------------- + -- Check_Diagnostic_To_Restriction_Consistency -- + ------------------------------------------------- + + procedure Check_Diagnostic_To_Restriction_Consistency (D_Id : Diagnostic_Id) + is + D : constant Diagnostic_Entry_Type := Diagnostic_Entries (D_Id); + Restrict : constant Restriction_Id := D.Restriction; + Err_Msg : constant String := + Restriction_Id'Image (D.Restriction) + & " should contain " + & Diagnostic_Id'Image (D_Id) + & " in its diagnostics"; + begin + if Restrict = Not_A_Restriction_Id then + return; + end if; + + if Rest_To_Diag_Mappping (Restrict) /= D_Id then + raise Diagnostic_Inconsistency with Err_Msg; + end if; + end Check_Diagnostic_To_Restriction_Consistency; + + ------------------------------------------------- + -- Check_Restriction_To_Diagnostic_Consistency -- + ------------------------------------------------- + + procedure Check_Restriction_To_Diagnostic_Consistency + (R_Id : Restriction_Id) + is + D : Diagnostic_Entry_Type; + D_Id : Diagnostic_Id; + begin + if R_Id = Not_A_Restriction_Id then + return; + end if; + + D_Id := Rest_To_Diag_Mappping (R_Id); + D := Diagnostic_Entries (D_Id); + + if D.Restriction /= R_Id then + raise Diagnostic_Inconsistency + with + Restriction_Id'Image (R_Id) + & " should be the restriction for " + & Diagnostic_Id'Image (D_Id); + end if; + end Check_Restriction_To_Diagnostic_Consistency; + -------------------------------------------- -- Check_Switch_To_Diagnostic_Consistency -- -------------------------------------------- @@ -138,10 +202,24 @@ package body Errid is if Id /= No_Diagnostic_Id then Diagnostic_Id_Lists.Append (Printer.Diagnostics, Id); Check_Diagnostic_To_Switch_Consistency (Id); + Check_Diagnostic_To_Restriction_Consistency (Id); end if; end loop; end Add_All_Diagnostic_Rules; + ------------------------------- + -- Add_All_Restriction_Rules -- + ------------------------------- + + procedure Add_All_Restriction_Rules (Printer : in out SARIF_Printer) is + begin + Printer.Restrictions := Restriction_Id_Lists.Create; + for R in All_Restrictions loop + Restriction_Id_Lists.Append (Printer.Restrictions, R); + Check_Restriction_To_Diagnostic_Consistency (R); + end loop; + end Add_All_Restriction_Rules; + -------------------------- -- Add_All_Switch_Rules -- -------------------------- @@ -166,6 +244,7 @@ package body Errid is begin Add_All_Diagnostic_Rules (Printer); Add_All_Switch_Rules (Printer); + Add_All_Restriction_Rules (Printer); Printer.Report_Type := Repository_Report; Print_SARIF_Report (Printer); diff --git a/gcc/ada/errid.ads b/gcc/ada/errid.ads index 26f9e201b16a..aa1c1ec1b41d 100644 --- a/gcc/ada/errid.ads +++ b/gcc/ada/errid.ads @@ -39,7 +39,107 @@ package Errid is GNAT0006, GNAT0007, GNAT0008, - GNAT0009); + GNAT0009, + GNAT0010, + GNAT0011, + GNAT0012, + GNAT0013, + GNAT0014, + GNAT0015, + GNAT0016, + GNAT0017, + GNAT0018, + GNAT0019, + GNAT0020, + GNAT0021, + GNAT0022, + GNAT0023, + GNAT0024, + GNAT0025, + GNAT0026, + GNAT0027, + GNAT0028, + GNAT0029, + GNAT0030, + GNAT0031, + GNAT0032, + GNAT0033, + GNAT0034, + GNAT0035, + GNAT0036, + GNAT0037, + GNAT0038, + GNAT0039, + GNAT0040, + GNAT0041, + GNAT0042, + GNAT0043, + GNAT0044, + GNAT0045, + GNAT0046, + GNAT0047, + GNAT0048, + GNAT0049, + GNAT0050, + GNAT0051, + GNAT0052, + GNAT0053, + GNAT0054, + GNAT0055, + GNAT0056, + GNAT0057, + GNAT0058, + GNAT0059, + GNAT0060, + GNAT0061, + GNAT0062, + GNAT0063, + GNAT0064, + GNAT0065, + GNAT0066, + GNAT0067, + GNAT0068, + GNAT0069, + GNAT0070, + GNAT0071, + GNAT0072, + GNAT0073, + GNAT0074, + GNAT0075, + GNAT0076, + GNAT0077, + GNAT0078, + GNAT0079, + GNAT0080, + GNAT0081, + GNAT0082, + GNAT0083, + GNAT0084, + GNAT0085, + GNAT0086, + GNAT0087, + GNAT0088, + GNAT0089, + GNAT0090, + GNAT0091, + GNAT0092, + GNAT0093, + GNAT0094, + GNAT0095, + GNAT0096, + GNAT0097, + GNAT0098, + GNAT0099, + GNAT0100, + GNAT0101, + GNAT0102, + GNAT0103, + GNAT0104, + GNAT0105, + GNAT0106, + GNAT0107, + GNAT0108, + GNAT0109); type Diagnostic_Id_Array is array (Positive range <>) of Diagnostic_Id; type Diagnostic_Id_Array_Access is access Diagnostic_Id_Array; diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index cce0e8952483..c29375d77b64 100644 --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -35,6 +35,7 @@ with Csets; use Csets; with Debug; use Debug; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; +with Errid.Diagnostic_Repository; use Errid.Diagnostic_Repository; with Erroutc; use Erroutc; with Erroutc.Pretty_Emitter; with Erroutc.SARIF_Emitter; use Erroutc.SARIF_Emitter; @@ -43,6 +44,7 @@ with Lib; use Lib; with Opt; use Opt; with Nlists; use Nlists; with Output; use Output; +with Rident; use Rident; with Scans; use Scans; with Sem_Aux; use Sem_Aux; with Sinput; use Sinput; @@ -237,6 +239,10 @@ package body Errout is -- Insert a switch to the printers swtiches list by adding them in -- the same order as they are defined (alphanumerically). + procedure Insert_Restriction (R : Restriction_Id); + -- Insert a restriction to the printers restriction list by adding them + -- in the same order as they are defined. + ----------------------- -- Insert_Diagnostic -- ----------------------- @@ -260,6 +266,35 @@ package body Errout is Append (Printer.Diagnostics, D); end Insert_Diagnostic; + ------------------------ + -- Insert_Restriction -- + ------------------------ + + procedure Insert_Restriction (R : Restriction_Id) is + use Restriction_Id_Lists; + It : Iterator := Iterate (Printer.Restrictions); + El : Restriction_Id; + begin + -- Do not add a switch if the diagnostic was not using one + + if R = Not_A_Restriction_Id then + return; + end if; + + while Has_Next (It) loop + Next (It, El); + + if El = R then + return; + elsif El > R then + Insert_Before (Printer.Restrictions, El, R); + return; + end if; + end loop; + + Append (Printer.Restrictions, R); + end Insert_Restriction; + ------------------- -- Insert_Switch -- ------------------- @@ -294,12 +329,14 @@ package body Errout is begin Printer.Diagnostics := Diagnostic_Id_Lists.Create; Printer.Switches := Switch_Id_Lists.Create; + Printer.Restrictions := Restriction_Id_Lists.Create; E_Id := First_Error_Msg; while E_Id /= No_Error_Msg loop E_Obj := Errors.Table (E_Id); Insert_Diagnostic (E_Obj.Id); Insert_Switch (E_Obj.Switch); + Insert_Restriction (E_Obj.Restriction); Next_Error_Msg (E_Id); end loop; @@ -1522,6 +1559,7 @@ package body Errout is Id => Error_Code, Switch => Get_Switch_Id (Error_Msg_Kind, Warning_Msg_Char), + Restriction => Diagnostic_Entries (Error_Code).Restriction, Fixes => First_Fix)); Cur_Msg := Errors.Last; diff --git a/gcc/ada/erroutc-sarif_emitter.adb b/gcc/ada/erroutc-sarif_emitter.adb index 4eee9bc98725..e49983777d9e 100644 --- a/gcc/ada/erroutc-sarif_emitter.adb +++ b/gcc/ada/erroutc-sarif_emitter.adb @@ -24,6 +24,7 @@ ------------------------------------------------------------------------------ with Errid.Diagnostic_Repository; use Errid.Diagnostic_Repository; +with Errid.Restriction_Repository; use Errid.Restriction_Repository; with Errid.Switch_Repository; use Errid.Switch_Repository; with JSON_Utils; use JSON_Utils; with Gnatvsn; use Gnatvsn; @@ -332,6 +333,16 @@ package body Erroutc.SARIF_Emitter is -- "name": <Human_Id(S)> -- }, + procedure Print_Rule (R : Restriction_Id); + -- Print a rule node that consists of the following attributes: + -- * ruleId + -- * name + -- + -- { + -- "id": <Restroction_Id>, + -- "name": <Restroction_Id>_Restriction + -- }, + procedure Print_Rules (Self : SARIF_Printer); -- Print a rules node that consists of multiple rule nodes. -- Rules are considered to be a set of unique diagnostics with the unique @@ -386,6 +397,10 @@ package body Erroutc.SARIF_Emitter is Diagnostic_Id_Lists.Destroy (Self.Diagnostics); end if; + if Restriction_Id_Lists.Present (Self.Restrictions) then + Restriction_Id_Lists.Destroy (Self.Restrictions); + end if; + if Switch_Id_Lists.Present (Self.Switches) then Switch_Id_Lists.Destroy (Self.Switches); end if; @@ -1146,6 +1161,7 @@ package body Erroutc.SARIF_Emitter is procedure Print_Rule (E : Diagnostic_Id) is Human_Id : constant String_Ptr := Diagnostic_Entries (E).Human_Id; Switch : constant Switch_Id := Diagnostic_Entries (E).Switch; + Restrict : constant Restriction_Id := Diagnostic_Entries (E).Restriction; begin Write_Char ('{'); Begin_Block; @@ -1171,6 +1187,20 @@ package body Erroutc.SARIF_Emitter is NL_And_Indent; Print_Relationship (Switches (Switch).Short_Name.all, "superset"); + End_Block; + NL_And_Indent; + Write_Char (']'); + + elsif Restrict /= Not_A_Restriction_Id then + Write_Char (','); + NL_And_Indent; + + Write_Str ("""" & N_RELATIONSHIPS & """" & ": " & "["); + Begin_Block; + + NL_And_Indent; + Print_Relationship (Restriction_Id'Image (Restrict), "superset"); + End_Block; NL_And_Indent; Write_Char (']'); @@ -1223,6 +1253,44 @@ package body Erroutc.SARIF_Emitter is Write_Char ('}'); end Print_Rule; + procedure Print_Rule (R : Restriction_Id) is + function Restriction_Name (R : Restriction_Id) return String + is (Restriction_Id'Image (R) & "_Restriction"); + + begin + pragma Assert (R /= Not_A_Restriction_Id); + + Write_Char ('{'); + Begin_Block; + NL_And_Indent; + + Write_String_Attribute (N_ID, Restriction_Id'Image (R)); + Write_Char (','); + NL_And_Indent; + + Write_String_Attribute (N_NAME, Restriction_Name (R)); + + if Rest_To_Diag_Mappping (R) /= No_Diagnostic_Id then + Write_Char (','); + NL_And_Indent; + + Write_Str ("""" & N_RELATIONSHIPS & """" & ": " & "["); + Begin_Block; + NL_And_Indent; + + Print_Relationship + (Diagnostic_Id'Image (Rest_To_Diag_Mappping (R)), "subset"); + + End_Block; + NL_And_Indent; + Write_Char (']'); + end if; + + End_Block; + NL_And_Indent; + Write_Char ('}'); + end Print_Rule; + ----------------- -- Print_Rules -- ----------------- @@ -1230,8 +1298,11 @@ package body Erroutc.SARIF_Emitter is procedure Print_Rules (Self : SARIF_Printer) is D : Diagnostic_Id; S : Switch_Id; + R : Restriction_Id; Diag_It : Diagnostic_Id_Lists.Iterator := Diagnostic_Id_Lists.Iterate (Self.Diagnostics); + Rest_It : Restriction_Id_Lists.Iterator := + Restriction_Id_Lists.Iterate (Self.Restrictions); Sw_It : Switch_Id_Lists.Iterator := Switch_Id_Lists.Iterate (Self.Switches); @@ -1262,6 +1333,15 @@ package body Erroutc.SARIF_Emitter is Print_Rule (S); end loop; + while Restriction_Id_Lists.Has_Next (Rest_It) loop + Restriction_Id_Lists.Next (Rest_It, R); + + Write_Char (','); + + NL_And_Indent; + Print_Rule (R); + end loop; + End_Block; NL_And_Indent; Write_Char (']'); diff --git a/gcc/ada/erroutc-sarif_emitter.ads b/gcc/ada/erroutc-sarif_emitter.ads index 0cc36a7044f0..e1c1078e043c 100644 --- a/gcc/ada/erroutc-sarif_emitter.ads +++ b/gcc/ada/erroutc-sarif_emitter.ads @@ -25,6 +25,15 @@ with GNAT.Lists; use GNAT.Lists; package Erroutc.SARIF_Emitter is + procedure Destroy (Elem : in out Restriction_Id) is null; + pragma Inline (Destroy); + package Restriction_Id_Lists is new Doubly_Linked_Lists + (Element_Type => Restriction_Id, + "=" => "=", + Destroy_Element => Destroy, + Check_Tampering => False); + subtype Restriction_Id_List is Restriction_Id_Lists.Doubly_Linked_List; + procedure Destroy (Elem : in out Switch_Id) is null; pragma Inline (Destroy); package Switch_Id_Lists is new Doubly_Linked_Lists @@ -61,7 +70,10 @@ package Erroutc.SARIF_Emitter is -- Unique diagnostics printed as rules in the SARIF report Switches : Switch_Id_List; - -- Unique switches printed as rules in the SARIF report + -- Unique switches printed as rules in the SARIF + + Restrictions : Restriction_Id_List; + -- Unique Restrictions printed as rules in the SARIF report Report_Type : Report_Kind := Diagnostic_Report; -- The type of report to be printed in SARIF diff --git a/gcc/ada/erroutc.ads b/gcc/ada/erroutc.ads index 0db58875c84d..a5d26fe78be3 100644 --- a/gcc/ada/erroutc.ads +++ b/gcc/ada/erroutc.ads @@ -27,9 +27,10 @@ -- reporting packages, including Errout and Prj.Err. with Table; -with Errid; use Errid; -with Osint; use Osint; -with Types; use Types; +with Errid; use Errid; +with Osint; use Osint; +with Rident; use Rident; +with Types; use Types; package Erroutc is @@ -353,6 +354,9 @@ package Erroutc is Id : Diagnostic_Id := No_Diagnostic_Id; -- Unique error code for the given message + Restriction : Restriction_Id := Not_A_Restriction_Id; + -- Restriction related to the diagnostic + Locations : Labeled_Span_Id := No_Labeled_Span; -- Identifier to the first location identified by the error message. -- These locations are marked with an underlying span line and diff --git a/gcc/ada/errutil.adb b/gcc/ada/errutil.adb index 1a789b539fc6..f1f9f13391b5 100644 --- a/gcc/ada/errutil.adb +++ b/gcc/ada/errutil.adb @@ -30,6 +30,7 @@ with Erroutc; use Erroutc; with Namet; use Namet; with Opt; use Opt; with Output; use Output; +with Rident; use Rident; with Scans; use Scans; with Sinput; use Sinput; with Stringt; use Stringt; @@ -217,6 +218,7 @@ package body Errutil is Kind => Error_Msg_Kind, Id => No_Diagnostic_Id, Switch => No_Switch_Id, + Restriction => Not_A_Restriction_Id, Locations => No_Labeled_Span, Fixes => No_Fix)); diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in index c0c1a0640f6b..43524ab5df33 100644 --- a/gcc/ada/gcc-interface/Make-lang.in +++ b/gcc/ada/gcc-interface/Make-lang.in @@ -331,6 +331,7 @@ GNAT_ADA_OBJS = \ ada/err_vars.o \ ada/errid.o \ ada/errid-diagnostic_repository.o \ + ada/errid-restriction_repository.o \ ada/errid-switch_repository.o \ ada/errout.o \ ada/erroutc.o \ @@ -623,6 +624,7 @@ GNATBIND_OBJS = \ ada/err_vars.o \ ada/errid.o \ ada/errid-diagnostic_repository.o \ + ada/errid-restriction_repository.o \ ada/errid-switch_repository.o \ ada/errout.o \ ada/erroutc.o \ diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index 32b394f66e18..acd34e0de8f2 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -337,6 +337,7 @@ GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \ seinfo.o einfo-entities.o einfo-utils.o sinfo-nodes.o sinfo-utils.o \ errid.o \ errid-diagnostic_repository.o \ + errid-restriction_repository.o \ errid-switch_repository.o \ erroutc-pretty_emitter.o \ erroutc-sarif_emitter.o \ diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb index 152ecfbf7f37..4b8ea7ed5bc9 100644 --- a/gcc/ada/restrict.adb +++ b/gcc/ada/restrict.adb @@ -23,23 +23,24 @@ -- -- ------------------------------------------------------------------------------ -with Atree; use Atree; -with Casing; use Casing; -with Einfo.Entities; use Einfo.Entities; -with Einfo.Utils; use Einfo.Utils; -with Errout; use Errout; -with Debug; use Debug; -with Fname; use Fname; -with Fname.UF; use Fname.UF; -with Lib; use Lib; -with Opt; use Opt; -with Sinfo.Nodes; use Sinfo.Nodes; -with Sinfo.Utils; use Sinfo.Utils; -with Sinput; use Sinput; -with Stand; use Stand; -with Targparm; use Targparm; -with Uname; use Uname; -with Warnsw; use Warnsw; +with Atree; use Atree; +with Casing; use Casing; +with Einfo.Entities; use Einfo.Entities; +with Einfo.Utils; use Einfo.Utils; +with Errid.Restriction_Repository; use Errid.Restriction_Repository; +with Errout; use Errout; +with Debug; use Debug; +with Fname; use Fname; +with Fname.UF; use Fname.UF; +with Lib; use Lib; +with Opt; use Opt; +with Sinfo.Nodes; use Sinfo.Nodes; +with Sinfo.Utils; use Sinfo.Utils; +with Sinput; use Sinput; +with Stand; use Stand; +with Targparm; use Targparm; +with Uname; use Uname; +with Warnsw; use Warnsw; package body Restrict is @@ -1246,13 +1247,19 @@ package body Restrict is end if; Add_Char ('!'); - Error_Msg_N (Msg (1 .. Len), N); + Error_Msg_N + (Msg => Msg (1 .. Len), + N => N, + Error_Code => Rest_To_Diag_Mappping (R)); -- Case of secondary profile continuation message present else Add_Char ('!'); - Error_Msg_N (Msg (1 .. Len), N); + Error_Msg_N + (Msg => Msg (1 .. Len), + N => N, + Error_Code => Rest_To_Diag_Mappping (R)); Len := 0; Add_Char ('\'); @@ -1277,7 +1284,10 @@ package body Restrict is -- Output unconditional message and we are done Add_Char ('!'); - Error_Msg_N (Msg (1 .. Len), N); + Error_Msg_N + (Msg => Msg (1 .. Len), + N => N, + Error_Code => Rest_To_Diag_Mappping (R)); end if; end Restriction_Msg;
