This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: cpplib: understand long long constants in #if


Zack,

This patch allows numbers which are invalid in the last digit to pass
without error (e.g. 0x, 1y, etc.). I made the attached change to your
patch and installed it.

Dave

Zack Weinberg wrote:

> This patch's primary purpose is to make cpplib understand long long
> constants in #if (i.e. 12345678901234567890LL).  This is needed to
> compile the current glibc snapshots with --enable-cpplib.  The patch
> also does a bunch of cleanup on the number and character constant
> parsing code in cppexp.c.
>
> With this patch applied, egcs/--enable-cpplib bootstraps successfully
> and compiles glibc.  The only regressions vs cccp are due to lack of
> support for the -dM and -std switches in cpplib, and possibly also a
> problem with #include_next, -pedantic, and C++.  I will be looking
> into these soon.
>
> zw
>
> 1999-01-22 13:54 -0500  Zack Weinberg  <zack@rabi.columbia.edu>
>
>         * cppexp.c:
>             (struct arglist): Removed.
>             (parse_number): Use HOST_WIDE_INT for the accumulator.
>             Allow two `l' suffixes unless C89.  Clean up.  Make
>             static.
>             (parse_charconst): New function broken out of cpp_lex.
>             Code cleaned up drastically.  Don't use a token_buffer.
>             (token_buffer): Removed.
>             (cpp_lex): Don't call parse_number on a constant string.
>             Use parse_charconst.
>             (cpp_parse_expr): Properly handle an ERROR op returned by
>             cpp_lex.


*** /tmp/cppexp.c	Mon Jan 25 13:45:59 1999
--- ./cppexp.c	Mon Jan 25 13:54:10 1999
*************** parse_number (pfile, start, end)
*** 139,145 ****
  
    if (p[0] == '0')
      {
!       if (end - start >= 2 && (p[1] == 'x' || p[1] == 'X'))
  	{
  	  p += 2;
  	  base = 16;
--- 139,145 ----
  
    if (p[0] == '0')
      {
!       if (end - start >= 3 && (p[1] == 'x' || p[1] == 'X'))
  	{
  	  p += 2;
  	  base = 16;
*************** parse_number (pfile, start, end)
*** 182,188 ****
  	      else if (c == 'u' || c == 'U')
  		  op.unsignedp++;
  	      else
! 		break;
  	      if (p == end)
  		break;
  	      c = *p++;
--- 182,194 ----
  	      else if (c == 'u' || c == 'U')
  		  op.unsignedp++;
  	      else
! 		{
! 		  /* Decrement p here so that the error for an invalid number
! 		     will be generated below in the case where this is the
! 		     last character in the buffer.  */
! 		  p--;
! 		  break;
! 		}
  	      if (p == end)
  		break;
  	      c = *p++;

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