[PATCH] Fix a warning when initializing symbol_flags

Saagar Jha saagar@saagarjha.com
Sat Sep 26 00:42:24 GMT 2020


Clang on certain platforms (such as arm64) will warn if a struct is
partially initialized:

symbols.c:199:35: error: missing field 'written' initializer [-Werror,-Wmissing-field-initializers]
2895  symbol_entry_t needle = { { { 0 }, hash, name, 0, 0, 0 } };

If we use empty braces we have the same effect but avoid the warning.

gas/ChangeLog:

	* symbols.c: Shorten an initializer for symbol_flags to be empty.
---
 gas/ChangeLog | 4 ++++
 gas/symbols.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1c692dd931..6f9e842330 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,7 @@
+2020-09-25  Saagar Jha  <saagar@saagarjha.com>
+
+	* symbols.c: Shorten an initializer for symbol_flags to be empty.
+
 2020-09-24  Jim Wilson  <jimw@sifive.com>
 
 	PR 26400
diff --git a/gas/symbols.c b/gas/symbols.c
index d6080886be..40d7ebc586 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -196,7 +196,7 @@ static void *
 symbol_entry_find (htab_t table, const char *name)
 {
   hashval_t hash = htab_hash_string (name);
-  symbol_entry_t needle = { { { 0 }, hash, name, 0, 0, 0 } };
+  symbol_entry_t needle = { { { }, hash, name, 0, 0, 0 } };
   return htab_find_with_hash (table, &needle, hash);
 }
 
-- 
2.28.0



More information about the Binutils mailing list