Properly support use of const structs and unions in assignments and as function arguments.
Here's an example that shows the issues (derived from a csmith-generated test case): struct S { unsigned f; }; void f1(struct S p) { printf("%u\n", p.f); } int main(void) { const struct S l = {123}; struct S s; f1(l); s = l; printf("%u\n", s.f); }
This commit is contained in:
parent
4746d9ff60
commit
7266b1d613
|
@ -2266,6 +2266,8 @@ var
|
|||
lexpressionType := expressionType; {save the expression type}
|
||||
|
||||
GenerateCode(tree); {get the type}
|
||||
while expressionType^.kind = definedType do
|
||||
expressionType := expressionType^.dType;
|
||||
ExpressionKind := expressionType^.kind;
|
||||
|
||||
doDispose := ldoDispose; {resore the volitile variables}
|
||||
|
@ -2853,7 +2855,10 @@ case tree^.token.kind of
|
|||
FunctionCall(tree);
|
||||
|
||||
ident: begin
|
||||
case tree^.id^.itype^.kind of
|
||||
tType := tree^.id^.itype;
|
||||
while tType^.kind = definedType do
|
||||
tType := tType^.dType;
|
||||
case tType^.kind of
|
||||
|
||||
scalarType: begin
|
||||
LoadScalar(tree^.id);
|
||||
|
@ -2885,8 +2890,6 @@ case tree^.token.kind of
|
|||
expressionType := wordPtr;
|
||||
end;
|
||||
|
||||
otherwise: ;
|
||||
|
||||
end; {case}
|
||||
end;
|
||||
|
||||
|
|
Loading…
Reference in New Issue