Fixed false unused-function warnings for global initializers
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 3 Sep 2026 03:35:04 +0000 (04:35 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 3 Sep 2026 03:35:04 +0000 (04:35 +0100)
amd64.c
i386.c

diff --git a/amd64.c b/amd64.c
index fd74b8a2b6fa3da8f2203223486829f2283cec1e..6fee090b78ef13bf3c9a65abebe04a88621563a0 100644 (file)
--- a/amd64.c
+++ b/amd64.c
@@ -39582,14 +39582,21 @@ static void parse_global_initializer_values (int64_s *values, char **symbols, in
                 report_line_at (get_filename (), get_line_number (), REPORT_ERROR, tok.report_start, tok.report_caret, "expected identifier after '&'");
             } else {
             
-                char addr_symbol[256];
                 char *base_name = xstrdup (tok.ident);
+                char addr_symbol[256];
+                
                 long addr_offset = 0;
+                
                 int sym_index = find_global_symbol (base_name);
                 long array_count = get_global_symbol_array_count (base_name);
+                
                 long base_size = sym_index >= 0 ? global_symbols[sym_index].size : 0;
                 long elem_size = 0;
                 
+                if (sym_index >= 0) {
+                    global_symbols[sym_index].used = 1;
+                }
+                
                 if (array_count > 0 && base_size > 0) {
                     elem_size = base_size / array_count;
                 }
diff --git a/i386.c b/i386.c
index 5d79f62225a75ce526a6b02b19791f7063d7f1d4..6b0ad1a8f7139bc0298ee54eaf73b8d63450b7d7 100644 (file)
--- a/i386.c
+++ b/i386.c
@@ -37021,14 +37021,21 @@ static void parse_global_initializer_values (int64_s *values, char **symbols, in
                 report_line_at (get_filename (), get_line_number (), REPORT_ERROR, tok.report_start, tok.report_caret, "expected identifier after '&'");
             } else {
             
-                char addr_symbol[256];
                 char *base_name = xstrdup (tok.ident);
+                char addr_symbol[256];
+                
                 long addr_offset = 0;
+                
                 int sym_index = find_global_symbol (base_name);
                 long array_count = get_global_symbol_array_count (base_name);
+                
                 long base_size = sym_index >= 0 ? global_symbols[sym_index].size : 0;
                 long elem_size = 0;
                 
+                if (sym_index >= 0) {
+                    global_symbols[sym_index].used = 1;
+                }
+                
                 if (array_count > 0 && base_size > 0) {
                     elem_size = base_size / array_count;
                 }