Skip to content

Commit

Permalink
Fix use-after-move
Browse files Browse the repository at this point in the history
  • Loading branch information
Lai-YT authored and leewei05 committed Jul 12, 2024
1 parent 683cf36 commit 77afe44
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -423,15 +423,15 @@ decl: declaration_specifiers init_declarator_list_opt SEMICOLON {
// A record declaration that doesn't declare any identifier, e.g., `struct point {int x, int y};`.
if (init_decl_list.empty()) {
decl_list.push_back(std::move(decl));
}

auto& rec_decl = dynamic_cast<RecordDeclNode&>(*decl);
// Initialize record variable.
for (auto& init_decl : init_decl_list) {
if (init_decl) {
init_decl->type = ResolveType(rec_decl.type->Clone(), std::move(init_decl->type));
} else {
auto& rec_decl = dynamic_cast<RecordDeclNode&>(*decl);
// Initialize record variable.
for (auto& init_decl : init_decl_list) {
if (init_decl) {
init_decl->type = ResolveType(rec_decl.type->Clone(), std::move(init_decl->type));
}
decl_list.push_back(std::move(init_decl));
}
decl_list.push_back(std::move(init_decl));
}
}
$$ = std::make_unique<DeclStmtNode>(Loc(@1), std::move(decl_list));
Expand Down

0 comments on commit 77afe44

Please sign in to comment.