[cfe-dev] A function which has anonymous enum parameter is not code-generated

Richard Smith richard at metafoo.co.uk
Thu May 3 11:10:43 PDT 2012


On Wed, May 2, 2012 at 10:10 PM, Jaemin Park <jm.j.park at samsung.com> wrote:

> Hello, ****
>
> ** **
>
> A function which has anonymous enum parameters is not code-generated.
>

There is no way (within standard C++) to call this function from outside
the translation unit, because there is no way to refer to the _TestEnum
type. Hence there's no need to emit code for it if it's not called within
the translation unit. You can force code to be generated by marking it with
__attribute__((used)), but it will still be given internal linkage.


> This is a sample code. ****
>
> ** **
>
> *amespace {*
>
> *enum _TestEnum {*
>
> *  ENUM_ZERO = 0,*
>
> *};*
>
> *}*
>
> * *
>
> *bool foo(_TestEnum val)*
>
> *{*
>
> *  if (val == ENUM_ZERO)*
>
> *    return true;*
>
> *  return false;*
>
> *}*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120503/3c113816/attachment.html>


More information about the cfe-dev mailing list