[binutils-gdb] Work around gcc9 warning bug

Alan Modra amodra@sourceware.org
Tue Apr 30 12:35:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8107ddcea1da07f1c4e902c17f045684beb78079

commit 8107ddcea1da07f1c4e902c17f045684beb78079
Author: Alan Modra <amodra@gmail.com>
Date:   Mon Apr 29 09:17:05 2019 +0930

    Work around gcc9 warning bug
    
    	* wrstabs.c (stab_start_class_type): Add assert to work around
    	gcc9 warning.  Tidy.

Diff:
---
 binutils/ChangeLog |  5 +++++
 binutils/wrstabs.c | 22 +++++++++-------------
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8fbc761..364fddb 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2019-04-30  Alan Modra  <amodra@gmail.com>
+
+	* wrstabs.c (stab_start_class_type): Add assert to work around
+	gcc9 warning.  Tidy.
+
 2019-04-24  Nick Clifton  <nickc@redhat.com>
 
 	* objcopy.c (strip_main): Do not enable note merging by default if
diff --git a/binutils/wrstabs.c b/binutils/wrstabs.c
index 3d1839f..3e941dc 100644
--- a/binutils/wrstabs.c
+++ b/binutils/wrstabs.c
@@ -1440,18 +1440,15 @@ stab_end_struct_type (void *p)
 /* Start outputting a class.  */
 
 static bfd_boolean
-stab_start_class_type (void *p, const char *tag, unsigned int id, bfd_boolean structp, unsigned int size, bfd_boolean vptr, bfd_boolean ownvptr)
+stab_start_class_type (void *p, const char *tag, unsigned int id,
+		       bfd_boolean structp, unsigned int size,
+		       bfd_boolean vptr, bfd_boolean ownvptr)
 {
   struct stab_write_handle *info = (struct stab_write_handle *) p;
-  bfd_boolean definition;
-  char *vstring;
+  bfd_boolean definition = FALSE;
+  char *vstring = NULL;
 
-  if (! vptr || ownvptr)
-    {
-      definition = FALSE;
-      vstring = NULL;
-    }
-  else
+  if (vptr && !ownvptr)
     {
       definition = info->type_stack->definition;
       vstring = stab_pop_type (info);
@@ -1472,17 +1469,16 @@ stab_start_class_type (void *p, const char *tag, unsigned int id, bfd_boolean st
 	}
       else
 	{
+	  assert (vstring);
 	  vtable = (char *) xmalloc (strlen (vstring) + 3);
 	  sprintf (vtable, "~%%%s", vstring);
 	  free (vstring);
+	  if (definition)
+	    info->type_stack->definition = TRUE;
 	}
-
       info->type_stack->vtable = vtable;
     }
 
-  if (definition)
-    info->type_stack->definition = TRUE;
-
   return TRUE;
 }



More information about the Binutils-cvs mailing list