Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Non-POD types should return in memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Jun 1, 2013
1 parent f4bb34c commit b805b71
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
(FuncDeclaration::toObjFile): Set-up function for NRVO.
(build_tlssections): Align _tlsstart and _tlsend symbols to target
address size.
* d-ctype(TypeFunction::toSymbol): Mark functions returning non-POD
structs as TREE_ADDRESSABLE to force return in memory.
* d-decls.cc(FuncDeclaration::toSymbol): Propagate TREE_ADDRESSABLE
from the original function type.

2013-05-29 Iain Buclaw <ibuclaw@gdcproject.org>

Expand Down
9 changes: 8 additions & 1 deletion gcc/d/d-ctype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,16 @@ TypeFunction::toCtype (void)
// Function type can be reference by parameters, etc. Set ctype earlier?
ctype = build_function_type (ret_type, type_list);
TYPE_LANG_SPECIFIC (ctype) = build_d_type_lang_specific (this);

d_keep (ctype);

if (next->toBasetype()->ty == Tstruct)
{
// Non-POD structs must return in memory.
TypeStruct *ts = (TypeStruct *) next->toBasetype();
if (!ts->sym->isPOD())
TREE_ADDRESSABLE (ctype) = 1;
}

switch (linkage)
{
case LINKpascal:
Expand Down
1 change: 1 addition & 0 deletions gcc/d/d-decls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ FuncDeclaration::toSymbol (void)
{
TYPE_ATTRIBUTES (fntype) = TYPE_ATTRIBUTES (TREE_TYPE (fndecl));
TYPE_LANG_SPECIFIC (fntype) = TYPE_LANG_SPECIFIC (TREE_TYPE (fndecl));
TREE_ADDRESSABLE (fntype) = TREE_ADDRESSABLE (TREE_TYPE (fndecl));
TREE_TYPE (fndecl) = fntype;
d_keep (fntype);
}
Expand Down

0 comments on commit b805b71

Please sign in to comment.