]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add initializers to field_of_this_result
authorTom Tromey <tromey@adacore.com>
Wed, 14 May 2025 13:59:16 +0000 (07:59 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 14 May 2025 15:14:24 +0000 (09:14 -0600)
This adds initializers to field_of_this_result, so that certain spots
don't have to memset it.  This approach seems safer and cleaner.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/c-exp.y
gdb/symtab.c
gdb/symtab.h

index f53a1383b72be5a079a2df7e35da736c70558568..bdf76744817860f8409e314a6253aa0b0de31b9a 100644 (file)
@@ -3042,10 +3042,6 @@ classify_name (struct parser_state *par_state, const struct block *block,
 
   std::string copy = copy_name (yylval.sval);
 
-  /* Initialize this in case we *don't* use it in this call; that way
-     we can refer to it unconditionally below.  */
-  memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
-
   bsym = lookup_symbol (copy.c_str (), block, SEARCH_VFT,
                        par_state->language ()->name_of_this ()
                        ? &is_a_field_of_this : NULL);
index 5147aee55d5ef0397017c37e16b72c2afdfe2708..313aa5ffa00561fc44db9addcf7d881af3120ed1 100644 (file)
@@ -2163,13 +2163,6 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
         domain_name (domain).c_str (), language_str (language));
     }
 
-  /* Make sure we do something sensible with is_a_field_of_this, since
-     the callers that set this parameter to some non-null value will
-     certainly use it later.  If we don't set it, the contents of
-     is_a_field_of_this are undefined.  */
-  if (is_a_field_of_this != NULL)
-    memset (is_a_field_of_this, 0, sizeof (*is_a_field_of_this));
-
   langdef = language_def (language);
 
   /* Search specified block and its superiors.  Don't search
index e547d109f356fbb41c98b8488611681d0cf1b0eb..0a57be5ed80b6d7038d694a3143cb0b4cf0af1a0 100644 (file)
@@ -2101,17 +2101,17 @@ struct field_of_this_result
      symbol was not found in 'this'.  If non-NULL, then one of the
      other fields will be non-NULL as well.  */
 
-  struct type *type;
+  struct type *type = nullptr;
 
   /* If the symbol was found as an ordinary field of 'this', then this
      is non-NULL and points to the particular field.  */
 
-  struct field *field;
+  struct field *field = nullptr;
 
   /* If the symbol was found as a function field of 'this', then this
      is non-NULL and points to the particular field.  */
 
-  struct fn_fieldlist *fn_field;
+  struct fn_fieldlist *fn_field = nullptr;
 };
 
 /* Find the definition for a specified symbol name NAME