diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2024-01-18 02:39:20 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2024-02-03 00:49:46 +0100 |
commit | f204359931866b917856fc959c70dbf55f28c14d (patch) | |
tree | ba1c671045e384fa49a6381f79abf7c1b84a55ea /gcc/d/expr.cc | |
parent | 5470a9b176c2b3030ff3891c7e9403db2b0685b8 (diff) | |
download | gcc-f204359931866b917856fc959c70dbf55f28c14d.zip gcc-f204359931866b917856fc959c70dbf55f28c14d.tar.gz gcc-f204359931866b917856fc959c70dbf55f28c14d.tar.bz2 |
d: Merge dmd, druntime bce5c1f7b5, phobos e4d0dd513.
D front-end changes:
- Import latest changes from dmd v2.107.0-beta.1.
- Keywords like `__FILE__' are now always evaluated at the
callsite.
D runtime changes:
- Import latest changes from druntime v2.107.0-beta.1.
- Added `nameSig' field to TypeInfo_Class in object.d.
Phobos changes:
- Import latest changes from phobos v2.107.0-beta.1.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd bce5c1f7b5.
* d-attribs.cc (build_attributes): Update for new front-end interface.
* d-lang.cc (d_parse_file): Likewise.
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Likewise.
* expr.cc (build_lambda_tree): New function.
(ExprVisitor::visit (FuncExp *)): Use build_lambda_tree.
(ExprVisitor::visit (SymOffExp *)): Likewise.
(ExprVisitor::visit (VarExp *)): Likewise.
* typeinfo.cc (create_tinfo_types): Add two ulong fields to internal
TypeInfo representation.
(TypeInfoVisitor::visit (TypeInfoClassDeclaration *)): Emit stub data
for TypeInfo_Class.nameSig.
(TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Update for new
front-end interface.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime bce5c1f7b5.
* src/MERGE: Merge upstream phobos e4d0dd513.
Diffstat (limited to 'gcc/d/expr.cc')
-rw-r--r-- | gcc/d/expr.cc | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 7e63b0b..6f596c5 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -204,6 +204,22 @@ binop_assignment (tree_code code, Expression *e1, Expression *e2) return compound_expr (lexpr, expr); } +/* Compile the function literal body. */ + +static void +build_lambda_tree (FuncLiteralDeclaration *fld, Type *type = NULL) +{ + /* This check is for lambda's, remove `vthis' as function isn't nested. */ + if (fld->tok == TOK::reserved && (type == NULL || type->ty == TY::Tpointer)) + { + fld->tok = TOK::function_; + fld->vthis = NULL; + } + + /* Compile the function literal body. */ + build_decl_tree (fld); +} + /* Implements the visitor interface to build the GCC trees of all Expression AST classes emitted from the D Front-end. All visit methods accept one parameter E, which holds the frontend AST @@ -2012,17 +2028,8 @@ public: void visit (FuncExp *e) final override { - Type *ftype = e->type->toBasetype (); - - /* This check is for lambda's, remove `vthis' as function isn't nested. */ - if (e->fd->tok == TOK::reserved && ftype->ty == TY::Tpointer) - { - e->fd->tok = TOK::function_; - e->fd->vthis = NULL; - } - - /* Compile the function literal body. */ - build_decl_tree (e->fd); + /* Compile the declaration. */ + build_lambda_tree (e->fd, e->type->toBasetype ()); /* If nested, this will be a trampoline. */ if (e->fd->isNested ()) @@ -2071,6 +2078,10 @@ public: if (e->var->isFuncDeclaration ()) result = maybe_reject_intrinsic (result); + /* Emit lambdas, same as is done in FuncExp. */ + if (FuncLiteralDeclaration *fld = e->var->isFuncLiteralDeclaration ()) + build_lambda_tree (fld); + if (declaration_reference_p (e->var)) gcc_assert (POINTER_TYPE_P (TREE_TYPE (result))); else @@ -2105,19 +2116,9 @@ public: return; } - /* This check is same as is done in FuncExp for lambdas. */ - FuncLiteralDeclaration *fld = e->var->isFuncLiteralDeclaration (); - if (fld != NULL) - { - if (fld->tok == TOK::reserved) - { - fld->tok = TOK::function_; - fld->vthis = NULL; - } - - /* Compiler the function literal body. */ - build_decl_tree (fld); - } + /* Emit lambdas, same as is done in FuncExp. */ + if (FuncLiteralDeclaration *fld = e->var->isFuncLiteralDeclaration ()) + build_lambda_tree (fld); if (this->constp_) { |