CIL issues an "Error: Unexpected operand for addrof" message when it encounters
&"stringliteral"
even though GCC will compile this expression even with -ansi and/or -pedantic
flags. Although the
construct is a little odd, I think that it is ANSI compliant. I include a
sample file below that
will compile and run with GCC but which generates the error message with CIL. I
looked at the code
that generates the error, but I was not sure what CIL should actually produce,
so I have no fix to
suggest.
the file:
_____________________________________________________
#include <stdio.h>
char *sp = NULL;
int
main (int argc, char** argv)
{
sp = (char *)&("this");
printf ("sp = 0x%lx 0x%lx %s\n", (unsigned long) sp, (unsigned long)
&sp, sp);
return 0;
}
_____________________________________________________
the CIL response:
cilly stringlit.c
gcc -D_GNUCC -E -DCIL=1 stringlit.c -o /tmp/cil-xJ0R9rQv.i
./cil/svndir/current/cil/obj/x86_LINUX/cilly.asm.exe --out
/tmp/cil-nrNmdv0P.cil.c /tmp/cil-xJ0R9rQv.i
stringlit.c:8: Error: Unexpected operand for addrof
Error: Cabs2cil had some errors
Fatal error: exception Errormsg.Error
_____________________________________________________
GCC on the same code
gcc -o stringlit -ansi stringlit.c
$ ./stringlit
sp = 0x40066c 0x601030 this
Jesse Draper
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users