Commit 9fa5d5de by Iain Buclaw Committed by Iain Buclaw

d: Fix ICE in get_frame_for_symbol

When generating code for a non-nested delegate literal, there is no
context pointer required to pass to the function.

2019-03-09  Iain Buclaw  <ibuclaw@gdcproject.org>

gcc/d/
	PR d/89041
	* d-codegen.cc (get_frame_for_symbol): Delegate literals defined in
	global scope don't have a frame pointer.

gcc/testsuite/
	PR d/89041
	* gdc.dg/pr89041.d: New test.

From-SVN: r269533
parent 4ea60a39
2019-03-09 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/89041
* d-codegen.cc (get_frame_for_symbol): Delegate literals defined in
global scope don't have a frame pointer.
2019-03-01 Iain Buclaw <ibuclaw@gdcproject.org> 2019-03-01 Iain Buclaw <ibuclaw@gdcproject.org>
* d-builtins.cc (d_init_versions): Add CppRuntime_Gcc as predefined * d-builtins.cc (d_init_versions): Add CppRuntime_Gcc as predefined
......
...@@ -2172,7 +2172,16 @@ get_frame_for_symbol (Dsymbol *sym) ...@@ -2172,7 +2172,16 @@ get_frame_for_symbol (Dsymbol *sym)
fdparent = (FuncDeclaration *) sym; fdparent = (FuncDeclaration *) sym;
} }
gcc_assert (fdparent != NULL); /* Not a nested function, there is no frame pointer to pass. */
if (fdparent == NULL)
{
/* Only delegate literals report as being nested, even if they are in
global scope. */
gcc_assert (fd && fd->isFuncLiteralDeclaration ());
return null_pointer_node;
}
gcc_assert (thisfd != NULL);
if (thisfd != fdparent) if (thisfd != fdparent)
{ {
...@@ -2180,8 +2189,8 @@ get_frame_for_symbol (Dsymbol *sym) ...@@ -2180,8 +2189,8 @@ get_frame_for_symbol (Dsymbol *sym)
if (!thisfd->vthis) if (!thisfd->vthis)
{ {
error_at (make_location_t (sym->loc), error_at (make_location_t (sym->loc),
"is a nested function and cannot be accessed from %qs", "%qs is a nested function and cannot be accessed from %qs",
thisfd->toChars ()); fd->toPrettyChars (), thisfd->toPrettyChars ());
return null_pointer_node; return null_pointer_node;
} }
......
2019-03-09 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/89041
* gdc.dg/pr89041.d: New test.
2019-03-09 Thomas Koenig <tkoenig@gcc.gnu.org> 2019-03-09 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/71544 PR fortran/71544
......
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89041
module pr89041;
enum dg = delegate {};
void fn()
{
auto var = dg;
auto inner() {
return dg();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment