On mcs51, passing an array element as an on-stack struct parameter fails
gen/mcs51-large-stack-auto/bug-3368/bug-3368.c:18: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '1837' : need pointerCode
Looks like we have an assignment in the iCode that should be a cast (iCode from dumpraw0):
test.c(l7:s0:k0:d0:s0:b3) _entry($2) :
test.c(l7:s0:k1:d0:s0:b3) proc _f1 [k1 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{void function ( ) fixed}
test.c(l9:s0:k2:d0:s0:b3) iTemp0 [k4 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{struct __00000000 generic* fixed} = &[_ipts1 [k3 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{struct __00000000 [2] fixed} , 0x0 {const-unsigned-char literal}]
test.c(l9:s0:k3:d0:s0:b3) push @[iTemp0 [k4 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{struct __00000000 generic* fixed} + 0x0 {const-unsigned-char literal}]
test.c(l9:s0:k4:d0:s0:b3) send 0x4 {const-int literal}{argreg = 1}
test.c(l9:s0:k5:d0:s0:b3) iTemp1 [k7 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{int fixed} = call _va1 [k2 lr0:0 so:0]{ ia0 a2p0 re0 rm0 nos0 ru0 dp0}{int function ( int fixed, struct __00000000 fixed) __reentrant fixed}
This can be reproduced using
typedef struct{int x,y;}ipoint;
ipoint ipts1[]={{1,2},{3,4}};
static int va1(int nargs,ipoint i) __reentrant;
void
f1 (void)
{
va1(4,ipts1[0]);
}
Two regression tests apparently fail due to this issue when enabled for mcs51: bug-3368.c, tests/gcc-torture-execute-920625-1.c.
Fixed in [r13859].
Related
Commit: [r13859]