File tree Expand file tree Collapse file tree 5 files changed +35
-0
lines changed
testsuite/tests/gnatcheck_errors/invalid_lkql_rules_config Expand file tree Collapse file tree 5 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -530,6 +530,16 @@ only on SPARK code. Those symbols must also refer to an object value formatted l
530530 Ada_2022_In_Ghost_Code
531531 }
532532
533+ Please note that compiler based rules (:ref: `Warnings `, :ref: `Restrictions ` and
534+ :ref: `Style_Checks `) cannot be restricted to Ada or SPARK code. Consequently,
535+ the following configuration will raise an error:
536+
537+ ::
538+
539+ val spark_rules = @{
540+ Warnings: "a"
541+ }
542+
533543.. note ::
534544
535545 Note that an LKQL rules config file may contain arbitrary computation logic; the only
Original file line number Diff line number Diff line change @@ -1213,6 +1213,16 @@ package body Gnatcheck.Rules.Rule_Table is
12131213 begin
12141214 -- If the rule is a compiler check then get the argument and process it
12151215 if Is_Compiler_Rule (R_Id) then
1216+ -- Ensure the source mode is "BOTH"
1217+ if Source_Mode_String /= " GENERAL" then
1218+ Error_In_Rule_File
1219+ (" cannot run compiler base rule "" "
1220+ & Rule_Name
1221+ & " "" only on "
1222+ & Source_Mode_String
1223+ & " code" );
1224+ end if ;
1225+
12161226 Instance := new Compiler_Instance (Instance_Name /= " " );
12171227 Instance.Rule := R_Id;
12181228 Instance.Defined_At := To_Unbounded_String (Output_Rule_File);
Original file line number Diff line number Diff line change 1+ val rules = @{
2+ Goto_Statements
3+ }
4+
5+ val ada_rules = @{
6+ Warnings: "a"
7+ }
Original file line number Diff line number Diff line change @@ -85,3 +85,9 @@ gnatcheck: error: Multiple instances with the same name: an_instance (instance_n
8585gnatcheck: error: no rule to check specified
8686try "gnatcheck --help" for more information.
8787>>>program returned status code 2
88+
89+ Compiler base rule in restricted rule set
90+ =========================================
91+
92+ gnatcheck: error: cannot run compiler base rule "warnings" only on ADA code (compiler_rule_in_restricted_source.lkql)
93+ >>>program returned status code 5
Original file line number Diff line number Diff line change 2626 lkql_rule_file : extra_param.lkql
2727- label : Multiple instance with the same name
2828 lkql_rule_file : instance_names.lkql
29+ - label : Compiler base rule in restricted rule set
30+ lkql_rule_file : compiler_rule_in_restricted_source.lkql
You can’t perform that action at this time.
0 commit comments