Skip to content

Commit

Permalink
Merge pull request #2195 from sconwayaus/proper_package_localparam
Browse files Browse the repository at this point in the history
[proper-parameter-declaration] change default behaviour
  • Loading branch information
hzeller authored Jun 11, 2024
2 parents 48a03f3 + 7093960 commit 23cda0c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ const LintRuleDescriptor &ProperParameterDeclarationRule::GetDescriptor() {
.param = {
{
.name = "package_allow_parameter",
.default_value = "true",
.default_value = "false",
.description = "Allow parameters in packages (treated as a "
"synonym for localparam).",
},
{
.name = "package_allow_localparam",
.default_value = "false",
.default_value = "true",
.description = "Allow localparams in packages.",
},
}};
Expand Down
4 changes: 2 additions & 2 deletions verilog/analysis/checkers/proper_parameter_declaration_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class ProperParameterDeclarationRule : public verible::SyntaxTreeLintRule {
private:
std::set<verible::LintViolation> violations_;

bool package_allow_parameter_ = true;
bool package_allow_localparam_ = false;
bool package_allow_parameter_ = false;
bool package_allow_localparam_ = true;
};

} // namespace analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ TEST(ProperParameterDeclarationRuleTest, RejectPackageParameters) {
"endmodule"},
};

RunConfiguredLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(
kTestCases,
"package_allow_parameter:false;package_allow_localparam:true");
RunLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(kTestCases);
}

// Tests that the expected number of localparam usage violations are found.
Expand Down Expand Up @@ -221,7 +219,9 @@ TEST(ProperParameterDeclarationRuleTest, AllowPackageParameters) {
"endpackage"},
};

RunLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(kTestCases);
RunConfiguredLintTestCases<VerilogAnalyzer, ProperParameterDeclarationRule>(
kTestCases,
"package_allow_parameter:true;package_allow_localparam:false");
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion verilog/tools/lint/testdata/endif_comment.sv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package endif_comment;
`ifdef FOOBAR
parameter int P = 4;
localparam int P = 4;
`endif
endpackage

0 comments on commit 23cda0c

Please sign in to comment.