poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ICE] couldn't promote integral to integral struct


From: Jose E. Marchesi
Subject: Re: [ICE] couldn't promote integral to integral struct
Date: Wed, 06 Apr 2022 18:43:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)


> #!!# type a = struct uint<32> { uint<16> field1; uint<16> field2; };
> #!!# type b = struct { little uint<32> my_a; }
> #!!# var x = open("*data*");
> #!!# (b @ x : 0#B) as a;
> 1:2: internal compiler error: couldn't promote integral to integral struct
> Important information has been dumped in /tmp/pokeiQKOL3.
> Please attach it to a bug report and send it to poke-devel@gnu.org.

Fixed in the patch I just pushed, below.

>From 4dd9dccdf9d95581011b2b0008ae75588845e67b Mon Sep 17 00:00:00 2001
From: "Jose E. Marchesi" <jose.marchesi@oracle.com>
Date: Wed, 6 Apr 2022 18:42:28 +0200
Subject: [PATCH] pkl: promo: do not try to promote regular structs to integral
 structs

2022-04-06  Jose E. Marchesi  <jemarch@gnu.org>

        * libpoke/pkl-promo.c (pkl_promo_ps_cast): Do not try to promote
        regular structs to integral structs.
        * testsuite/poke.pkl/cast-int-struct-4.pk: New test.
        * testsuite/Makefile.am (EXTRA_DIST): Add new test.
---
 ChangeLog             | 7 +++++++
 libpoke/pkl-promo.c   | 4 +++-
 testsuite/Makefile.am | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fe8bc259..019f3870 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-04-06  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * libpoke/pkl-promo.c (pkl_promo_ps_cast): Do not try to promote
+       regular structs to integral structs.
+       * testsuite/poke.pkl/cast-int-struct-4.pk: New test.
+       * testsuite/Makefile.am (EXTRA_DIST): Add new test.
+
 2022-04-04  Jose E. Marchesi  <jemarch@gnu.org>
 
        * etc/Makefile.am (dist_lisp_DATA): Do not install poke-mode.
diff --git a/libpoke/pkl-promo.c b/libpoke/pkl-promo.c
index 91eb581e..4eab993f 100644
--- a/libpoke/pkl-promo.c
+++ b/libpoke/pkl-promo.c
@@ -1626,13 +1626,15 @@ PKL_PHASE_BEGIN_HANDLER (pkl_promo_ps_cast)
 {
   pkl_ast_node cast = PKL_PASS_NODE;
   pkl_ast_node exp = PKL_AST_CAST_EXP (cast);
+  pkl_ast_node from_type = PKL_AST_TYPE (exp);
   pkl_ast_node to_type = PKL_AST_CAST_TYPE (cast);
 
   if (PKL_AST_TYPE_CODE (to_type) == PKL_TYPE_STRUCT)
     {
       pkl_ast_node itype = PKL_AST_TYPE_S_ITYPE (to_type);
 
-      if (itype)
+      if (itype
+          && PKL_AST_TYPE_CODE (from_type) == PKL_TYPE_INTEGRAL)
         {
           int restart = 0;
 
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 059d2871..b8b5b40d 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -972,6 +972,7 @@ EXTRA_DIST = \
   poke.pkl/cast-int-struct-1.pk \
   poke.pkl/cast-int-struct-2.pk \
   poke.pkl/cast-int-struct-3.pk \
+  poke.pkl/cast-int-struct-4.pk \
   poke.pkl/cast-offsets-1.pk \
   poke.pkl/cast-offsets-2.pk \
   poke.pkl/cast-offsets-3.pk \
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]