From 23382fa5b5971d1bf30a6ce4c7bd49e3ef10e902 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Wed, 20 Nov 2024 01:44:28 +0100 Subject: [PATCH] Add optional template arguments to please GCC4.8 Clang on macos as well as GCC 4.8 complains when those templates are missing. gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Add template to tl::optional. * hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Likewise. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/hir/rust-ast-lower-expr.cc | 5 +++-- gcc/rust/hir/rust-ast-lower-type.cc | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index fb24a72efa70..a8c07303bd1c 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -517,8 +517,9 @@ ASTLoweringExpr::visit (AST::StructExprStructFields &struct_expr) { HIR::Expr *translated_base = ASTLoweringExpr::translate ( struct_expr.get_struct_base ().get_base_struct ()); - base = tl::optional (Rust::make_unique ( - std::unique_ptr (translated_base))); + base = tl::optional> ( + Rust::make_unique ( + std::unique_ptr (translated_base))); } auto const &in_fields = struct_expr.get_fields (); diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc index c1bfe213aa17..553c9c9612da 100644 --- a/gcc/rust/hir/rust-ast-lower-type.cc +++ b/gcc/rust/hir/rust-ast-lower-type.cc @@ -503,9 +503,11 @@ ASTLowerGenericParam::visit (AST::TypeParam ¶m) } } - auto type = param.has_type () ? tl::optional (std::unique_ptr ( - ASTLoweringType::translate (param.get_type ()))) - : tl::nullopt; + tl::optional> type = tl::nullopt; + if (param.has_type ()) + type + = tl::optional> (std::unique_ptr ( + ASTLoweringType::translate (param.get_type ()))); auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (),