From daede218196b85fa2a1720f0491b22d324ee54c6 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 19 Oct 2021 18:12:46 -0500 Subject: [PATCH] Fix bug with assembly-language functions that return structs/unions. --- Parser.pas | 24 ++++++++++++------------ cc.notes | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Parser.pas b/Parser.pas index e2e151c..e38a0b3 100644 --- a/Parser.pas +++ b/Parser.pas @@ -3859,24 +3859,24 @@ if isFunction then begin lp := lp^.pnext; end; {while} gotoList := nil; {initialize the label list} - {set up struct/union area} - if variable^.itype^.ftype^.kind in [structType,unionType] then begin - lp := NewSymbol(@'@struct', variable^.itype^.ftype, staticsy, - variablespace, declared); - tk.kind := ident; - tk.class := identifier; - tk.name := @'@struct'; - tk.symbolPtr := nil; - lp := FindSymbol(tk, variableSpace, false, true); - Gen1Name(pc_lao, 0, lp^.name); - Gen2t(pc_str, 0, 0, cgULong); - end; {if} fenvAccessInFunction := fenvAccess; if isAsm then begin AsmFunction(variable); {handle assembly language functions} PopTable; end {if} else begin + {set up struct/union area} + if variable^.itype^.ftype^.kind in [structType,unionType] then begin + lp := NewSymbol(@'@struct', variable^.itype^.ftype, staticsy, + variablespace, declared); + tk.kind := ident; + tk.class := identifier; + tk.name := @'@struct'; + tk.symbolPtr := nil; + lp := FindSymbol(tk, variableSpace, false, true); + Gen1Name(pc_lao, 0, lp^.name); + Gen2t(pc_str, 0, 0, cgULong); + end; {if} {generate parameter labels} if fnType^.overrideKR then GenParameters(nil) diff --git a/cc.notes b/cc.notes index bbd0df7..420ae4c 100644 --- a/cc.notes +++ b/cc.notes @@ -1376,6 +1376,8 @@ int foo(int[42]); 168. Unions may now contain bit-fields, as specified in the C standards. +169. If an assembly-language function (declared with the asm keyword) had a structure or union return type, ORCA/C would generate some spurious code at the beginning of the function, which might trash data used by its caller. + -- Bugs from C 2.1.0 that have been fixed ----------------------------------- 1. In some situations, fread() reread the first 1K or so of the file.