Skip to content

Commit

Permalink
fix: Incorrect relative immediate operand validation (fixes #177)
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Sep 17, 2021
1 parent f7143c8 commit 614c86e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Diagnostics lost during JSON serialization
- Files with extension should not be set to hlasm in libs folder
- Lookahead mode does not work correctly when triggered from AINSERTed code
- Incorrect relative immediate operand validation

## [0.14.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/0.13.0...0.14.0) (2021-08-18)

Expand Down
8 changes: 6 additions & 2 deletions parser_library/src/expressions/mach_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ inline mach_expression::value_t mach_expr_binary<rel_addr>::evaluate(mach_evalua
}

auto result = target - location;
if (result.value_kind() == context::symbol_value_kind::ABS && result.get_abs() % 2 != 0)
add_diagnostic(diagnostic_op::error_ME003(get_range()));
if (result.value_kind() == context::symbol_value_kind::ABS)
{
if (result.get_abs() % 2 != 0)
add_diagnostic(diagnostic_op::error_ME003(get_range()));
result = mach_expression::value_t(result.get_abs() / 2);
}
return result;
}

Expand Down
21 changes: 18 additions & 3 deletions parser_library/test/checking/mach_instr_check_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ TEST(machine_instr_check_test, reloc_ImmS_out_of_range)
{
std::string input(
R"(
BRAS 1,DISP
LEN123 DS CL(64444)
DISP MVC 0(1),1
BRAS 1,DISP
DS CL(65532)
DISP MVC 0(1),1
)");
analyzer a(input);
a.analyze();
Expand All @@ -316,6 +316,21 @@ DISP MVC 0(1),1
ASSERT_EQ(a.diags().at(0).code, "M123");
}

TEST(machine_instr_check_test, reloc_ImmS_in_range)
{
std::string input(
R"(
BRAS 1,DISP
DS CL(65530)
DISP MVC 0(1),1
)");
analyzer a(input);
a.analyze();
a.collect_diags();
ASSERT_EQ(a.parser().getNumberOfSyntaxErrors(), (size_t)0);
ASSERT_EQ(a.diags().size(), (size_t)0);
}

TEST(machine_instr_check_test, mask_out_of_range)
{
std::string input(
Expand Down

0 comments on commit 614c86e

Please sign in to comment.