There are several bugs in __builtin_classify_type implementation:
- It doesn't support member functions, so the following program crashes clang:
lass cl { public: void bar() {} }; ... int res = __builtin_classify_type(&cl::bar);
- It returns enumeral_type_class for enums, function_type_class for functions and array_type_class for arrays in both C and C++ modes. However, gcc returns integer_type_class for enums and pointer_type_class for arrays and functions in C mode -- which is correct, as conversions between enums and ints and function pointers and arrays and pointers can happen everywhere in C. (gcc returns the same as what clang does in C++ mode, however.)
- It returns string_type_class for chars, which is odd and doesn't match what gcc does.
This patch fixes all these bugs.
Yours,
Andrey
Software Engineer
Intel Compiler Team