c-parse.in (yyoverflow): New.
* c-parse.in (yyoverflow): New. * cp/parse.y (yyoverflow): New. * g++.dg/parse/stack1.C: New. * gcc.dg/20020425-1.c: New. From-SVN: r52779
This commit is contained in:
parent
5c5b228389
commit
6052bef039
@ -1,3 +1,8 @@
|
||||
2002-04-25 Richard Henderson <rth@redhat.com>
|
||||
|
||||
PR c/2161
|
||||
* c-parse.in (yyoverflow): New.
|
||||
|
||||
2002-04-25 Richard Henderson <rth@redhat.com>
|
||||
|
||||
PR c/2098
|
||||
|
@ -61,6 +61,41 @@ end ifobjc
|
||||
|
||||
/* Like YYERROR but do call yyerror. */
|
||||
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
|
||||
|
||||
/* Like the default stack expander, except (1) use realloc when possible,
|
||||
and (2) impose no hard maxiumum on stack size. */
|
||||
#define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
|
||||
do { \
|
||||
size_t newsize; \
|
||||
short *newss; \
|
||||
YYSTYPE *newvs; \
|
||||
newsize = *(YYSSZ) *= 2; \
|
||||
if (yyfree_stacks) \
|
||||
{ \
|
||||
newss = (short *) \
|
||||
really_call_realloc (*(SS), newsize * sizeof (short)); \
|
||||
newvs = (YYSTYPE *) \
|
||||
really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
newss = (short *) really_call_malloc (newsize * sizeof (short)); \
|
||||
if (newss) \
|
||||
memcpy (newss, *(SS), (SSSIZE)); \
|
||||
newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
|
||||
if (newvs) \
|
||||
memcpy (newvs, *(VS), (VSSIZE)); \
|
||||
} \
|
||||
if (!newss || !newvs) \
|
||||
{ \
|
||||
yyerror (MSG); \
|
||||
return 2; \
|
||||
} \
|
||||
yyfree_stacks = 1; \
|
||||
*(SS) = newss; \
|
||||
*(VS) = newvs; \
|
||||
} while (0)
|
||||
|
||||
%}
|
||||
|
||||
%start program
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-04-25 Richard Henderson <rth@redhat.com>
|
||||
|
||||
PR c/2161
|
||||
* parse.y (yyoverflow): New.
|
||||
|
||||
2002-04-25 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/5607
|
||||
|
@ -48,6 +48,40 @@ extern struct obstack permanent_obstack;
|
||||
/* Like YYERROR but do call yyerror. */
|
||||
#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
|
||||
|
||||
/* Like the default stack expander, except (1) use realloc when possible,
|
||||
and (2) impose no hard maxiumum on stack size. */
|
||||
#define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \
|
||||
do { \
|
||||
size_t newsize; \
|
||||
short *newss; \
|
||||
YYSTYPE *newvs; \
|
||||
newsize = *(YYSSZ) *= 2; \
|
||||
if (yyfree_stacks) \
|
||||
{ \
|
||||
newss = (short *) \
|
||||
really_call_realloc (*(SS), newsize * sizeof (short)); \
|
||||
newvs = (YYSTYPE *) \
|
||||
really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
newss = (short *) really_call_malloc (newsize * sizeof (short)); \
|
||||
if (newss) \
|
||||
memcpy (newss, *(SS), (SSSIZE)); \
|
||||
newvs = (YYSTYPE *) really_call_malloc (newsize * sizeof (YYSTYPE)); \
|
||||
if (newvs) \
|
||||
memcpy (newvs, *(VS), (VSSIZE)); \
|
||||
} \
|
||||
if (!newss || !newvs) \
|
||||
{ \
|
||||
yyerror (MSG); \
|
||||
return 2; \
|
||||
} \
|
||||
yyfree_stacks = 1; \
|
||||
*(SS) = newss; \
|
||||
*(VS) = newvs; \
|
||||
} while (0)
|
||||
|
||||
#define OP0(NODE) (TREE_OPERAND (NODE, 0))
|
||||
#define OP1(NODE) (TREE_OPERAND (NODE, 1))
|
||||
|
||||
|
14
gcc/testsuite/g++.dg/parse/stack1.C
Normal file
14
gcc/testsuite/g++.dg/parse/stack1.C
Normal file
@ -0,0 +1,14 @@
|
||||
/* PR c/2161: parser stack overflow. */
|
||||
/* { dg-do compile } */
|
||||
|
||||
#define ONE else if (0) { }
|
||||
#define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE
|
||||
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
|
||||
#define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
|
||||
|
||||
void foo()
|
||||
{
|
||||
if (0) { }
|
||||
/* 11,000 else if's. */
|
||||
THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU
|
||||
}
|
14
gcc/testsuite/gcc.dg/20020425-1.c
Normal file
14
gcc/testsuite/gcc.dg/20020425-1.c
Normal file
@ -0,0 +1,14 @@
|
||||
/* PR c/2161: parser stack overflow. */
|
||||
/* { dg-do compile } */
|
||||
|
||||
#define ONE else if (0) { }
|
||||
#define TEN ONE ONE ONE ONE ONE ONE ONE ONE ONE ONE
|
||||
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
|
||||
#define THOU HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
|
||||
|
||||
void foo()
|
||||
{
|
||||
if (0) { }
|
||||
/* 11,000 else if's. */
|
||||
THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU THOU
|
||||
}
|
Loading…
Reference in New Issue
Block a user