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

Fix clang-18 compilation issue #1335

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
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
28 changes: 16 additions & 12 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -1913,20 +1913,10 @@ struct compound_statement_node
return open_brace;
}

auto add_statement(
auto add_statement(
std::unique_ptr<statement_node>&& statement,
int before_pos
)
-> bool
{
// Adopt this statement into our list of statements
statements.insert(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

[Explanation] This call causes deletion of the std::unique_ptr<statement_node>. As discussed in #1088 this causes trouble for clang-18 if compound_statement_node::add_statement() is defiend before statement_node::~statement_node().

statements.begin() + std::clamp( before_pos, 0, unchecked_narrow<int>(std::ssize(statements)) ),
std::move(statement)
);

return true;
}
) -> bool;

auto visit(auto& v, int depth) -> void;
};
Expand Down Expand Up @@ -2320,6 +2310,20 @@ auto alternative_node::visit(auto& v, int depth)
v.end(*this, depth);
}

auto compound_statement_node::add_statement(
std::unique_ptr<statement_node>&& statement,
int before_pos
)
-> bool
{
// Adopt this statement into our list of statements
statements.insert(
statements.begin() + std::clamp( before_pos, 0, unchecked_narrow<int>(std::ssize(statements)) ),
std::move(statement)
);

return true;
}

auto compound_statement_node::visit(auto& v, int depth)
-> void
Expand Down
Loading