-# $OpenBSD: Makefile,v 1.6 2013/08/01 21:26:30 kettenis Exp $
+# $OpenBSD: Makefile,v 1.7 2013/12/28 02:14:32 martynas Exp $
SUBDIR+= gcc libiberty
.if defined(REGRESS_FULL)
SUBDIR += gcc-bounds
+SUBDIR += gcc-builtins
.endif
install:
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2013/12/28 02:14:32 martynas Exp $
+
+GCC_BUILTINS= sprintf-1 sprintf-2 sprintf-3 stpcpy-1 stpcpy-2 strcat-1 \
+ strcat-2 strcpy-1 strcpy-2 strncat-1 vsprintf-1 vsprintf-2 \
+ vsprintf-3
+
+TCC= gcc
+TCFLAGS= -O2
+TCXXFLAGS= ${TCFLAGS}
+
+.for i in ${GCC_BUILTINS}
+REGRESS_TARGETS+= c-${i}
+c-${i}:
+ ${TCC} ${TCFLAGS} -o /dev/null ${i}.c 2>&1 | cut -d: -f2- | diff -u - ${.CURDIR}/${i}.c.exp
+.endfor
+
+generate:
+.for i in ${REGRESS_TARGETS}
+ -${TCC} ${TCFLAGS} -o /dev/null ${i:C/^c-//g}.c 2>&1 | cut -d: -f2- >${i:C/^c-//g}.c.exp
+.endfor
+
+.PHONY: ${REGRESS_TARGETS} generate regress
+
+NOOBJ= Yes
+
+.include <bsd.regress.mk>
--- /dev/null
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[512];
+ volatile int rv;
+
+ /* This expression cannot be folded. */
+ rv = sprintf(buf, "%s", argv[0]);
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: sprintf() is often misused, please use snprintf()
--- /dev/null
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[10];
+
+ /* This expression can be folded. */
+ sprintf(buf, "%s", "foo");
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: sprintf() is often misused, please use snprintf()
--- /dev/null
+#include <stdio.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[10];
+
+ /* This expression can be folded. */
+ sprintf(buf, "baz");
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: sprintf() is often misused, please use snprintf()
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[512];
+ volatile char *rv;
+
+ /* This expression cannot be folded. */
+ rv = stpcpy(buf, argv[0]);
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: stpcpy() is dangerous GNU crap; don't use it
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[10];
+
+ /* This expression can be folded. */
+ stpcpy(buf, "foo");
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: stpcpy() is dangerous GNU crap; don't use it
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[512];
+ volatile char *rv;
+
+ /* This expression cannot be folded. */
+ rv = strcat(buf, argv[0]);
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: strcat() is almost always misused, please use strlcat()
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[10];
+
+ /* This expression can be folded. */
+ strcat(buf, "foo");
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: strcat() is almost always misused, please use strlcat()
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[512];
+ volatile char *rv;
+
+ /* This expression cannot be folded. */
+ rv = strcpy(buf, argv[0]);
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: strcpy() is almost always misused, please use strlcpy()
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char buf[10];
+
+ /* This expression can be folded. */
+ strcpy(buf, "foo");
+
+ return (1);
+}
--- /dev/null
+ In function `main':
+ warning: strcpy() is almost always misused, please use strlcpy()
--- /dev/null
+#include <string.h>
+
+int
+main(int argc, char **argv)
+{
+ char foo[10];
+ const char bar[] = "bar";
+
+ /* The compiler should not simplify this into strcat. */
+ strncat(foo, bar, sizeof(foo));
+
+ return (1);
+}
--- /dev/null
+#include <stdio.h>
+#include <stdarg.h>
+
+void
+test_vsprintf(int unused, ...)
+{
+ char buf[512];
+ volatile int rv;
+ va_list ap;
+
+ va_start(ap, unused);
+
+ /* This expression cannot be folded. */
+ rv = vsprintf(buf, "%s", ap);
+
+ va_end(ap);
+}
+
+int
+main(int argc, char **argv)
+{
+ test_vsprintf(0, argv[0]);
+
+ return (1);
+}
--- /dev/null
+ In function `test_vsprintf':
+ warning: vsprintf() is often misused, please use vsnprintf()
--- /dev/null
+#include <stdio.h>
+#include <stdarg.h>
+
+void
+test_vsprintf(int unused, ...)
+{
+ char buf[10];
+ volatile int rv;
+ va_list ap;
+
+ va_start(ap, unused);
+
+ /* This expression can be folded. */
+ rv = vsprintf(buf, "%s", ap);
+
+ va_end(ap);
+}
+
+int
+main(int argc, char **argv)
+{
+ test_vsprintf(0, "foo");
+
+ return (1);
+}
--- /dev/null
+ In function `test_vsprintf':
+ warning: vsprintf() is often misused, please use vsnprintf()
--- /dev/null
+#include <stdio.h>
+#include <stdarg.h>
+
+void
+test_vsprintf(int unused, ...)
+{
+ char buf[10];
+ volatile int rv;
+ va_list ap;
+
+ va_start(ap, unused);
+
+ /* This expression can be folded. */
+ rv = vsprintf(buf, "bar", ap);
+
+ va_end(ap);
+}
+
+int
+main(int argc, char **argv)
+{
+ test_vsprintf(0);
+
+ return (1);
+}
--- /dev/null
+ In function `test_vsprintf':
+ warning: vsprintf() is often misused, please use vsnprintf()