]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix ICE in build_deref, at d/d-codegen.cc:1650 [PR111650]
authorIain Buclaw <ibuclaw@gdcproject.org>
Fri, 19 Apr 2024 08:51:12 +0000 (10:51 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 21 Jan 2025 15:42:30 +0000 (16:42 +0100)
PR d/111650

gcc/d/ChangeLog:

* decl.cc (get_fndecl_arguments): Move generation of frame type to ...
(DeclVisitor::visit (FuncDeclaration *)): ... here, after the call to
build_closure.

gcc/testsuite/ChangeLog:

* gdc.dg/pr111650.d: New test.

(cherry picked from commit 4d4929fe0654d51b52a2bf6e6188d7aad0bf17ac)

gcc/d/decl.cc
gcc/testsuite/gdc.dg/pr111650.d [new file with mode: 0644]

index a2dd8b84c59f98cf1c6de1edca4609c49621e988..6c2705d9864f9324210169b225b7871105a714bc 100644 (file)
@@ -162,16 +162,6 @@ get_fndecl_arguments (FuncDeclaration *decl)
          tree parm_decl = get_symbol_decl (decl->vthis);
          DECL_ARTIFICIAL (parm_decl) = 1;
          TREE_READONLY (parm_decl) = 1;
-
-         if (decl->vthis->type == Type::tvoidptr)
-           {
-             /* Replace generic pointer with back-end closure type
-                (this wins for gdb).  */
-             tree frame_type = FRAMEINFO_TYPE (get_frameinfo (decl));
-             gcc_assert (frame_type != NULL_TREE);
-             TREE_TYPE (parm_decl) = build_pointer_type (frame_type);
-           }
-
          param_list = chainon (param_list, parm_decl);
        }
 
@@ -1047,6 +1037,16 @@ public:
     /* May change cfun->static_chain.  */
     build_closure (d);
 
+    /* Replace generic pointer with back-end closure type
+       (this wins for gdb).  */
+    if (d->vthis && d->vthis->type == Type::tvoidptr)
+      {
+       tree frame_type = FRAMEINFO_TYPE (get_frameinfo (d));
+       gcc_assert (frame_type != NULL_TREE);
+       tree parm_decl = get_symbol_decl (d->vthis);
+       TREE_TYPE (parm_decl) = build_pointer_type (frame_type);
+      }
+
     if (d->vresult)
       declare_local_var (d->vresult);
 
diff --git a/gcc/testsuite/gdc.dg/pr111650.d b/gcc/testsuite/gdc.dg/pr111650.d
new file mode 100644 (file)
index 0000000..4298a76
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+ref V require(K, V)(ref V[K] aa, K key, lazy V value);
+
+struct Root
+{
+    ulong[3] f;
+}
+
+Root[ulong] roots;
+
+Root getRoot(int fd, ulong rootID)
+{
+    return roots.require(rootID,
+    {
+            Root result;
+            inoLookup(fd, () => result);
+            return result;
+    }());
+}
+
+void inoLookup(int, scope Root delegate()) { }