Lizunov, Andrey E
2013-Aug-02 08:52 UTC
[LLVMdev] 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 -------------------------------------------------------------------- Closed Joint Stock Company Intel A/O Registered legal address: Krylatsky Hills Business Park, 17 Krylatskaya Str., Bldg 4, Moscow 121614, Russian Federation This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130802/13d7022e/attachment.html>