ado@UUNET.UU.NET (Arthur David Olson) (01/17/90)
Index: cccp.c (We're running SunOS 4.0.3 on a Sun 3/280.) Description: gcc 1.36 fails to catch repeated #define arguments Repeat-By: Script started on Wed Jan 17 09:19:10 1990 elsie$ echo '#define macro(a, a)' > try.c elsie$ /usr/local/bin/gcc -E -v try.c gcc version 1.36 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 try.c GNU CPP version 1.36 # 1 "try.c" elsie$ exit script done on Wed Jan 17 09:19:28 1990 Fix: *** 1.3/cccp.c Wed Jan 17 09:19:53 1990 --- 1.4/cccp.c Wed Jan 17 09:19:56 1990 *************** *** 2841,2846 **** --- 2841,2865 ---- error ("unterminated parameter list in #define"); goto nope; } + { + struct arglist *otemp; + + for (otemp = temp->next; otemp != NULL; otemp = otemp->next) + if (temp->length == otemp->length && + strncmp(temp->name, otemp->name) == 0) { + U_CHAR *msg; + char *preamble = "repeated #define argument name ("; + char *postamble = ")"; + + msg = (U_CHAR *) alloca(strlen(preamble) + temp->length + + strlen(postamble) + 1); + (void) strcpy(msg, preamble); + (void) strncat(msg, temp->name, temp->length); + (void) strcat(msg, postamble); + error (msg); + goto nope; + } + } } ++bp; /* skip paren */ -- Arthur David Olson ado@alw.nih.gov ADO is a trademark of Ampex.
ado@UUNET.UU.NET (Arthur David Olson) (01/19/90)
Index: cccp.c (We're running SunOS 4.0.3 on a Sun 3/280.) Description: gcc 1.36 fails to catch repeated #define arguments Repeat-By: Script started on Wed Jan 17 09:19:10 1990 elsie$ echo '#define macro(a, a)' > try.c elsie$ /usr/local/bin/gcc -E -v try.c gcc version 1.36 /usr/local/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 try.c GNU CPP version 1.36 # 1 "try.c" elsie$ exit script done on Wed Jan 17 09:19:28 1990 Fix: *** 1.3/cccp.c Wed Jan 17 12:39:19 1990 --- 1.5/cccp.c Wed Jan 17 12:39:22 1990 *************** *** 2841,2846 **** --- 2841,2861 ---- error ("unterminated parameter list in #define"); goto nope; } + { + struct arglist *otemp; + + for (otemp = temp->next; otemp != NULL; otemp = otemp->next) + if (temp->length == otemp->length && + strncmp(temp->name, otemp->name, temp->length) == 0) { + U_CHAR *name; + + name = (U_CHAR *) alloca(temp->length + 1); + (void) strncpy(name, temp->name, temp->length); + name[temp->length] = '\0'; + error ("repeated #define argument name (%s)", name); + goto nope; + } + } } ++bp; /* skip paren */ -- Arthur David Olson ado@alw.nih.gov ADO is a trademark of Ampex.