From: Not Zed Date: Tue, 11 Jul 2023 03:47:21 +0000 (+0930) Subject: Fix access of constant values in enumerations. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=6a5e1dd24cd6c4091bc6341c7dc3cd7e38c73755;p=nativez Fix access of constant values in enumerations. The documentation is unclear and what worked in gcc 12 no longer works. --- 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;