Skip to content

Commit

Permalink
fix: False positive sequence symbol redefinition diagnostics generated
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Oct 7, 2022
1 parent c6b8b97 commit 211a860
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Produce only a warning when immediate operand overflows in machine instructions
- Relax PROCESS operand validation
- Syntax error while parsing the END language operands
- False positive sequence symbol redefinition diagnostics generated

## [1.4.0](https://github.com/eclipse/che-che4z-lsp-for-hlasm/compare/1.3.0...1.4.0) (2022-08-30)

Expand Down
8 changes: 4 additions & 4 deletions parser_library/src/processing/processing_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ bool processing_manager::seq_lookahead_active() const
return look_pr && look_pr->action == lookahead_action::SEQ;
}

bool processing_manager::lookahead_active() const { return procs_.back()->kind == processing_kind::LOOKAHEAD; }

statement_provider& processing_manager::find_provider()
{
if (attr_lookahead_active())
Expand Down Expand Up @@ -314,17 +316,15 @@ void processing_manager::register_sequence_symbol(context::id_index target, rang
auto symbol = hlasm_ctx_.get_opencode_sequence_symbol(target);
auto new_symbol = create_opencode_sequence_symbol(target, symbol_range);

bool seq_lookahead = seq_lookahead_active();

if (!symbol)
{
hlasm_ctx_.add_opencode_sequence_symbol(std::move(new_symbol));
if (seq_lookahead)
if (lookahead_active())
m_pending_seq_redifinitions.emplace_back(m_lookahead_seq_redifinitions.try_emplace(target).first);
}
else if (!(*symbol->access_opencode_symbol() == *new_symbol))
{
if (!seq_lookahead)
if (!lookahead_active())
add_diagnostic(diagnostic_op::error_E045(*target, symbol_range));
else if (auto it = m_lookahead_seq_redifinitions.find(target); it == m_lookahead_seq_redifinitions.end()
|| it->second.first != pending_seq_redifinition_state::lookahead_pending)
Expand Down
1 change: 1 addition & 0 deletions parser_library/src/processing/processing_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class processing_manager final : public processing_state_listener, public branch

bool attr_lookahead_active() const;
bool seq_lookahead_active() const;
bool lookahead_active() const;

statement_provider& find_provider();
void finish_processor();
Expand Down
26 changes: 26 additions & 0 deletions parser_library/test/processing/lookahead_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,29 @@ TEST(lookahead, combined_redefinition)

EXPECT_TRUE(matches_message_codes(a.diags(), { "E045", "E045", "E045" }));
}

TEST(lookahead, ord_with_aread)
{
std::string input = R"(
MACRO
MAC
&X AREAD
&X AREAD
MEND
*
AIF (L'X EQ 0).SKIP
MAC
.TEST
.TEST
MNOTE 'AAAA'
.SKIP ANOP
X DS C
END
)";

analyzer a(input);
a.analyze();
a.collect_diags();

EXPECT_TRUE(matches_message_codes(a.diags(), { "MNOTE" }));
}

0 comments on commit 211a860

Please sign in to comment.