Article View: gnu.gcc.bug
Article #1530Small addition
From: pasieka%sureal
Date: Fri, 11 Dec 1992 17:46
Date: Fri, 11 Dec 1992 17:46
55 lines
1984 bytes
1984 bytes
I have been looking at and modifying GCC 2.2.2 for the project I am
working on here at UMass. I have found what I consider to be a slight
error in the file stmt.c. Specifically the macro POPSTACK does not
correctly adjust the value of nesting_depth. The original macro is:
#define POPSTACK(STACK) \
do { int initial_depth = nesting_stack->depth; \
do { struct nesting *this = STACK; \
STACK = this->next; \
nesting_stack = this->all; \
nesting_depth = this->depth; \
obstack_free (&stmt_obstack, this); } \
while (nesting_depth > initial_depth); } while (0)
I have added to the last line a decrementation of nesting_depth as follows:
#define POPSTACK(STACK) \
do { int initial_depth = nesting_stack->depth; \
do { struct nesting *this = STACK; \
STACK = this->next; \
nesting_stack = this->all; \
nesting_depth = this->depth; \
obstack_free (&stmt_obstack, this); } \
while (nesting_depth > initial_depth); --nesting_depth; } while (0)
Given the following program:
main ()
{
int x, y, z;
y = 0;
z = 0;
for (x=1 ; x<10; x++) {
y++;
}
for (x=1 ; x<10; x++) {
z++;
}
}
the value of nesting_depth while parsing both y++ and z++ should be 2.
Without the change the value is correct while parsing y++ but is 3
while parsing z++.
Is this a bug or a feature?
Please feel free to contact me about this if I can provide more
information. I can be reached via email at pasieka@cs.umass.edu or by
phone at 413/545-2447.
-- Michael
Technical Details
Message-ID:
<9212111746.AA09786@sureal.cs.umass.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.umass.edu!pasieka%surealShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.umass.edu!pasieka%sureal From: pasieka%sureal@cs.umass.edu Subject: Small addition Message-ID: <9212111746.AA09786@sureal.cs.umass.edu> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 11 Dec 1992 17:46:21 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 56