[cfe-dev] Clang (3.1 and 3.2): __attribute__((overloadable)) and enum types.

Ólafur Waage olafurw at gmail.com
Fri Aug 2 05:57:43 PDT 2013


Since enums in C are just named integers, they are all of the same type. So
it would be the same as doing three functions with int as the argument.




On Fri, Aug 2, 2013 at 12:29 PM, Lizunov, Andrey E <
andrey.e.lizunov at intel.com> wrote:

>  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-coverloadable 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.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130802/d03c2201/attachment.html>


More information about the cfe-dev mailing list