summaryrefslogtreecommitdiff
path: root/gcc/d/decl.cc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-03-29 16:57:10 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-04-02 23:56:52 +0200
commit235d5a96cb8dad0b4c427602346fcf966a4ec914 (patch)
treeca19c774a19ad923e5d6f09d43ee8d89c275a96e /gcc/d/decl.cc
parentbe07535d0f43390b8906826cc119473dea514b54 (diff)
d: Merge upstream dmd 47871363d, druntime, c52e28b7, phobos 99e9c1b77.
D front-end changes: - Import dmd v2.099.1-beta.1. - The address of NRVO variables is now stored in scoped closures when they have nested references. - Using `__traits(parameters)' in foreach loops now always returns the parameters to the function the foreach appears within. Previously, when used inside a `foreach' using an overloaded `opApply', the trait would yield the parameters to the delegate. - The deprecation period of unannotated `asm' blocks has been ended. - The `inout' attribute no longer implies the `return' attribute. - Added new `D_PreConditions', `D_PostConditions', and `D_Invariants' version identifiers. D runtime changes: - Import druntime v2.099.1-beta.1. Phobos changes: - Import phobos v2.099.1-beta.1. - `Nullable' in `std.typecons' can now act as a range. - std.experimental.logger default level changed to `info' instead of `warning'. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 47871363d. * d-builtins.cc (d_init_versions): Add predefined version identifiers D_PreConditions, D_PostConditions, and D_Invariants. * d-codegen.cc (d_build_call): Update for new front-end interface. (build_frame_type): Generate reference field for NRVO variables with nested references. (build_closure): Generate assignment of return address to closure. * d-tree.h (DECL_INSTANTIATED): Use DECL_LANG_FLAG_2. (bind_expr): Remove. * decl.cc (DeclVisitor::visit (FuncDeclaration *)): Update for new front-end interface. (get_symbol_decl): Likewise. (get_decl_tree): Check DECL_LANG_FRAME_FIELD before DECL_LANG_NRVO. Dereference the field when both are set. * expr.cc (ExprVisitor::visit (DeleteExp *)): Update for new front-end interface. * modules.cc (get_internal_fn): Likewise. * toir.cc (IRVisitor::visit (ReturnStatement *)): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime c52e28b7. * libdruntime/Makefile.am (DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/pwd.d. * libdruntime/Makefile.in: Regenerate. * src/MERGE: Merge upstream phobos 99e9c1b77. * testsuite/libphobos.exceptions/message_with_null.d: New test. gcc/testsuite/ChangeLog: * gdc.dg/nrvo1.d: New test.
Diffstat (limited to 'gcc/d/decl.cc')
-rw-r--r--gcc/d/decl.cc52
1 files changed, 29 insertions, 23 deletions
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 7ec0caf1bc0..ea8baef588c 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -791,7 +791,7 @@ public:
return;
}
- if (d->semantic3Errors)
+ if (d->hasSemantic3Errors ())
return;
if (d->isNested ())
@@ -805,7 +805,7 @@ public:
break;
/* Parent failed to compile, but errors were gagged. */
- if (fdp->semantic3Errors)
+ if (fdp->hasSemantic3Errors ())
return;
}
}
@@ -921,15 +921,6 @@ public:
}
}
- /* May change cfun->static_chain. */
- build_closure (d);
-
- if (d->vresult)
- declare_local_var (d->vresult);
-
- if (d->v_argptr)
- push_stmt_list ();
-
/* Named return value optimisation support for D.
Implemented by overriding all the RETURN_EXPRs and replacing all
occurrences of VAR with the RESULT_DECL for the function.
@@ -951,7 +942,7 @@ public:
else
d->shidden = resdecl;
- if (d->nrvo_can && d->nrvo_var)
+ if (d->isNRVO () && d->nrvo_var)
{
tree var = get_symbol_decl (d->nrvo_var);
@@ -966,6 +957,15 @@ public:
}
}
+ /* May change cfun->static_chain. */
+ build_closure (d);
+
+ if (d->vresult)
+ declare_local_var (d->vresult);
+
+ if (d->v_argptr)
+ push_stmt_list ();
+
build_function_body (d);
/* Initialize the _argptr variable. */
@@ -1284,26 +1284,26 @@ get_symbol_decl (Declaration *decl)
/* In [pragma/crtctor], Annotates a function so it is run after the C
runtime library is initialized and before the D runtime library is
initialized. */
- if (fd->isCrtCtorDtor == 1)
+ if (fd->isCrtCtor ())
{
DECL_STATIC_CONSTRUCTOR (decl->csym) = 1;
decl_init_priority_insert (decl->csym, DEFAULT_INIT_PRIORITY);
}
- else if (fd->isCrtCtorDtor == 2)
+ else if (fd->isCrtDtor ())
{
DECL_STATIC_DESTRUCTOR (decl->csym) = 1;
decl_fini_priority_insert (decl->csym, DEFAULT_INIT_PRIORITY);
- }
+ }
/* Function was declared `naked'. */
- if (fd->naked)
+ if (fd->isNaked ())
{
insert_decl_attribute (decl->csym, "naked");
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl->csym) = 1;
}
/* Mark compiler generated functions as artificial. */
- if (fd->generated)
+ if (fd->isGenerated ())
DECL_ARTIFICIAL (decl->csym) = 1;
/* Ensure and require contracts are lexically nested in the function they
@@ -1486,20 +1486,26 @@ get_decl_tree (Declaration *decl)
if (vd == NULL || fd == NULL)
return t;
- /* Get the named return value. */
- if (DECL_LANG_NRVO (t))
- return DECL_LANG_NRVO (t);
-
/* Get the closure holding the var decl. */
if (DECL_LANG_FRAME_FIELD (t))
{
FuncDeclaration *parent = vd->toParent2 ()->isFuncDeclaration ();
tree frame_ref = get_framedecl (fd, parent);
- return component_ref (build_deref (frame_ref),
- DECL_LANG_FRAME_FIELD (t));
+ tree field = component_ref (build_deref (frame_ref),
+ DECL_LANG_FRAME_FIELD (t));
+ /* Frame field can also be a reference to the DECL_RESULT of a function.
+ Dereference it to get the value. */
+ if (DECL_LANG_NRVO (t))
+ field = build_deref (field);
+
+ return field;
}
+ /* Get the named return value. */
+ if (DECL_LANG_NRVO (t))
+ return DECL_LANG_NRVO (t);
+
/* Get the non-local `this' value by going through parent link
of nested classes, this routine pretty much undoes what
getRightThis in the frontend removes from codegen. */