aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeffrey A Law <law@cygnus.com>1999-10-31 07:54:56 +0000
committerJeff Law <law@gcc.gnu.org>1999-10-31 01:54:56 -0600
commitf5d236de11b9276e2573043083e279489289d246 (patch)
treebc5866b7ac6979c4d4dca84d20e8967695641095 /gcc
parent0d9009fd94a333be02f9843edaf649d8f1b289bd (diff)
downloadgcc-f5d236de11b9276e2573043083e279489289d246.zip
gcc-f5d236de11b9276e2573043083e279489289d246.tar.gz
gcc-f5d236de11b9276e2573043083e279489289d246.tar.bz2
cccp.c (macroexpand): Avoid out of range accesses for omitted arguments.
* cccp.c (macroexpand): Avoid out of range accesses for omitted arguments. From-SVN: r30289
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cccp.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c2b522c..48c9614 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+Sun Oct 31 01:53:30 1999 Jeffrey A Law (law@cygnus.com)
+
+ * cccp.c (macroexpand): Avoid out of range accesses for omitted
+ arguments.
+
Sat Oct 30 22:42:50 1999 Stephen L Moshier <moshier@mediaone.net>
* c-lex.c (yylex): Accept 'f' in mantissa of hex float constant.
diff --git a/gcc/cccp.c b/gcc/cccp.c
index 6f9c36c..0e77a91 100644
--- a/gcc/cccp.c
+++ b/gcc/cccp.c
@@ -8581,7 +8581,12 @@ macroexpand (hp, op)
Also count number of times each arg is used. */
xbuf_len = defn->length;
for (ap = defn->pattern; ap != NULL; ap = ap->next) {
- if (ap->stringify)
+ if (ap->stringify && args[ap->argno].stringified_length_bound == 0)
+ /* macarg is not called for omitted arguments, as a result
+ stringified_length_bound will be zero. We need to make
+ enough space for "". */
+ xbuf_len += 2;
+ else if (ap->stringify)
xbuf_len += args[ap->argno].stringified_length_bound;
else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
/* Add 4 for two newline-space markers to prevent