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;
|
struct Value *Result;
|
||||||
union AnyValue *ValPtr;
|
union AnyValue *ValPtr;
|
||||||
|
struct ValueType *Typ;
|
||||||
|
|
||||||
#ifdef DEBUG_EXPRESSIONS
|
#ifdef DEBUG_EXPRESSIONS
|
||||||
printf("ExpressionPrefixOperator()\n");
|
printf("ExpressionPrefixOperator()\n");
|
||||||
|
@ -663,11 +664,12 @@ void ExpressionPrefixOperator(struct ParseState *Parser,
|
||||||
case TokenSizeof:
|
case TokenSizeof:
|
||||||
/* return the size of the argument */
|
/* return the size of the argument */
|
||||||
if (TopValue->Typ == &Parser->pc->TypeType)
|
if (TopValue->Typ == &Parser->pc->TypeType)
|
||||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Val->Typ,
|
Typ = TopValue->Val->Typ;
|
||||||
TopValue->Val->Typ->ArraySize, true));
|
|
||||||
else
|
else
|
||||||
ExpressionPushInt(Parser, StackTop, TypeSize(TopValue->Typ,
|
Typ = TopValue->Typ;
|
||||||
TopValue->Typ->ArraySize, true));
|
if (Typ->FromType != NULL && Typ->FromType->Base == TypeStruct)
|
||||||
|
Typ = Typ->FromType;
|
||||||
|
ExpressionPushInt(Parser, StackTop, TypeSize(Typ, Typ->ArraySize, true));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* an arithmetic operator */
|
/* an arithmetic operator */
|
||||||
|
|
|
@ -1,12 +1,43 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
char a;
|
char a;
|
||||||
int b;
|
int b;
|
||||||
double c;
|
double c;
|
||||||
|
|
||||||
printf("%d\n", sizeof(a));
|
struct P1 {
|
||||||
printf("%d\n", sizeof(b));
|
int a;
|
||||||
printf("%d\n", sizeof(c));
|
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
|
1
|
||||||
4
|
4
|
||||||
8
|
8
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue