/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2003 Ullrich von Bassewitz */
+/* Römerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "litpool.h"
#include "scanner.h"
#include "stdfunc.h"
+#include "stdnames.h"
#include "typeconv.h"
unsigned Flags = CF_FORCECHAR;
/* Read the expression we're going to pass to the function */
- int k = hie1 (InitExprDesc (Arg));
+ hie1 (InitExprDesc (Arg));
/* Convert this expression to the expected type */
- k = TypeConversion (Arg, k, Type);
+ TypeConversion (Arg, Type);
/* If the value is not a constant, load it into the primary */
- if (k != 0 || Arg->Flags != E_MCONST) {
+ if (ED_IsLVal (Arg) || Arg->Flags != E_MCONST) {
/* Load into the primary */
- exprhs (CF_NONE, k, Arg);
- k = 0;
+ ExprLoad (CF_NONE, Arg);
+ ED_MakeRVal (Arg);
} else {
int MemSet = 1; /* Use real memset if true */
unsigned ParamSize = 0;
-
- /* Check the prototype of the function against what we know about it, so
- * we can detect errors.
- */
- /* ### */
-
/* Argument #1 */
Flags = ParseArg (Arg1Type, &Arg);
g_push (Flags, Arg.ConstVal);
*/
Flags = ParseArg (Arg3Type, &Arg);
if (Flags & CF_CONST) {
- exprhs (CF_FORCECHAR, 0, &Arg);
+ if (Arg.ConstVal == 0) {
+ Warning ("Call to memset has no effect");
+ }
+ ExprLoad (CF_FORCECHAR, &Arg);
}
/* Emit the actual function call */
- g_call (CF_NONE, MemSet? "memset" : "_bzero", ParamSize);
+ g_call (CF_NONE, MemSet? Func_memset : Func__bzero, ParamSize);
/* We expect the closing brace */
ConsumeRParen ();
/* Handle the strlen function */
{
static type ParamType[] = { T_PTR, T_SCHAR, T_END };
- int k;
ExprDesc Param;
unsigned CodeFlags;
unsigned long ParamName;
ParamType[1] = GetDefaultChar () | T_QUAL_CONST;
/* Fetch the parameter and convert it to the type needed */
- k = TypeConversion (&Param, hie1 (InitExprDesc (&Param)), ParamType);
+ hie1 (InitExprDesc (&Param));
+ TypeConversion (&Param, ParamType);
/* Check if the parameter is a constant array of some type, or a numeric
* address cast to a pointer.
if (!WriteableStrings) {
/* String literals are const */
ExprDesc Length;
- MakeConstIntExpr (&Length, strlen (GetLiteral (Param.ConstVal)));
+ ED_MakeConstInt (&Length, strlen (GetLiteral (Param.ConstVal)));
ResetLiteralPoolOffs (Param.ConstVal);
- exprhs (CF_NONE, 0, &Length);
+ ExprLoad (CF_NONE, &Length);
goto ExitPoint;
} else {
CodeFlags |= CF_CONST | CF_STATIC;
} else {
/* Not an array with a constant address. Load parameter into primary */
- exprhs (CF_NONE, k, &Param);
+ ExprLoad (CF_NONE, &Param);
}