From: Iain Buclaw Date: Sat, 9 Mar 2019 19:29:29 +0000 (+0000) Subject: d: Fix ICE in get_frame_for_symbol X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9fa5d5de369171b7149827fbc784aedb27eb6b84;p=gcc.git 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 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 --- diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index 305b22e793d..4d9fb99a8d8 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,9 @@ +2019-03-09 Iain Buclaw + + 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 * d-builtins.cc (d_init_versions): Add CppRuntime_Gcc as predefined diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc index 58c8257c63c..e8233b43c67 100644 --- a/gcc/d/d-codegen.cc +++ b/gcc/d/d-codegen.cc @@ -2172,7 +2172,16 @@ get_frame_for_symbol (Dsymbol *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) { @@ -2180,8 +2189,8 @@ get_frame_for_symbol (Dsymbol *sym) if (!thisfd->vthis) { error_at (make_location_t (sym->loc), - "is a nested function and cannot be accessed from %qs", - thisfd->toChars ()); + "%qs is a nested function and cannot be accessed from %qs", + fd->toPrettyChars (), thisfd->toPrettyChars ()); return null_pointer_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b1714e44109..cb4bf77efef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-09 Iain Buclaw + + PR d/89041 + * gdc.dg/pr89041.d: New test. + 2019-03-09 Thomas Koenig PR fortran/71544 diff --git a/gcc/testsuite/gdc.dg/pr89041.d b/gcc/testsuite/gdc.dg/pr89041.d new file mode 100644 index 00000000000..b62c2db85d4 --- /dev/null +++ b/gcc/testsuite/gdc.dg/pr89041.d @@ -0,0 +1,13 @@ +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89041 +module pr89041; + +enum dg = delegate {}; + +void fn() +{ + auto var = dg; + + auto inner() { + return dg(); + } +}