diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index 8240a4e60..9e52027ce 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -72,6 +72,12 @@ const Type type_size_t[] = { TYPE(T_SIZE_T), TYPE(T_END) }; const Type type_float[] = { TYPE(T_FLOAT), TYPE(T_END) }; const Type type_double[] = { TYPE(T_DOUBLE), TYPE(T_END) }; +/* More predefined type strings */ +const Type type_char_p[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) }; +const Type type_c_char_p[] = { TYPE(T_PTR), TYPE(T_C_CHAR), TYPE(T_END) }; +const Type type_void_p[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) }; +const Type type_c_void_p[] = { TYPE(T_PTR), TYPE(T_C_VOID), TYPE(T_END) }; + /*****************************************************************************/ diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index b65cbdd05..1140ee498 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -146,6 +146,10 @@ enum { T_PTR = T_TYPE_PTR | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE, T_FUNC = T_TYPE_FUNC | T_CLASS_FUNC | T_SIGN_NONE | T_SIZE_NONE, + /* More types for convenience */ + T_C_CHAR = T_CHAR | T_QUAL_CONST, + T_C_VOID = T_VOID | T_QUAL_CONST, + /* Aliases */ T_SIZE_T = T_UINT, }; @@ -211,6 +215,12 @@ extern const Type type_size_t[]; extern const Type type_float[]; extern const Type type_double[]; +/* More predefined type strings */ +extern const Type type_char_p[]; +extern const Type type_c_char_p[]; +extern const Type type_void_p[]; +extern const Type type_c_void_p[]; + /* Forward for the SymEntry struct */ struct SymEntry; diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 117214a24..bdc7be006 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -212,9 +212,9 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Handle the memcpy function */ { /* Argument types: (void*, const void*, size_t) */ - static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) }; - static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_VOID|T_QUAL_CONST), TYPE(T_END) }; - static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) }; + static const Type* Arg1Type = type_void_p; + static const Type* Arg2Type = type_c_void_p; + static const Type* Arg3Type = type_size_t; ArgDesc Arg1, Arg2, Arg3; unsigned ParamSize = 0; @@ -556,9 +556,9 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Handle the memset function */ { /* Argument types: (void*, int, size_t) */ - static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_VOID), TYPE(T_END) }; - static const Type Arg2Type[] = { TYPE(T_INT), TYPE(T_END) }; - static const Type Arg3Type[] = { TYPE(T_SIZE_T), TYPE(T_END) }; + static const Type* Arg1Type = type_void_p; + static const Type* Arg2Type = type_int; + static const Type* Arg3Type = type_size_t; ArgDesc Arg1, Arg2, Arg3; int MemSet = 1; /* Use real memset if true */ @@ -782,8 +782,8 @@ static void StdFunc_strcmp (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Handle the strcmp function */ { /* Argument types: (const char*, const char*) */ - static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) }; - static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) }; + static const Type* Arg1Type = type_c_char_p; + static const Type* Arg2Type = type_c_char_p; ArgDesc Arg1, Arg2; unsigned ParamSize = 0; @@ -983,8 +983,8 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Handle the strcpy function */ { /* Argument types: (char*, const char*) */ - static const Type Arg1Type[] = { TYPE(T_PTR), TYPE(T_CHAR), TYPE(T_END) }; - static const Type Arg2Type[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) }; + static const Type* Arg1Type = type_char_p; + static const Type* Arg2Type = type_c_char_p; ArgDesc Arg1, Arg2; unsigned ParamSize = 0; @@ -1180,7 +1180,7 @@ ExitPoint: static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr) /* Handle the strlen function */ { - static const Type ArgType[] = { TYPE(T_PTR), TYPE(T_CHAR|T_QUAL_CONST), TYPE(T_END) }; + static const Type* ArgType = type_c_char_p; ExprDesc Arg; int IsArray; int IsPtr;