fix: issue #2, for real this time
This commit is contained in:
parent
e8b2139b26
commit
6132405404
10
expression.c
10
expression.c
|
@ -635,6 +635,7 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
|
|||
{
|
||||
struct Value *Result;
|
||||
union AnyValue *ValPtr;
|
||||
struct ValueType *Typ;
|
||||
|
||||
#ifdef DEBUG_EXPRESSIONS
|
||||
printf("ExpressionPrefixOperator()\n");
|
||||
|
@ -663,11 +664,12 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
|
|||
case TokenSizeof:
|
||||
/* return the size of the argument */
|
||||
if (TopValue->Typ == &Parser->pc->TypeType)
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Val->Typ,
|
||||
TopValue->Val->Typ->ArraySize, true));
|
||||
Typ = TopValue->Val->Typ;
|
||||
else
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Typ,
|
||||
TopValue->Typ->ArraySize, true));
|
||||
Typ = TopValue->Typ;
|
||||
if (Typ->FromType != NULL && Typ->FromType->Base == TypeStruct)
|
||||
Typ = Typ->FromType;
|
||||
ExpressionPushInt(Parser, StackTop, TypeSize(Typ, Typ->ArraySize, true));
|
||||
break;
|
||||
default:
|
||||
/* an arithmetic operator */
|
||||
|
|
|
@ -1,12 +1,43 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char a;
|
||||
int b;
|
||||
double c;
|
||||
|
||||
printf("%d\n", sizeof(a));
|
||||
printf("%d\n", sizeof(b));
|
||||
printf("%d\n", sizeof(c));
|
||||
struct P1 {
|
||||
int a;
|
||||
int b;
|
||||
double c;
|
||||
};
|
||||
|
||||
struct P2 {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
double e;
|
||||
};
|
||||
|
||||
void main() {}
|
||||
struct P3 {
|
||||
int a;
|
||||
int b;
|
||||
int c;
|
||||
int d;
|
||||
double e;
|
||||
struct P1 *p1;
|
||||
struct P1 *p2;
|
||||
struct P1 *p3;
|
||||
};
|
||||
|
||||
void main() {
|
||||
struct P1 *p1;
|
||||
struct P2 *p2;
|
||||
struct P3 *p3;
|
||||
printf("%d\n", sizeof(*p1));
|
||||
printf("%d\n", sizeof(*p2));
|
||||
printf("%d\n", sizeof(*p3));
|
||||
printf("%d\n", sizeof(a));
|
||||
printf("%d\n", sizeof(b));
|
||||
printf("%d\n", sizeof(c));
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
16
|
||||
24
|
||||
48
|
||||
1
|
||||
4
|
||||
8
|
||||
|
||||
|
|
Loading…
Reference in a new issue