Clang (3.1 and 3.2): __attribute__((overloadable)) and enum types.

Hello,

I was trying to use attribute((overloadable)) for functions accepting enumerated types but hadn’t succeeded so far.

Clang 3.1 and 3.2 failed to compile the following example.

/* clang -x c foo.cpp */

typedef enum __One {DUMMY_1} One;

typedef enum {DUMMY_2} Two;

enum Three {DUMMY_3};

attribute((overloadable)) void foo(One);

attribute((overloadable)) void foo(Two);

attribute((overloadable)) void foo(enum Three);

int main()

{

foo(DUMMY_1);

return 0;

}

Providing me with the following error message:

$ clang -x c foo.cpp

foo.cpp:22:3: error: call to ‘foo’ is ambiguous

foo(DUMMY_1);

^~~

foo.cpp:16:36: note: candidate function

attribute((overloadable)) void foo(One);

^

foo.cpp:17:36: note: candidate function

attribute((overloadable)) void foo(Two);

^

foo.cpp:18:36: note: candidate function

attribute((overloadable)) void foo(enum Three);

^

1 error generated.

While with “-x c++” both versions of Clang compiled it successfully (failed to link though).

According to http://clang.llvm.org/docs/LanguageExtensions.html#function-overloading-in-c overloadable attribute is an analogue for C++ function overloading in C.

So, is it a bug in the Clang or I didn’t understand/consider something?

BR,

Andrey Lizunov