diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-26 05:35:13 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-26 05:35:13 +0000 |
commit | deae487ab287f34088fdbdd50375dbfc954ad24f (patch) | |
tree | 8cb83d3dda7305192e25c976afb951b1ed9e5357 /gcc/c-parse.in | |
parent | fe5f236657f1802839c8d64b902396bf8cc063ac (diff) | |
download | gcc-deae487ab287f34088fdbdd50375dbfc954ad24f.tar.gz |
* c-parse.in (yyoverflow): New.
* cp/parse.y (yyoverflow): New.
* g++.dg/parse/stack1.C: New.
* gcc.dg/20020425-1.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52779 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 5835fe14e13..f3a3da8f999 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -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 |