This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Fix handling of invalid octal constants
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 12 Jan 2003 16:10:39 -0800
- Subject: PATCH: Fix handling of invalid octal constants
- Reply-to: mark at codesourcery dot com
This patch fixes PR c++/9264, a case which caused the new parser to
crash on invalid octal constants.
Bootstrapped and tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2003-01-12 Mark Mitchell <mark@codesourcery.com>
PR c++/9264
* c-lex.c (c_lex): Set the token value to error_mark_node for
invalid numeric constants.
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.192
diff -c -5 -p -r1.192 c-lex.c
*** c-lex.c 10 Jan 2003 02:21:58 -0000 1.192
--- c-lex.c 13 Jan 2003 00:03:34 -0000
*************** c_lex (value)
*** 710,719 ****
--- 710,720 ----
switch (flags & CPP_N_CATEGORY)
{
case CPP_N_INVALID:
/* cpplib has issued an error. */
+ *value = error_mark_node;
break;
case CPP_N_INTEGER:
*value = interpret_integer (tok, flags);
break;
Index: testsuite/g++.dg/parse/octal1.C
===================================================================
RCS file: testsuite/g++.dg/parse/octal1.C
diff -N testsuite/g++.dg/parse/octal1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/parse/octal1.C 13 Jan 2003 00:03:44 -0000
***************
*** 0 ****
--- 1 ----
+ int i = 08; // { dg-error "" }