Can clang parse the Linux kernel?

Trying to answer this question, I had a go at Linux 2.6.27.10.
I did not go very far, as make stopped because of the following:

$ clang -w modpost.i
modpost.i:6067:28: error: used type '_Elf64_Mips_R_Info_union' where arithmetic or pointer type is required
    r_sym = ((__extension__ (_Elf64_Mips_R_Info_union)(rela->r_info)).r_info_fields.r_sym);
                            ^ ~~~~~~~~~~~~~~
modpost.i:6069:28: error: used type '_Elf64_Mips_R_Info_union' where arithmetic or pointer type is required
    r_typ = ((__extension__ (_Elf64_Mips_R_Info_union)(rela->r_info)).r_info_fields.r_type1);
                            ^ ~~~~~~~~~~~~~~
modpost.i:6111:28: error: used type '_Elf64_Mips_R_Info_union' where arithmetic or pointer type is required
    r_sym = ((__extension__ (_Elf64_Mips_R_Info_union)(rel->r_info)).r_info_fields.r_sym);
                            ^ ~~~~~~~~~~~~~
modpost.i:6113:28: error: used type '_Elf64_Mips_R_Info_union' where arithmetic or pointer type is required
    r_typ = ((__extension__ (_Elf64_Mips_R_Info_union)(rel->r_info)).r_info_fields.r_type1);
                            ^ ~~~~~~~~~~~~~
4 diagnostics generated.
$

Should I file bug reports for such problems?
All the best,

    Roberto

Yes, please. We aim to eventually support most of GCC's extensions. In this case, we haven't implemented a cast to union type:

  Cast to Union - Using the GNU Compiler Collection (GCC)

  - Doug

This is a known problem:
http://llvm.org/bugs/show_bug.cgi?id=2746

-Chris

I sent a patch to, at least partially, support this extension on the 13th of May. I believe it wasn't committed because I got side-tracked with other things before I added the extension thing to make it only work in GNU mode. It probably wouldn't be too difficult to finish...

David

David Chisnall wrote: