C & C++ PATCH: Correct "overflow" in yylex/real_yylex

Gavin Romig-Koch gavin@cygnus.com
Thu Jul 1 11:43:00 GMT 1999


OK for mainline?

This is the correction to the overflow test I mentioned yesterday.
The same problem is both the C and C++ lexers.  Also, there isn't 
really a need for the overflow flag, so I scrapped it too.

For gcc:
	* c-lex.c (yylex) : Correct the test for overflow when lexing
	integer literals.

For gcc/cp:
	* lex.c (real_yylex) : Correct the test for overflow when lexing
	integer literals.



Index: gcc/c-lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-lex.c,v
retrieving revision 1.51
diff -r1.51 gcc/c-lex.c
1486d1485
< 	int overflow = 0;
1618,1622d1616
< 		/* If the extra highest-order part ever gets anything in it,
< 		   the number is certainly too big.  */
< 		if (parts[TOTAL_PARTS - 1] != 0)
< 		  overflow = 1;
< 
1774,1778c1768,1774
< 	       then pedwarn. */
< 
< 	    warn = overflow;
< 	    if (warn)
< 	      pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
---
> 	       then pedwarn.  If the extra highest-order parts has something
> 	       in it, the number is too big.  */
> 	    if (parts[(HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2] != 0)
> 	      {
> 		warn = 1;
> 		pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
> 	      }
Index: gcc/cp/lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.116
diff -r1.116 gcc/cp/lex.c
3616d3615
< 	int overflow = 0;
3743,3747d3741
< 		/* If the extra highest-order part ever gets anything in it,
< 		   the number is certainly too big.  */
< 		if (parts[TOTAL_PARTS - 1] != 0)
< 		  overflow = 1;
< 
3899,3903c3893,3899
< 	       then pedwarn. */
< 
< 	    warn = overflow;
< 	    if (warn)
< 	      pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
---
> 	       then pedwarn.  If the extra highest-order parts has something
> 	       in it, the number is too big.  */
> 	    if (parts[(HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2] != 0)
> 	      {
> 		warn = 1;
> 		pedwarn ("integer constant is too large for this configuration of the compiler - truncated to %d bits", HOST_BITS_PER_WIDE_INT * 2);
> 	      }


More information about the Gcc-patches mailing list