Commit 3cf22d8a authored by Jens Gustedt's avatar Jens Gustedt
Browse files

rework the annotations for multiply evaluated arguments

parent b0cf7826
......@@ -5,7 +5,8 @@ COPYCLOSED = "all rights reserved, "
LICENSECLOSED = SHORTLICENCE-closed.txt
COPY = "(C) copyright "
LICENSE = SHORTLICENCE-open.txt
TIDY = ../../parxxl/scripts/findSvnAuthors --type c --copy ${COPY} --lice ${LICENSE} --ofile
AUTH = ../scripts/AUTHORS.txt
TIDY = ../../parxxl/scripts/findSvnAuthors --type c --auth ${AUTH} --copy ${COPY} --lice ${LICENSE} --ofile
target : p99_generated.h check
......@@ -13,7 +14,11 @@ p99_generated.h : ../scripts/p99_generate.pl
../scripts/p99_generate.pl > $@
check : *.h
../scripts/p99_find_macros.pl p99_*.h | ../scripts/p99_find_ternary.pl | ../scripts/p99_find_args.pl
../scripts/p99_find_macros.pl p99_*.h | ../scripts/p99_find_ternary.pl | ../scripts/p99_find_args.pl --prefix="non VM types: "
../scripts/p99_find_macros.pl p99_*.h | ../scripts/p99_find_ternary.pl --sizeof | ../scripts/p99_find_args.pl --prefix="possible VLA: "
check-vla : *.h
../scripts/p99_find_macros.pl p99_*.h --sizeof | ../scripts/p99_find_ternary.pl --sizeof | ../scripts/p99_find_args.pl --prefix="watch for VLA: "
TAGS : *.h
etags *.h
......@@ -25,4 +30,4 @@ clean:
distclean : clean
tidy :
for f in *.h p99_conformity.c ; do ${TIDY} $$f ; done
for f in *.h p99_conformity.c p99_special.c ; do ${TIDY} $$f ; done
......@@ -135,7 +135,7 @@ P00_BLK_END
** @see P99_UNWIND to break through one or several nested guarded blocks
** @see P99_UNWIND_RETURN to return from the enclosing function
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_GUARDED_BLOCK, 0)
P00_DOCUMENT_WARN_VLA_ARGUMENT(P99_GUARDED_BLOCK, 0)
P00_DOCUMENT_DECLARATION_ARGUMENT(P99_GUARDED_BLOCK, 1)
P00_DOCUMENT_STATEMENT_ARGUMENT(P99_GUARDED_BLOCK, 4)
#define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER) \
......
......@@ -83,7 +83,7 @@ P99_MACRO_END(declare_enum_getname, T)
** to prefix it with `color' such that the documentation lands inside
** the one for `color'.
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_DECLARE_ENUM, 0)
P00_DOCUMENT_IDENTIFIER_ARGUMENT(P99_DECLARE_ENUM, 0)
P00_DOCUMENT_DECLARATION_ARGUMENT(P99_DECLARE_ENUM, 1)
P00_DOCUMENT_DECLARATION_ARGUMENT(P99_DECLARE_ENUM, 2)
P00_DOCUMENT_DECLARATION_ARGUMENT(P99_DECLARE_ENUM, 3)
......
......@@ -288,19 +288,19 @@ P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_ARE_ORDERED, 1)
P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_ARE_ORDERED, 2)
#define P99_ARE_ORDERED(OP, ...) P00_ARE_ORDERED(OP, P99_NARG(__VA_ARGS__), __VA_ARGS__)
#define P00_ARE_ORDERED(OP, N, ...) \
P99_IF_LT(N, 3) \
(P00_ARE_ORDERED2(OP,__VA_ARGS__)) \
#define P00_ARE_ORDERED(OP, N, ...) \
P99_IF_LT(N, 3) \
(P00_ARE_ORDERED2(OP,__VA_ARGS__)) \
(P00_ARE_ORDERED3(OP, P99_PRED(N), __VA_ARGS__))
#define P00_ARE_ORDERED2(OP, X, Y) (X) OP (Y)
#define P00_ARE_ORDERED3(OP, N, ...) \
((P99_SUB(0, 1, __VA_ARGS__)) \
OP P00_ARE_ORDERED_MID(OP, P99_PRED(N), __VA_ARGS__) \
#define P00_ARE_ORDERED3(OP, N, ...) \
((P99_SUB(0, 1, __VA_ARGS__)) \
OP P00_ARE_ORDERED_MID(OP, P99_PRED(N), __VA_ARGS__) \
OP (P99_SUB(N, 1, __VA_ARGS__)))
#define P00_ARE_ORDERED_MID(OP, N, ...) \
#define P00_ARE_ORDERED_MID(OP, N, ...) \
P99_FOR(OP, N, P00_ARE_ORDERED_OP, P00_ARE_ORDERED_AND, P99_SUB(1, N, __VA_ARGS__))
#define P00_ARE_ORDERED_AND(_0, X, _2) (X)) && ((X)
......@@ -322,9 +322,9 @@ P99_FOR(OP, N, P00_ARE_ORDERED_OP, P00_ARE_ORDERED_AND, P99_SUB(1, N, __VA_ARGS_
** @endcode
**/
P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_TOKJOIN, 0)
#define P99_TOKJOIN(TOK, ...) \
P99_IF_LT(P99_NARG(__VA_ARGS__), 2) \
(__VA_ARGS__) \
#define P99_TOKJOIN(TOK, ...) \
P99_IF_LT(P99_NARG(__VA_ARGS__), 2) \
(__VA_ARGS__) \
(P99_FOR(TOK, P99_NARG(__VA_ARGS__), P00_TOKJOIN, P00_IDT, __VA_ARGS__))
/**
......@@ -414,8 +414,9 @@ P00_DOCUMENT_MULTIPLE_ARGUMENT(P99_CDIM, 0)
** @brief Produce a list of the lengths of the argument array @a ARR in terms of number
** of elements in the first @a N dimensions.
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_ALENS, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALENS, 1)
#define P99_ALENS(X, N) P99_FOR(X, N, P00_ALENS0, P00_ALEN, P99_REP(N,))
#define P99_ALENS(ARR, N) P99_FOR(ARR, N, P00_ALENS0, P00_ALEN, P99_REP(N,))
#define P00_ACALL1(ARR) P99_ALENS(*ARR, 1), (ARR)
#define P00_ACALL2(ARR, N) P99_ALENS(*ARR, N), (ARR)
......@@ -449,6 +450,8 @@ P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALENS, 1)
** If @a ARR is actually just a pointer to an array, P99_ALEN(ARR, 0)
** is meaningless.
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_ALEN, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALEN, 1)
#define P99_ALEN(ARR, N)
/**
......@@ -493,6 +496,9 @@ P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALENS, 1)
** hide incompatibilities.
** @see P99_AARG
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_ACALL, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ACALL, 1)
P00_DOCUMENT_TYPE_ARGUMENT(P99_ACALL, 2)
#define P99_ACALL(ARR, N, TYPE)
/**
......@@ -516,11 +522,15 @@ P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALENS, 1)
** @see P99_ACALL
** @see P99_ALEN
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_AARG, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_AARG, 2)
#define P99_AARG(TYPE, NAME, DIM, VAR)
#else
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALENS, 1)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_ALEN, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ALEN, 1)
#define P99_ALEN(...) P99_IF_EQ_1(P99_NARG(__VA_ARGS__))(P00_ALEN(__VA_ARGS__, ,0))(P00_ALEN2(__VA_ARGS__))
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_ACALL, 0)
P00_DOCUMENT_NUMBER_ARGUMENT(P99_ACALL, 1)
P00_DOCUMENT_TYPE_ARGUMENT(P99_ACALL, 2)
#define P99_ACALL(...) P99_PASTE2(P00_ACALL, P99_NARG(__VA_ARGS__))(__VA_ARGS__)
......
......@@ -202,6 +202,7 @@ typedef extendedInt p99x_int128;
**
** The returning expression is of type @c uintmax_t
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_TO_UNSIGNED, 0)
P00_DOCUMENT_MACRO_ARGUMENT(P99_TO_UNSIGNED, 1)
#define P99_TO_UNSIGNED(T, MACRO) \
((uintmax_t) \
......@@ -270,6 +271,7 @@ P00_DOCUMENT_UNSIGNED(3)
**
** The returning expression is of type @c uintmax_t
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_UT_MAX, 0)
#define P99_UT_MAX(T) (P99_M1U(T))
/**
......@@ -854,6 +856,7 @@ P00_DECLARE_OVERFLOW(ll);
**/
#define P99_RVAL(T, ...) (P99_LVAL(T) = (__VA_ARGS__))
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_CHOOSE5, 0)
#define P99_CHOOSE5(xT, cc, cs, ci, cl, cll) \
((sizeof(xT) < sizeof(int)) \
? ((sizeof(xT) < sizeof(short)) \
......@@ -865,6 +868,8 @@ P00_DECLARE_OVERFLOW(ll);
: cl) \
: cll))
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_PRI, 0)
#define P99_PRI(xT, F, LEN) \
P99_CHOOSE5(xT, \
"%" #LEN "hh" #F, \
......
......@@ -137,6 +137,9 @@ p00_strcat_terminate \
** @see P99_STRDUP for a variant that returns a @c malloc'ed string and
** thus can be called with any type of @c char* arguments.
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_JOIN, 0)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_JOIN, 1)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_JOIN, 2)
#define P99_JOIN(...) P99_STRCATS((char[P99_SIZEOFS(__VA_ARGS__) + 1]){ 0 }, __VA_ARGS__)
/**
......
......@@ -48,6 +48,7 @@
** @see P99_MEMZERO for a macro that initializes to a default value
** that is guaranteed to correspond to the type.
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_PZERO, 0)
#define P99_PZERO(X, N) (memset((X), 0, sizeof(X[0]) * N))
/**
......@@ -61,7 +62,8 @@
** @see P99_MEMZERO for a macro that initializes to a default value
** that is guaranteed to correspond to the type.
**/
#define P99_TZERO(...) (memset(&(__VA_ARGS__), 0, sizeof(__VA_ARGS__)))
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_TZERO, 0)
#define P99_TZERO(X) (memset(&(X), 0, sizeof(X)))
p99_inline
......@@ -142,6 +144,7 @@ void* p00_calloc(void const* source, size_t size, size_t number) {
#define P00_CALLOC0(T, N) p00_calloc((void const*)&P99_LVAL(const T), sizeof(T), N)
#define P00_CALLOC(...) P00_CALLOC0(__VA_ARGS__)
#ifdef P00_DOXYGEN
/**
** @brief A type oriented replacement for @c calloc
**
......@@ -171,7 +174,11 @@ void* p00_calloc(void const* source, size_t size, size_t number) {
** from using plain @c calloc.
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_CALLOC, 0)
#define P99_CALLOC(T, N)
#else
P00_DOCUMENT_TYPE_ARGUMENT(P99_CALLOC, 0)
#define P99_CALLOC(...) P00_CALLOC(P99_CALL_DEFARG_LIST(P00_CALLOC, 2, __VA_ARGS__))
#endif
#define P00_CALLOC_defarg_1() 1
......
......@@ -81,10 +81,12 @@
P99_PASTE2(P99_PASTE5(_1, _2, _3, _4, _5), _6)
#ifndef P00_DOCUMENT_MULTIPLE_ARGUMENT
#define P00_DOCUMENT_TYPE_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO should correspond to a type */
#define P00_DOCUMENT_TYPE_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO should correspond to a type that is not a VLA. */
#define P00_DOCUMENT_MULTIPLE_ARGUMENT(MACRO, N) /*! @warning argument N of MACRO may be evaluated multiple times */
#define P00_DOCUMENT_PERMITTED_ARGUMENT(MACRO, N)
#define P00_DOCUMENT_STATEMENT_ARGUMENT(MACRO, N)
#define P00_DOCUMENT_WARN_VLA_ARGUMENT(MACRO, N) /*! @warning argument N of MACRO may be evaluated multiple times if it is a VLA */
#define P00_DOCUMENT_IDENTIFIER_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO must be an identifier */
#define P00_DOCUMENT_PERMITTED_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO maybe evaluated several times for its type but only once for its value */
#define P00_DOCUMENT_STATEMENT_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO is a statement that will be emitted multiple times in the resulting macro expansion */
#define P00_DOCUMENT_DECLARATION_ARGUMENT(MACRO, N)
#define P00_DOCUMENT_MACRO_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO should correspond to a macro name */
#define P00_DOCUMENT_NUMBER_ARGUMENT(MACRO, N) /*! @remark argument N of MACRO must expand to a decimal number */
......
......@@ -151,6 +151,8 @@ p00_swap1( \
** representation.
**
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_SWAP, 0)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_SWAP, 1)
#define P99_SWAP(_0, _1) ((sizeof(_0) > sizeof(uintmax_t)) ? P00_SWAP1(_0, _1) : P00_SWAP2(_0, _1))
......
......@@ -43,7 +43,7 @@
** This declaration should also be suitable to be included into a C++
** source.
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_DECLARE_STRUCT, 0)
P00_DOCUMENT_IDENTIFIER_ARGUMENT(P99_DECLARE_STRUCT, 0)
#define P99_DECLARE_STRUCT(NAME) typedef struct NAME NAME
......@@ -57,7 +57,7 @@ P00_DOCUMENT_TYPE_ARGUMENT(P99_DECLARE_STRUCT, 0)
** This declaration should also be suitable to be included into a C++
** source.
**/
P00_DOCUMENT_TYPE_ARGUMENT(P99_DECLARE_UNION, 0)
P00_DOCUMENT_IDENTIFIER_ARGUMENT(P99_DECLARE_UNION, 0)
#define P99_DECLARE_UNION(NAME) typedef union NAME NAME
/** @}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment