This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: dwarf2read.c bug with unsigned type



Please commit this.  Thanks!

Fred Fish <fnf@ns1.ninemoons.com> writes:

> 
> In dwarf2read.c, there is an instance where the third argument to
> init_type() is the integer value "1" for creating an unsigned type,
> rather than an int with the TYPE_FLAG_UNSIGNED bit set to 1.
> 
> Luckily though, TYPE_FLAG_UNSIGNED is the LSB of the flag bits, so the
> two calls are binary equivalent.
> 
> This patch fixes the latent bug.
> 
> -Fred
> 
> 2001-12-08  Fred Fish  <fnf@redhat.com>
> 
> 	* dwarf2read.c (read_base_type): Rename is_unsigned to type_flags.
> 	For unsigned types set TYPE_FLAG_UNSIGNED and pass it to
> 	init_type().
> 
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 dwarf2read.c
> --- dwarf2read.c	2001/12/07 22:11:51	1.38
> +++ dwarf2read.c	2001/12/08 23:30:12
> @@ -2939,18 +2939,18 @@ read_base_type (struct die_info *die, st
>    if (attr && DW_STRING (attr))
>      {
>        enum type_code code = TYPE_CODE_INT;
> -      int is_unsigned = 0;
> +      int type_flags = 0;
>  
>        switch (encoding)
>  	{
>  	case DW_ATE_address:
>  	  /* Turn DW_ATE_address into a void * pointer.  */
>  	  code = TYPE_CODE_PTR;
> -	  is_unsigned = 1;
> +	  type_flags |= TYPE_FLAG_UNSIGNED;
>  	  break;
>  	case DW_ATE_boolean:
>  	  code = TYPE_CODE_BOOL;
> -	  is_unsigned = 1;
> +	  type_flags |= TYPE_FLAG_UNSIGNED;
>  	  break;
>  	case DW_ATE_complex_float:
>  	  code = TYPE_CODE_COMPLEX;
> @@ -2963,14 +2963,14 @@ read_base_type (struct die_info *die, st
>  	  break;
>  	case DW_ATE_unsigned:
>  	case DW_ATE_unsigned_char:
> -	  is_unsigned = 1;
> +	  type_flags |= TYPE_FLAG_UNSIGNED;
>  	  break;
>  	default:
>  	  complain (&dwarf2_unsupported_at_encoding,
>  		    dwarf_type_encoding_name (encoding));
>  	  break;
>  	}
> -      type = init_type (code, size, is_unsigned, DW_STRING (attr), objfile);
> +      type = init_type (code, size, type_flags, DW_STRING (attr), objfile);
>        if (encoding == DW_ATE_address)
>  	TYPE_TARGET_TYPE (type) = dwarf2_fundamental_type (objfile, FT_VOID);
>      }
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]