Skip to content

Commit

Permalink
Allow DPI imports to have an implicit return type
Browse files Browse the repository at this point in the history
  • Loading branch information
MikePopoloski committed Dec 15, 2023
1 parent 267adb4 commit f148698
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/parsing/Parser_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,8 +2090,10 @@ DPIImportSyntax& Parser::parseDPIImport(AttrList attributes) {
equals = expect(TokenKind::Equals);
}

auto& method = parseFunctionPrototype(SyntaxKind::Unknown, FunctionOptions::AllowEmptyArgNames |
FunctionOptions::IsPrototype);
auto& method = parseFunctionPrototype(SyntaxKind::Unknown,
FunctionOptions::AllowEmptyArgNames |
FunctionOptions::AllowImplicitReturn |
FunctionOptions::IsPrototype);

if (property.kind == TokenKind::PureKeyword && method.keyword.kind == TokenKind::TaskKeyword)
addDiag(diag::DPIPureTask, method.keyword.range()) << property.range();
Expand Down
9 changes: 9 additions & 0 deletions tests/unittests/parsing/MemberParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,3 +1164,12 @@ import "DPI-C" pure task bad_pure_dpi_t (logic [3:0] a);
REQUIRE(diagnostics.size() == 1);
CHECK(diagnostics[0].code == diag::DPIPureTask);
}

TEST_CASE("DPI implicit return parsing") {
auto& text = R"(
import "DPI-C" function dpi_f (logic [3:0] a);
)";

parseCompilationUnit(text);
CHECK_DIAGNOSTICS_EMPTY;
}

0 comments on commit f148698

Please sign in to comment.