Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[slang] Fix PATHPULSE limit values #1048

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/diagnostics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ error WrongSpecifyDelayCount "expected one, two, three, six, or twelve delay val
error IfNoneEdgeSensitive "ifnone specify path cannot be an edge-sensitive path"
error PulseControlSpecifyParent "pulse control specparams can only be declared in specify blocks"
error PulseControlPATHPULSE "pulse control specparam names must start with 'PATHPULSE$'"
error PulseControlTwoValues "pulse control specparams must be assigned two values (reject limit and error limit)"
error TooManyEdgeDescriptors "cannot have more than six pairs of edge transitions in list"
error EdgeDescWrongKeyword "edge descriptor list cannot be used after '{}'"
error BindDirectiveInvalidName "bind target name must be a simple module or interface identifier when a list of instances is provided"
Expand Down
2 changes: 1 addition & 1 deletion source/parsing/Parser_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,7 @@ SpecparamDeclaratorSyntax& Parser::parseSpecparamDeclarator(SyntaxKind parentKin
if (parentKind != SyntaxKind::SpecifyBlock)
addDiag(diag::PulseControlSpecifyParent, name.range());
else if (!expr2)
addDiag(diag::PulseControlTwoValues, expr1.sourceRange()) << name.range();
expr2 = &expr1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not duplicate the expression here -- leaving it null seems fine. The parse tree must maintain the property that visiting the tokens in it via depth-first traversal recovers the original source file as typed by the user.

Copy link
Contributor Author

@likeamahoney likeamahoney Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in last commit with simple code refactoring

}
else if (expr2) {
auto last = expr2->getLastToken();
Expand Down
19 changes: 16 additions & 3 deletions tests/unittests/parsing/MemberParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,20 @@ module m;
specparam PATHPULSE$a$b = (1:2:3, 4:5:6);
endspecify
endmodule

module m1;
specify
specparam PATHPULSE$ = 1;
specparam PATHPULSE$a$b = 1;
endspecify
endmodule

module m2;
specify
specparam PATHPULSE$ = (1);
specparam PATHPULSE$a$b = (1);
endspecify
endmodule
)";

parseCompilationUnit(text);
Expand All @@ -710,10 +724,9 @@ endmodule

parseCompilationUnit(text);

REQUIRE(diagnostics.size() == 3);
REQUIRE(diagnostics.size() == 2);
CHECK(diagnostics[0].code == diag::PulseControlSpecifyParent);
CHECK(diagnostics[1].code == diag::PulseControlTwoValues);
CHECK(diagnostics[2].code == diag::PulseControlPATHPULSE);
CHECK(diagnostics[1].code == diag::PulseControlPATHPULSE);
}

TEST_CASE("Invalid package decls") {
Expand Down