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]

Re: [rfa/pascal!] Gag -Werror shift warning and bug


Pierre Muller wrote:
> 
> After looking at the c-exp.y equivalent code, I suggest that you simply
> take that code,
> as it doesn't seem to suffer from the same problems

Good point.  I'll check in the attatched.

	thanks, Andrew
2001-03-17  Andrew Cagney  <ac131313@redhat.com>

	* p-exp.y (parse_number): Avoid shift overflow when ``long''.
	Code copied from c-exp.y.

*** GDB/src/gdb/p-exp.y	Tue Mar  6 10:38:28 2001
--- WIP/src/gdb/p-exp.y	Sat Mar 17 15:46:29 2001
***************
*** 858,871 ****
      }
    else
      {
!       high_bit = (((ULONGEST)1)
! 		  << (TARGET_LONG_LONG_BIT - 32 - 1)
! 		  << 16
! 		  << 16);
!       if (high_bit == 0)
  	/* A long long does not fit in a LONGEST.  */
! 	high_bit =
! 	  (ULONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
        unsigned_type = builtin_type_unsigned_long_long;
        signed_type = builtin_type_long_long;
      }
--- 858,870 ----
      }
    else
      {
!       int shift;
!       if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
  	/* A long long does not fit in a LONGEST.  */
! 	shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
!       else
! 	shift = (TARGET_LONG_LONG_BIT - 1);
!       high_bit = (ULONGEST) 1 << shift;
        unsigned_type = builtin_type_unsigned_long_long;
        signed_type = builtin_type_long_long;
      }

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