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]

(C, C++) number lexing tweak


Don't crash on '0x'.  Applied.

1999-08-06  Jason Merrill  <jason@yorick.cygnus.com>

	* lex.c (real_yylex): We can have a number with no digits.

Index: c-lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-lex.c,v
retrieving revision 1.56
diff -c -p -r1.56 c-lex.c
*** c-lex.c	1999/08/04 19:55:29	1.56
--- c-lex.c	1999/08/07 00:57:52
*************** yylex ()
*** 1656,1663 ****
  	      }
  	  }
  
  	if (numdigits == 0)
! 	  abort ();
  
  	if (largest_digit >= base)
  	  error ("numeric constant contains digits beyond the radix");
--- 1656,1664 ----
  	      }
  	  }
  
+ 	/* This can happen on input like `int i = 0x;' */
  	if (numdigits == 0)
! 	  error ("numeric constant with no digits");
  
  	if (largest_digit >= base)
  	  error ("numeric constant contains digits beyond the radix");
Index: cp/lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.128
diff -c -p -r1.128 lex.c
*** cp/lex.c	1999/08/06 18:20:27	1.128
--- cp/lex.c	1999/08/07 00:57:52
*************** real_yylex ()
*** 3973,3980 ****
  	      }
  	  }
  
  	if (numdigits == 0)
! 	  my_friendly_abort (990710);
  
  	if (largest_digit >= base)
  	  error ("numeric constant contains digits beyond the radix");
--- 3973,3981 ----
  	      }
  	  }
  
+ 	/* This can happen on input like `int i = 0x;' */
  	if (numdigits == 0)
! 	  error ("numeric constant with no digits");
  
  	if (largest_digit >= base)
  	  error ("numeric constant contains digits beyond the radix");


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