[PATCH] D19835: Tolerate incorrect return type for 'isinf' and 'isnan' in tests.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Mon May 2 14:45:49 PDT 2016


EricWF added a comment.

In http://reviews.llvm.org/D19835#419211, @jroelofs wrote:

> I think you could lean on the linker to cause the test to fail when the type is wrong:
>
>   bool isinf(double);
>  
>   typedef int (*expected_signature)(double);
>  
>   void assert_via_linker(decltype(isinf) blah);
>   void assert_via_linker(expected_signature blah) {}
>  
>   void foo() {
>     assert_via_linker(isinf);
>   }
>  
>


Alternatively `static_assert(std::is_same<decltype(isinf((double)0)), bool>::value);` :-P

Testing the return type isn't the problem. The problem is telling LIT *when* we expect the test to fail using the `XFAIL` directive.

The test will pass for:

- non-linux systems
- GLIBC >= 2.26 and C++ >= 11.

The test will fail for:

- GLIBC < 2.26
- GLIBC >= 2.26 and C++ < 11.

Trying to encode that within 'XFAIL' is currently not possible and


http://reviews.llvm.org/D19835





More information about the cfe-commits mailing list