From: Robert Pengelly Date: Thu, 3 Sep 2026 03:35:04 +0000 (+0100) Subject: Fixed false unused-function warnings for global initializers X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=bb22d552de51323ed2fa964ebc31a7006f54d54f;p=scc.git Fixed false unused-function warnings for global initializers --- diff --git a/amd64.c b/amd64.c index fd74b8a..6fee090 100644 --- 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 5d79f62..6b0ad1a 100644 --- 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; }