Hi all
There may be some other bugs in tcc related to nocode_wanted
Check commit 78c076a70f5
      The following check in tccgen.c is removed
        if (nocode_wanted)
        tcc_error("statement expression in global scope");
    This check is introduced in commit 5bcc3eed7b93 and breaks compilation
    of the linux 2.4.26 kernel.

commit 5bcc3ee
Author: Thomas Preud'homme
    Add some missing nocode_wanted guard

A test program related to this issue:
=========================
typedef unsigned int __u32;
struct romfs_super_block {
        __u32 word0;
        __u32 word1;
        __u32 size;
        __u32 checksum;
        char name[0];
};
int main() {
    struct romfs_super_block *romfsb;
    int nblocks = ((__builtin_constant_p((__u32)((romfsb->size))) ?
        ({ __u32 __x = (((romfsb->size))); ((__u32)( (((__u32)(__x) &
(__u32)0x000000ffUL) << 24)
            | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) |
(((__u32)(__x) & (__u32)0x00ff0000UL) >> 8)
            | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); })
        : __fswab32(((romfsb->size))))+(1<<10)-1)>>10;
}
======================
typedef unsigned int __u32;
struct romfs_super_block {
	__u32 word0;
	__u32 word1;
	__u32 size;
	__u32 checksum;
	char name[0];		 
};

int main() {
    struct romfs_super_block *romfsb;

    int nblocks = ((__builtin_constant_p((__u32)((romfsb->size))) ? 
	({ __u32 __x = (((romfsb->size))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24)
	    | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8)
	    | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); })
	: __fswab32(((romfsb->size))))+(1<<10)-1)>>10;
}
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to