From 6e1bb77101de9f550e70de17aa0254284feca6ea Mon Sep 17 00:00:00 2001 From: law Date: Sun, 31 Oct 1999 07:54:56 +0000 Subject: [PATCH] * cccp.c (macroexpand): Avoid out of range accesses for omitted arguments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30289 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/cccp.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 * 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 -- 2.7.4