From 6a5e1dd24cd6c4091bc6341c7dc3cd7e38c73755 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Tue, 11 Jul 2023 13:17:21 +0930 Subject: [PATCH] Fix access of constant values in enumerations. The documentation is unclear and what worked in gcc 12 no longer works. --- src/notzed.nativez/native/export.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/notzed.nativez/native/export.cc b/src/notzed.nativez/native/export.cc index d8b183b..d5eca37 100644 --- a/src/notzed.nativez/native/export.cc +++ b/src/notzed.nativez/native/export.cc @@ -778,7 +778,7 @@ static void export_type(tree type, const char *names) { for (tree v = TYPE_VALUES(target); v != NULL; v = TREE_CHAIN (v)) { generate("\t{ name => '%s', value => '%ld' },\n", IDENTIFIER_POINTER(TREE_PURPOSE(v)), - tree_to_shwi(TREE_VALUE(v))); + tree_to_shwi(DECL_INITIAL(TREE_VALUE(v)))); } generate("]},\n"); break; @@ -973,7 +973,7 @@ static void export_type(tree type, const char *names) { for (tree v = TYPE_VALUES(type); v != NULL; v = TREE_CHAIN (v)) { generate("\t{ name => '%s', value => '%ld' },\n", IDENTIFIER_POINTER(TREE_PURPOSE(v)), - tree_to_shwi(TREE_VALUE(v))); + tree_to_shwi(DECL_INITIAL(TREE_VALUE(v)))); } generate("]},\n"); break; -- 2.39.5