case T_SCHAR:
case T_UCHAR:
- return 1;
+ return SIZEOF_CHAR;
case T_SHORT:
case T_USHORT:
+ return SIZEOF_SHORT;
+
case T_INT:
case T_UINT:
+ return SIZEOF_INT;
+
case T_PTR:
case T_FUNC: /* Maybe pointer to function */
- return 2;
+ return SIZEOF_PTR;
case T_LONG:
case T_ULONG:
- return 4;
+ return SIZEOF_LONG;
case T_LONGLONG:
case T_ULONGLONG:
- return 8;
+ return SIZEOF_LONGLONG;
case T_ENUM:
- return 2;
+ return SIZEOF_INT;
case T_FLOAT:
+ return SIZEOF_FLOAT;
+
case T_DOUBLE:
- return 4;
+ return SIZEOF_DOUBLE;
case T_STRUCT:
case T_UNION:
unsigned Size = SizeOf (T);
if (Size == 0) {
Error ("Size of data type is unknown");
- Size = 1;
+ Size = SIZEOF_CHAR; /* Don't return zero */
}
return Size;
}
unsigned Size = PSizeOf (T);
if (Size == 0) {
Error ("Size of data type is unknown");
- Size = 1;
+ Size = SIZEOF_CHAR; /* Don't return zero */
}
return Size;
}
/* Sizes */
#define SIZEOF_CHAR 1
+#define SIZEOF_SHORT 2
#define SIZEOF_INT 2
#define SIZEOF_LONG 4
+#define SIZEOF_LONGLONG 8
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 4
+#define SIZEOF_PTR 2
/* Predefined type strings */
extern type type_uchar [];
(rflags & E_MGLOBAL) != 0 || /* Static array, or ... */
rflags == E_MLOCAL; /* Local array */
- if (ConstSubAddr && CheckedSizeOf (lval->Type) == 1) {
+ if (ConstSubAddr && CheckedSizeOf (lval->Type) == SIZEOF_CHAR) {
type* SavedType;
/* Reverse the order of evaluation */
- unsigned flags = (CheckedSizeOf (lval2.Type) == 1)? CF_CHAR : CF_INT;
+ unsigned flags = (CheckedSizeOf (lval2.Type) == SIZEOF_CHAR)? CF_CHAR : CF_INT;
RemoveCode (Mark2);
/* Get a pointer to the array into the primary. We have changed
/* If the lhs is character sized, the operation may be later done
* with characters.
*/
- if (CheckedSizeOf (lval->Type) == 1) {
+ if (CheckedSizeOf (lval->Type) == SIZEOF_CHAR) {
flags |= CF_FORCECHAR;
}
/* If the lhs is character sized, the operation may be later done
* with characters.
*/
- if (CheckedSizeOf (lval->Type) == 1) {
+ if (CheckedSizeOf (lval->Type) == SIZEOF_CHAR) {
flags |= CF_FORCECHAR;
}
F_AllocLocalSpace (CurrentFunc);
/* Setup the type flags for the assignment */
- Flags = (Size == 1)? CF_FORCECHAR : CF_NONE;
+ Flags = (Size == SIZEOF_CHAR)? CF_FORCECHAR : CF_NONE;
/* Get the expression into the primary */
if (evalexpr (Flags, hie1, &lval) == 0) {
} else {
/* Setup the type flags for the assignment */
- Flags = (Size == 1)? CF_FORCECHAR : CF_NONE;
+ Flags = (Size == SIZEOF_CHAR)? CF_FORCECHAR : CF_NONE;
/* Get the expression into the primary */
if (evalexpr (Flags, hie1, &lval) == 0) {
NextToken ();
if (CurTok.Tok != TOK_SEMI) {
+
+ /* Check if the function has a return value declared */
if (F_HasVoidReturn (CurrentFunc)) {
Error ("Returning a value in function with return type void");
}
if (!F_HasVoidReturn (CurrentFunc)) {
assignadjust (F_GetReturnType (CurrentFunc), &lval);
}
+
} else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) {
Error ("Function `%s' must return a value", F_GetFuncName (CurrentFunc));
}