mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-07 19:29:29 +00:00
Fix code generation for qualified struct or union function parameters.
They were not being properly recognized as structs/unions, so they were being passed by address rather than by value as they should be. Here is an example affected by this: struct S {int a,b,c,d;}; int f(struct S s) { return s.a + s.b + s.c + s.d; } int main(void) { const struct S s = {1,2,3,4}; return f(s); }
This commit is contained in:
parent
83537fd3c7
commit
50636bd28b
|
@ -3453,12 +3453,18 @@ var
|
||||||
while tp <> nil do begin
|
while tp <> nil do begin
|
||||||
if tp^.middle <> nil then begin
|
if tp^.middle <> nil then begin
|
||||||
GenerateCode(tp^.middle);
|
GenerateCode(tp^.middle);
|
||||||
if expressionType^.kind in [structType,unionType] then begin
|
if expressionType^.kind in [structType,unionType,definedType]
|
||||||
if expressionType^.size & $FFFF8000 <> 0 then
|
then begin
|
||||||
|
tType := expressionType;
|
||||||
|
while tType^.kind = definedType do
|
||||||
|
tType := tType^.dType;
|
||||||
|
if tType^.kind in [structType,unionType] then begin
|
||||||
|
if tType^.size & $FFFF8000 <> 0 then
|
||||||
Error(61);
|
Error(61);
|
||||||
Gen1t(pc_ldc, long(expressionType^.size).lsw, cgWord);
|
Gen1t(pc_ldc, long(tType^.size).lsw, cgWord);
|
||||||
Gen0(pc_psh);
|
Gen0(pc_psh);
|
||||||
end; {if}
|
end; {if}
|
||||||
|
end; {if}
|
||||||
if fmt <> fmt_none then begin
|
if fmt <> fmt_none then begin
|
||||||
new(tfp);
|
new(tfp);
|
||||||
tfp^.next := fp;
|
tfp^.next := fp;
|
||||||
|
|
2
cc.notes
2
cc.notes
|
@ -1620,6 +1620,8 @@ If you use #pragma debug 0x0010 to enable stack check debug code, the compiler w
|
||||||
|
|
||||||
15. Native code peephole optimization might produce invalid code in some obscure circumstances where one element of a global or static array was decremented and then another element of the same array was accessed immediately thereafter.
|
15. Native code peephole optimization might produce invalid code in some obscure circumstances where one element of a global or static array was decremented and then another element of the same array was accessed immediately thereafter.
|
||||||
|
|
||||||
|
16. When an expression of const- or volatile-qualified struct or union type was passed as a function parameter, incorrect code would be generated. This could lead to incorrect program behavior or crashes.
|
||||||
|
|
||||||
-- Bugs from C 2.1.1 B3 that have been fixed in C 2.2.0 ---------------------
|
-- Bugs from C 2.1.1 B3 that have been fixed in C 2.2.0 ---------------------
|
||||||
|
|
||||||
1. There were various bugs that could cause incorrect code to be generated in certain cases. Some of these were specific to certain optimization passes, alone or in combination.
|
1. There were various bugs that could cause incorrect code to be generated in certain cases. Some of these were specific to certain optimization passes, alone or in combination.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user