From e4deaba0ac5b801b1922f2088536ceac1c446eee Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 9 Jul 2022 13:18:46 +0100 Subject: [PATCH] Fix code generation failure with constant string in architecture --- src/dump.c | 1 + src/elab.c | 8 +++----- test/regress/const9.vhd | 15 +++++++++++++++ test/regress/testlist.txt | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 test/regress/const9.vhd diff --git a/src/dump.c b/src/dump.c index a3f318cc..88adad6e 100644 --- a/src/dump.c +++ b/src/dump.c @@ -1310,6 +1310,7 @@ static void dump_entity(tree_t t) printf(" );\n"); } dump_ports(t, 2); + dump_decls(t, 2); if (tree_stmts(t) > 0) { syntax("#begin\n"); for (unsigned i = 0; i < tree_stmts(t); i++) { diff --git a/src/elab.c b/src/elab.c index 615aa706..45e6c927 100644 --- a/src/elab.c +++ b/src/elab.c @@ -252,8 +252,8 @@ static void elab_find_config_roots(tree_t t, tree_list_t *roots) { tree_t what = tree_ref(t); if (tree_kind(what) == T_ARCH) { - APUSH(*roots, what); APUSH(*roots, tree_primary(what)); + APUSH(*roots, what); } } // Fall-through @@ -280,8 +280,6 @@ static tree_t elab_copy(tree_t t, elab_ctx_t *ctx) type_pred = elab_should_copy_type; tree_list_t roots = AINIT; - APUSH(roots, t); - switch (tree_kind(t)) { case T_ARCH: APUSH(roots, tree_primary(t)); @@ -292,12 +290,12 @@ static tree_t elab_copy(tree_t t, elab_ctx_t *ctx) default: fatal_trace("unexpected %s in elab_copy", tree_kind_str(tree_kind(t))); } - + APUSH(roots, t); // Architecture must be processed last tree_copy(roots.items, roots.count, elab_should_copy_tree, type_pred, elab_tree_copy_cb, elab_type_copy_cb, ©_ctx); - tree_t copy = roots.items[0]; + tree_t copy = roots.items[roots.count - 1]; ACLEAR(roots); // Change the name of any copied types to reflect the new hiearchy diff --git a/test/regress/const9.vhd b/test/regress/const9.vhd new file mode 100644 index 00000000..085ea822 --- /dev/null +++ b/test/regress/const9.vhd @@ -0,0 +1,15 @@ +entity const9 is + constant str : string := const9'path_name; +end entity; + +architecture test of const9 is +begin + + p1: process is + begin + report str; + assert str = ":const9:"; + wait; + end process; + +end architecture; diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index b69a4c64..4be973bc 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -616,3 +616,4 @@ attr17 normal,2002,gold signal23 normal,gold,2008 driver12 normal record33 normal,2008 +const9 normal -- 2.39.2