diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h --- a/flang/include/flang/Lower/PFTBuilder.h +++ b/flang/include/flang/Lower/PFTBuilder.h @@ -55,8 +55,9 @@ using Ref = common::Reference>; ReferenceVariantBase() = delete; - template - ReferenceVariantBase(B &b) : u{Ref{b}} {} + ReferenceVariantBase(std::variant...> b) : u(b) {} + template + ReferenceVariantBase(Ref b) : u(b) {} template constexpr BaseType &get() const { diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp --- a/flang/lib/Lower/PFTBuilder.cpp +++ b/flang/lib/Lower/PFTBuilder.cpp @@ -64,8 +64,11 @@ class PFTBuilder { public: PFTBuilder(const semantics::SemanticsContext &semanticsContext) - : pgm{std::make_unique()}, - parentVariantStack{*pgm.get()}, semanticsContext{semanticsContext} {} + : pgm{std::make_unique()}, semanticsContext{ + semanticsContext} { + lower::pft::ParentVariant y{*pgm.get()}; + parentVariantStack.push_back(y); + } /// Get the result std::unique_ptr result() { return std::move(pgm); } @@ -905,11 +908,15 @@ template static lower::pft::FunctionLikeUnit::FunctionStatement getFunctionStmt(const T &func) { - return std::get>(func.t); + lower::pft::FunctionLikeUnit::FunctionStatement result{ + std::get>(func.t)}; + return Res; } template static lower::pft::ModuleLikeUnit::ModuleStatement getModuleStmt(const T &mod) { - return std::get>(mod.t); + lower::pft::ModuleLikeUnit::ModuleStatement result{ + std::get>(mod.t)}; + return Res; } static const semantics::Symbol *getSymbol( @@ -1078,7 +1085,8 @@ const auto &ps{ std::get>>(func.t)}; if (ps.has_value()) { - beginStmt = ps.value(); + FunctionStatement begin{ps.value()}; + beginStmt = begin; symbol = getSymbol(beginStmt); processSymbolTable(*symbol->scope()); } else {