Patch by Junio C Hamano to workaround a gcc compiler bug.

The construct certain vintages of GCC (the one I have trouble
with is 3.2.3) have trouble with looks like the following:

    static struct st a;
    static struct st *p = &a;
    struct st { int foo; };
    static void init(void) { a.foo = 0; }

The problem disappears if we move the struct declaration up to
let the compiler know the shape of the struct before the first
definition uses it, like this:

    struct st { int foo; }; /* this has been moved up */
    static struct st a;
    static struct st *p = &a;
    static void init(void) { a.foo = 0; }
This commit is contained in:
Glenn L McGrath 2003-09-17 00:22:26 +00:00
parent 2570b43e82
commit d3612178b7

View File

@ -550,6 +550,29 @@ static int parselleft; /* copy of parsefile->lleft */
/* next character in input buffer */
static char *parsenextc; /* copy of parsefile->nextc */
struct strpush {
struct strpush *prev; /* preceding string on stack */
char *prevstring;
int prevnleft;
#ifdef CONFIG_ASH_ALIAS
struct alias *ap; /* if push was associated with an alias */
#endif
char *string; /* remember the string since it may change */
};
struct parsefile {
struct parsefile *prev; /* preceding file on stack */
int linno; /* current line */
int fd; /* file descriptor (or -1 if string) */
int nleft; /* number of chars left in this line */
int lleft; /* number of chars left in this buffer */
char *nextc; /* next char in buffer */
char *buf; /* input buffer */
struct strpush *strpush; /* for pushing strings at this level */
struct strpush basestrpush; /* so pushing one is fast */
};
static struct parsefile basepf; /* top level input file */
static char basebuf[IBUFSIZ]; /* buffer for top level input file */
static struct parsefile *parsefile = &basepf; /* current input file */
@ -1573,28 +1596,6 @@ static inline int varequal(const char *a, const char *b) {
static int loopnest; /* current loop nesting level */
struct strpush {
struct strpush *prev; /* preceding string on stack */
char *prevstring;
int prevnleft;
#ifdef CONFIG_ASH_ALIAS
struct alias *ap; /* if push was associated with an alias */
#endif
char *string; /* remember the string since it may change */
};
struct parsefile {
struct parsefile *prev; /* preceding file on stack */
int linno; /* current line */
int fd; /* file descriptor (or -1 if string) */
int nleft; /* number of chars left in this line */
int lleft; /* number of chars left in this buffer */
char *nextc; /* next char in buffer */
char *buf; /* input buffer */
struct strpush *strpush; /* for pushing strings at this level */
struct strpush basestrpush; /* so pushing one is fast */
};
/*
* The parsefile structure pointed to by the global variable parsefile
* contains information about the current file being read.