From f100f6b8e2126a38c6bacb751eac2efaa7da395d Mon Sep 17 00:00:00 2001 From: rillig Date: Thu, 8 Mar 2007 14:31:06 +0000 Subject: [PATCH] Added a testcase for offsetof. Reorganized the rest. --- regress/compiler/Makefile | 23 +++++------------------ regress/compiler/files/Makefile | 29 +++++++++++++++++++++++++++++ regress/compiler/files/checklen.c | 2 ++ regress/compiler/files/checktype.c | 2 ++ regress/compiler/files/language.c | 7 +++++++ regress/compiler/files/offsetof.c | 9 +++++++++ 6 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 regress/compiler/files/Makefile create mode 100644 regress/compiler/files/language.c create mode 100644 regress/compiler/files/offsetof.c diff --git a/regress/compiler/Makefile b/regress/compiler/Makefile index 2d0c8a383605..e3cd81452df8 100644 --- a/regress/compiler/Makefile +++ b/regress/compiler/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2007/02/22 19:01:24 wiz Exp $ +# $NetBSD: Makefile,v 1.4 2007/03/08 14:31:06 rillig Exp $ # DISTNAME= compiler-1.1 @@ -11,25 +11,12 @@ COMMENT= Tests whether the pkgsrc compilers work as expected NO_CHECKSUM= yes WRKSRC= ${WRKDIR} -USE_TOOLS+= printf - -SRC_CMD= ${PRINTF} '\#if defined(__cplusplus)\nLANG: Cplus\n\#else\nLANG: Cplain\n\#endif\n' +USE_LANGUAGES= c c++ do-extract: - cd ${FILESDIR} && cp *.c ${WRKSRC} + cd ${FILESDIR} && cp Makefile *.c ${WRKSRC} + cd ${WRKSRC} && for i in *.c; do ln $$i $${i}c; done -do-build: - # Test whether CPP is a C preprocessor. - ${SRC_CMD} | cpp -DLANG=Cplain - # Test whether CXXCPP is a C++ preprocessor. - # CXXCPP is not (yet)? defined. - #${SRC_CMD} | cxxcpp -DLANG=Cplus - # Test whether white-space is preserved in macro definitions. - cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES=\"\ \ \ \ \" && ./checklen - cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES=\"" \"" && ./checklen - cd ${WRKSRC} && cc checklen.c -o checklen -DLEN=4 -DSPACES='" "' && ./checklen - # Test whether backslashes are preserved in macro definitions. - cd ${WRKSRC} && cc -c checktype.c -DTYPE="unsigned long" - cd ${WRKSRC} && cc -c checktype.c -DTYPE=unsigned\ long +do-wrksrc-build: .include "../../mk/bsd.pkg.mk" diff --git a/regress/compiler/files/Makefile b/regress/compiler/files/Makefile new file mode 100644 index 000000000000..a84217e4e58c --- /dev/null +++ b/regress/compiler/files/Makefile @@ -0,0 +1,29 @@ +# $NetBSD: Makefile,v 1.1 2007/03/08 14:31:06 rillig Exp $ +# + +all: \ + test-preprocessor \ + test-offsetof \ + test-wrapper + +test-preprocessor: + # Test whether CPP is a C preprocessor. + ${CPP} language.c | grep Cplain +.if defined(CXXCPP) + # Test whether CXXCPP is a C++ preprocessor. + ${CXXCPP} language.cc | grep Cplus +.endif + +test-wrapper: + # Test whether white-space is preserved in macro definitions. + ${CC} checklen.c -o checklen -DLEN=4 -DSPACES=\"\ \ \ \ \" && ./checklen + ${CC} checklen.c -o checklen -DLEN=4 -DSPACES=\"" \"" && ./checklen + ${CC} checklen.c -o checklen -DLEN=4 -DSPACES='" "' && ./checklen + # Test whether backslashes are preserved in macro definitions. + ${CC} -c checktype.c -DTYPE="unsigned long" + ${CC} -c checktype.c -DTYPE=unsigned\ long + +test-offsetof: + # Test whether offsetof is available in both C and C++ + ${CC} -c offsetof.c + ${CXX} -c offsetof.c diff --git a/regress/compiler/files/checklen.c b/regress/compiler/files/checklen.c index 92b91acafd41..2bc78216a379 100644 --- a/regress/compiler/files/checklen.c +++ b/regress/compiler/files/checklen.c @@ -1,3 +1,5 @@ +/* $NetBSD: checklen.c,v 1.2 2007/03/08 14:31:06 rillig Exp $ */ + #include #include diff --git a/regress/compiler/files/checktype.c b/regress/compiler/files/checktype.c index 5c13fc7de619..1d18b9086773 100644 --- a/regress/compiler/files/checktype.c +++ b/regress/compiler/files/checktype.c @@ -1 +1,3 @@ +/* $NetBSD: checktype.c,v 1.2 2007/03/08 14:31:06 rillig Exp $ */ + typedef TYPE t; diff --git a/regress/compiler/files/language.c b/regress/compiler/files/language.c new file mode 100644 index 000000000000..de171220b78b --- /dev/null +++ b/regress/compiler/files/language.c @@ -0,0 +1,7 @@ +/* $NetBSD: language.c,v 1.1 2007/03/08 14:31:07 rillig Exp $ */ + +#if defined(__cplusplus) +Cplus +#else +Cplain +#endif diff --git a/regress/compiler/files/offsetof.c b/regress/compiler/files/offsetof.c new file mode 100644 index 000000000000..de8ac7f4c753 --- /dev/null +++ b/regress/compiler/files/offsetof.c @@ -0,0 +1,9 @@ +/* $NetBSD: offsetof.c,v 1.1 2007/03/08 14:31:07 rillig Exp $ */ + +#include + +#if !defined(offsetof) +"force a syntax error" = 1; +#else +typedef int dummy; +#endif