Skip to content

Commit

Permalink
Fix crash on type mark error for protected func.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikLeberg committed Nov 29, 2024
1 parent 2d8f452 commit 6358fb5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,13 @@ class_t class_of(tree_t t)
case T_FUNC_BODY:
case T_FUNC_INST:
case T_FCALL:
case T_PROT_FCALL:
return C_FUNCTION;
case T_PROC_DECL:
case T_PROC_BODY:
case T_PROC_INST:
case T_PCALL:
case T_PROT_PCALL:
return C_PROCEDURE;
case T_ENTITY:
return C_ENTITY;
Expand Down
6 changes: 6 additions & 0 deletions test/parse/protected3.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fred4 is
type fred4_t is protected
impure function is_empty return boolean;
impure function hi_there return is_empty; -- error
end protected;
end package fred4;
22 changes: 22 additions & 0 deletions test/test_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -6960,6 +6960,27 @@ START_TEST(test_hang)
}
END_TEST

START_TEST(test_protected3)
{
opt_set_int(OPT_RELAXED, 1);
set_standard(STD_08);

input_from_file(TESTDIR "/parse/protected3.vhd");

const error_t expect[] = {
{ 4, "type mark does not denote a type or a subtype" },
{ -1, NULL }
};
expect_errors(expect);

parse_and_check(T_PACKAGE);

fail_unless(parse() == NULL);

check_expected_errors();
}
END_TEST

Suite *get_parse_tests(void)
{
Suite *s = suite_create("parse");
Expand Down Expand Up @@ -7127,6 +7148,7 @@ Suite *get_parse_tests(void)
tcase_add_test(tc_core, test_issue1038);
tcase_add_test(tc_core, test_issue1055);
tcase_add_test(tc_core, test_hang);
tcase_add_test(tc_core, test_protected3);
suite_add_tcase(s, tc_core);

return s;
Expand Down

0 comments on commit 6358fb5

Please sign in to comment.