-O gen-C++ fix for recent smart pointer changes

This commit is contained in:
Vern Paxson 2023-07-13 15:05:16 -07:00
parent bf6d030894
commit 10797bb955

View file

@ -406,14 +406,14 @@ void CPPCompile::GenWhenStmt(const WhenStmt* w)
Emit("{ // begin a new scope for internal variables");
Emit("static WhenInfo* CPP__wi = nullptr;");
Emit("static std::shared_ptr<WhenInfo> CPP__wi = nullptr;");
Emit("static IDSet CPP__w_globals;");
NL();
Emit("if ( ! CPP__wi )");
StartBlock();
Emit("CPP__wi = new WhenInfo(%s);", is_return);
Emit("CPP__wi = std::make_shared<WhenInfo>(%s);", is_return);
for ( auto& wg : wi->WhenExprGlobals() )
Emit("CPP__w_globals.insert(find_global__CPP(\"%s\").get());", wg->Name());
EndBlock();