Fix C++23 compilation errors This doesn't start building the project with C++23 yet (that needs reach-out and discussion). In C++23, instantiating ~unique_ptr<T> requires T to be a complete type. So define some methods that instantiate this template later (out-of-line). Change-Id: I68d8ef73f4f7dc08b5762a73324cf98e8868b4d1 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/22480 Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: Victor Vianna <victorvianna@google.com>
diff --git a/src/gn/parse_tree.cc b/src/gn/parse_tree.cc index e4fba38..8173c90 100644 --- a/src/gn/parse_tree.cc +++ b/src/gn/parse_tree.cc
@@ -378,6 +378,10 @@ return ret; } +void AccessorNode::set_member(std::unique_ptr<IdentifierNode> i) { + member_ = std::move(i); +} + Value AccessorNode::ExecuteSubscriptAccess(Scope* scope, Err* err) const { const Value* base_value = scope->GetValue(base_.value(), true); if (!base_value) { @@ -685,6 +689,10 @@ return ret; } +void BlockNode::set_end(std::unique_ptr<EndNode> e) { + end_ = std::move(e); +} + // ConditionNode -------------------------------------------------------------- ConditionNode::ConditionNode() = default; @@ -813,6 +821,10 @@ return ret; } +void FunctionCallNode::set_args(std::unique_ptr<ListNode> a) { + args_ = std::move(a); +} + void FunctionCallNode::SetNewLocation(int line_number) { Location func_old_loc = function_.location(); Location func_new_loc = @@ -954,6 +966,10 @@ return ret; } +void ListNode::set_end(std::unique_ptr<EndNode> e) { + end_ = std::move(e); +} + template <typename Comparator> void ListNode::SortList(Comparator comparator) { // Partitions first on BlockCommentNodes and sorts each partition separately.
diff --git a/src/gn/parse_tree.h b/src/gn/parse_tree.h index f3aeb58..471d6cb 100644 --- a/src/gn/parse_tree.h +++ b/src/gn/parse_tree.h
@@ -183,7 +183,7 @@ // The member is the identifier on the right hand side of the dot. Will be // null if the index is set. const IdentifierNode* member() const { return member_.get(); } - void set_member(std::unique_ptr<IdentifierNode> i) { member_ = std::move(i); } + void set_member(std::unique_ptr<IdentifierNode> i); void SetNewLocation(int line_number); @@ -292,7 +292,7 @@ static std::unique_ptr<BlockNode> NewFromJSON(const base::Value& value); void set_begin_token(const Token& t) { begin_token_ = t; } - void set_end(std::unique_ptr<EndNode> e) { end_ = std::move(e); } + void set_end(std::unique_ptr<EndNode> e); const EndNode* End() const { return end_.get(); } ResultMode result_mode() const { return result_mode_; } @@ -391,7 +391,7 @@ void set_function(Token t) { function_ = t; } const ListNode* args() const { return args_.get(); } - void set_args(std::unique_ptr<ListNode> a) { args_ = std::move(a); } + void set_args(std::unique_ptr<ListNode> a); const BlockNode* block() const { return block_.get(); } void set_block(std::unique_ptr<BlockNode> b) { block_ = std::move(b); } @@ -458,7 +458,7 @@ void set_begin_token(const Token& t) { begin_token_ = t; } const Token& Begin() const { return begin_token_; } - void set_end(std::unique_ptr<EndNode> e) { end_ = std::move(e); } + void set_end(std::unique_ptr<EndNode> e); const EndNode* End() const { return end_.get(); } void append_item(std::unique_ptr<ParseNode> s) {