Can you make NS_ENSURE_TRUE(foo, /* */) and NS_ENSURE_TRUE(foo,) errors?

Maybe there's a better way to do this, but I think we could do

template<class T>
MOZ_ALWAYS_INLINE void EnsureIsLvalue(T t) {}

and then make NS_ENSURE_TRUE call EnsureIsLvalue on the second arg.

I'd want to check that this doesn't slow down our compilations, though.

On Sun, Dec 23, 2012 at 8:31 PM, Nicholas Nethercote
<n.netherc...@gmail.com> wrote:
> Hi,
>
> This is a moderately common idiom:
>
>   NS_ENSURE_TRUE(foo, );
>
> It also occurs with NS_ENSURE_FALSE and NS_ENSURE_SUCCESS.  It's used
> in functions that return |void|.
>
> Unfortunately, it causes warnings with recent versions of clang, and
> they can turn into errors if you have --enable-warnings-as-errors.
>
> This alternative is sometimes is used instead, which (surprisingly
> enough) avoids the warning:
>
>   NS_ENSURE_TRUE(foo, /* */);
>
> However, this trick isn't needed, because you can instead do this:
>
>   NS_ENSURE_TRUE_VOID(foo);
>
> All of this applies to NS_ENSURE_FALSE and NS_ENSURE_SUCCESS, too.
>
> I've filed bug 824397 to convert the existing cases.  Please use the
> _VOID forms in the future.  Thanks!
>
> Nick
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to