Userland: Silence or resolve new GCC 13 warnings

GCC 13 produces the following true positive warnings:
- `-Wredundant-move` when trying to move `result->tooltip()`, which
  is a const reference in `Assistant/main.cpp`
- `-Wuse-after-free` when freeing an environment variable before
  removing it from `s_malloced_environment_variables`
- `-Wdangling-pointer` when storing an AST node's `this` pointer to the
  interpreter's node stack in LibJS. This is not actually an issue, as
  it is popped when the scope ends, but GCC has no way of telling this.
This commit is contained in:
Daniel Bertalan 2023-05-11 11:04:30 +02:00 committed by Andreas Kling
parent 2123fdd678
commit fc003cd248
3 changed files with 6 additions and 2 deletions

View file

@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& match = results_container.add<Assistant::ResultRow>();
match.set_icon(result->bitmap());
match.set_text(String::from_deprecated_string(result->title()).release_value_but_fixme_should_propagate_errors());
match.set_tooltip(move(result->tooltip()));
match.set_tooltip(result->tooltip());
match.on_click = [&result](auto) {
result->activate();
GUI::Application::the()->quit();

View file

@ -399,8 +399,8 @@ static void free_environment_variable_if_needed(char const* var)
{
if (!s_malloced_environment_variables.contains((FlatPtr)var))
return;
free(const_cast<char*>(var));
s_malloced_environment_variables.remove((FlatPtr)var);
free(const_cast<char*>(var));
}
char* getenv(char const* name)

View file

@ -48,7 +48,11 @@ public:
, m_chain_node { nullptr, node }
{
m_interpreter.vm().running_execution_context().current_node = &node;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-pointer"
// The node pointer is popped from the interpreter in the destructor.
m_interpreter.push_ast_node(m_chain_node);
#pragma GCC diagnostic push
}
~InterpreterNodeScope()