[PATCH] __attribute__((enable_if)) and non-overloaded member functions

Nick Lewycky nlewycky at google.com
Tue May 26 19:54:47 PDT 2015


On 26 May 2015 at 13:20, Ettore Speziale <speziale.ettore at gmail.com> wrote:

> Hello,
>
> the attached patch fixes the case where __attribute__((enable_if)) is
> sticked to a member function with no overloads. It seems that in these case
> clang does not execute the code about overload resolution which contains
> the check about __attribute__((enable_if)). Hence it would be possible to
> use a function protected by __attribute__((enable_if)) even if the
> __attribute__((enable_if)) predicate is false.
>

Good catch!

I think this will cause the enable_if expression to be evaluated multiple
times if the expression is not dependent but appertains to a function
template, such as:

  template <typename T> void foo(int i, T t) __attribute__((enable_if(i==0,
""))) {}

I'm not sure how to fix that without hoisting it up to ActOnCallExpr? Could
you check whether this is a real problem?

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150526/95330365/attachment.html>


More information about the cfe-commits mailing list