diff options
Diffstat (limited to 'test/std/depr/depr.c.headers')
-rw-r--r-- | test/std/depr/depr.c.headers/extern_c.pass.cpp | 43 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/fenv_h.pass.cpp | 2 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/inttypes_h.pass.cpp | 2 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/math_h.pass.cpp | 51 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/math_h_isinf.pass.cpp | 30 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/math_h_isnan.pass.cpp | 30 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/setjmp_h.pass.cpp | 1 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/stdarg_h.pass.cpp | 4 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/stdint_h.pass.cpp | 8 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/stdio_h.pass.cpp | 12 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/string_h.pass.cpp | 11 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/time_h.pass.cpp | 2 | ||||
-rw-r--r-- | test/std/depr/depr.c.headers/wchar_h.pass.cpp | 39 |
13 files changed, 97 insertions, 138 deletions
diff --git a/test/std/depr/depr.c.headers/extern_c.pass.cpp b/test/std/depr/depr.c.headers/extern_c.pass.cpp deleted file mode 100644 index d4d8b5fafdde..000000000000 --- a/test/std/depr/depr.c.headers/extern_c.pass.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Sometimes C++'s <foo.h> headers get included within extern "C" contexts. This -// is ill-formed (no diagnostic required), per [using.headers]p3, but we permit -// it as an extension. - -extern "C" { -#include <assert.h> -// complex.h is not supported in extern "C". -#include <ctype.h> -#include <errno.h> -#include <fenv.h> -#include <float.h> -#include <inttypes.h> -#include <iso646.h> -#include <limits.h> -#include <locale.h> -#include <math.h> -#include <setjmp.h> -#include <signal.h> -#include <stdalign.h> -#include <stdarg.h> -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -// tgmath.h is not supported in extern "C". -#include <time.h> -// FIXME: #include <uchar.h> -#include <wchar.h> -#include <wctype.h> -} - -int main() {} diff --git a/test/std/depr/depr.c.headers/fenv_h.pass.cpp b/test/std/depr/depr.c.headers/fenv_h.pass.cpp index f2fcf4914cfd..0da4c9d86b2d 100644 --- a/test/std/depr/depr.c.headers/fenv_h.pass.cpp +++ b/test/std/depr/depr.c.headers/fenv_h.pass.cpp @@ -60,7 +60,7 @@ int main() { - fenv_t fenv = {0}; + fenv_t fenv = {}; fexcept_t fex = 0; static_assert((std::is_same<decltype(feclearexcept(0)), int>::value), ""); static_assert((std::is_same<decltype(fegetexceptflag(&fex, 0)), int>::value), ""); diff --git a/test/std/depr/depr.c.headers/inttypes_h.pass.cpp b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp index 637cf72287b8..ff045a913fdb 100644 --- a/test/std/depr/depr.c.headers/inttypes_h.pass.cpp +++ b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp @@ -917,7 +917,7 @@ int main() uintmax_t i4 = 0; } { - imaxdiv_t i1 = {0}; + imaxdiv_t i1 = {}; } intmax_t i = 0; static_assert((std::is_same<decltype(imaxabs(i)), intmax_t>::value), ""); diff --git a/test/std/depr/depr.c.headers/math_h.pass.cpp b/test/std/depr/depr.c.headers/math_h.pass.cpp index ed12fcf73a8c..7e1b2d110642 100644 --- a/test/std/depr/depr.c.headers/math_h.pass.cpp +++ b/test/std/depr/depr.c.headers/math_h.pass.cpp @@ -9,9 +9,6 @@ // <math.h> -// NOTE: isinf and isnan are tested separately because they are expected to fail -// on linux. We don't want their expected failure to hide other failures in this file. - #include <math.h> #include <type_traits> #include <cassert> @@ -631,6 +628,29 @@ void test_isgreaterequal() assert(isgreaterequal(-1.0, 0.F) == false); } +void test_isinf() +{ +#ifdef isinf +#error isinf defined +#endif + static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), ""); + + typedef decltype(isinf((double)0)) DoubleRetType; +#ifndef __linux__ + static_assert((std::is_same<DoubleRetType, bool>::value), ""); +#else + // GLIBC < 2.26 defines 'isinf(double)' with a return type of 'int' in + // all C++ dialects. The test should tolerate this. + // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439 + static_assert((std::is_same<DoubleRetType, bool>::value + || std::is_same<DoubleRetType, int>::value), ""); +#endif + + static_assert((std::is_same<decltype(isinf(0)), bool>::value), ""); + static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), ""); + assert(isinf(-1.0) == false); +} + void test_isless() { #ifdef isless @@ -688,6 +708,29 @@ void test_islessgreater() assert(islessgreater(-1.0, 0.F) == true); } +void test_isnan() +{ +#ifdef isnan +#error isnan defined +#endif + static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), ""); + + typedef decltype(isnan((double)0)) DoubleRetType; +#ifndef __linux__ + static_assert((std::is_same<DoubleRetType, bool>::value), ""); +#else + // GLIBC < 2.26 defines 'isnan(double)' with a return type of 'int' in + // all C++ dialects. The test should tolerate this. + // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439 + static_assert((std::is_same<DoubleRetType, bool>::value + || std::is_same<DoubleRetType, int>::value), ""); +#endif + + static_assert((std::is_same<decltype(isnan(0)), bool>::value), ""); + static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), ""); + assert(isnan(-1.0) == false); +} + void test_isunordered() { #ifdef isunordered @@ -1443,9 +1486,11 @@ int main() test_isnormal(); test_isgreater(); test_isgreaterequal(); + test_isinf(); test_isless(); test_islessequal(); test_islessgreater(); + test_isnan(); test_isunordered(); test_acosh(); test_asinh(); diff --git a/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp b/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp deleted file mode 100644 index cc7eaac7de62..000000000000 --- a/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <math.h> - -// isinf - -// XFAIL: linux - -#include <math.h> -#include <type_traits> -#include <cassert> - -int main() -{ -#ifdef isinf -#error isinf defined -#endif - static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), ""); - static_assert((std::is_same<decltype(isinf((double)0)), bool>::value), ""); - static_assert((std::is_same<decltype(isinf(0)), bool>::value), ""); - static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), ""); - assert(isinf(-1.0) == false); -} diff --git a/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp b/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp deleted file mode 100644 index 118f96bdd434..000000000000 --- a/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <math.h> - -// isnan - -// XFAIL: linux - -#include <math.h> -#include <type_traits> -#include <cassert> - -int main() -{ -#ifdef isnan -#error isnan defined -#endif - static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), ""); - static_assert((std::is_same<decltype(isnan((double)0)), bool>::value), ""); - static_assert((std::is_same<decltype(isnan(0)), bool>::value), ""); - static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), ""); - assert(isnan(-1.0) == false); -} diff --git a/test/std/depr/depr.c.headers/setjmp_h.pass.cpp b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp index 9bc35b747493..9663d8892ac5 100644 --- a/test/std/depr/depr.c.headers/setjmp_h.pass.cpp +++ b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp @@ -19,6 +19,7 @@ int main() { jmp_buf jb; + ((void)jb); // Prevent unused warning static_assert((std::is_same<decltype(longjmp(jb, 0)), void>::value), "std::is_same<decltype(longjmp(jb, 0)), void>::value"); } diff --git a/test/std/depr/depr.c.headers/stdarg_h.pass.cpp b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp index f7d12b1ad551..e3c38801e4a8 100644 --- a/test/std/depr/depr.c.headers/stdarg_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp @@ -11,11 +11,13 @@ #include <stdarg.h> +#include "test_macros.h" + #ifndef va_arg #error va_arg not defined #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 # ifndef va_copy # error va_copy is not defined when c++ >= 11 # endif diff --git a/test/std/depr/depr.c.headers/stdint_h.pass.cpp b/test/std/depr/depr.c.headers/stdint_h.pass.cpp index 92bb04e558bb..3d49111fd82b 100644 --- a/test/std/depr/depr.c.headers/stdint_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdint_h.pass.cpp @@ -171,8 +171,8 @@ int main() // INTN_MIN static_assert(INT8_MIN == -128, "INT8_MIN == -128"); static_assert(INT16_MIN == -32768, "INT16_MIN == -32768"); - static_assert(INT32_MIN == -2147483648U, "INT32_MIN == -2147483648"); - static_assert(INT64_MIN == -9223372036854775808ULL, "INT64_MIN == -9223372036854775808LL"); + static_assert(INT32_MIN == -2147483647 - 1, "INT32_MIN == -2147483648"); + static_assert(INT64_MIN == -9223372036854775807LL - 1, "INT64_MIN == -9223372036854775808LL"); // INTN_MAX static_assert(INT8_MAX == 127, "INT8_MAX == 127"); @@ -189,8 +189,8 @@ int main() // INT_FASTN_MIN static_assert(INT_FAST8_MIN <= -128, "INT_FAST8_MIN <= -128"); static_assert(INT_FAST16_MIN <= -32768, "INT_FAST16_MIN <= -32768"); - static_assert(INT_FAST32_MIN <= -2147483648U, "INT_FAST32_MIN <= -2147483648"); - static_assert(INT_FAST64_MIN <= -9223372036854775808ULL, "INT_FAST64_MIN <= -9223372036854775808LL"); + static_assert(INT_FAST32_MIN <= -2147483647 - 1, "INT_FAST32_MIN <= -2147483648"); + static_assert(INT_FAST64_MIN <= -9223372036854775807LL - 1, "INT_FAST64_MIN <= -9223372036854775808LL"); // INT_FASTN_MAX static_assert(INT_FAST8_MAX >= 127, "INT_FAST8_MAX >= 127"); diff --git a/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/test/std/depr/depr.c.headers/stdio_h.pass.cpp index 3c5dd0ebf0e0..85f9d2986284 100644 --- a/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -99,17 +99,25 @@ #include <cstdarg> +#if defined(__GNUC__) #pragma GCC diagnostic ignored "-Wformat-zero-length" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam +#endif int main() { FILE* fp = 0; - fpos_t fpos = {0}; - size_t s = 0; ((void)s); + fpos_t fpos = {}; + size_t s = 0; char* cp = 0; char arr[] = {'a', 'b'}; va_list va; + ((void)fp); // Prevent unused warning + ((void)fpos); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)cp); // Prevent unused warning + ((void)arr); // Prevent unused warning + ((void)va); // Prevent unused warning static_assert((std::is_same<decltype(remove("")), int>::value), ""); static_assert((std::is_same<decltype(rename("","")), int>::value), ""); static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), ""); diff --git a/test/std/depr/depr.c.headers/string_h.pass.cpp b/test/std/depr/depr.c.headers/string_h.pass.cpp index afc784f74b89..db0308b7ef82 100644 --- a/test/std/depr/depr.c.headers/string_h.pass.cpp +++ b/test/std/depr/depr.c.headers/string_h.pass.cpp @@ -47,4 +47,15 @@ int main() static_assert((std::is_same<decltype(memset(vp, 0, s)), void*>::value), ""); static_assert((std::is_same<decltype(strerror(0)), char*>::value), ""); static_assert((std::is_same<decltype(strlen(cpc)), size_t>::value), ""); + + // These tests fail on systems whose C library doesn't provide a correct overload + // set for strchr, strpbrk, strrchr, strstr, and memchr, unless the compiler is + // a suitably recent version of Clang. +#if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD) + static_assert((std::is_same<decltype(strchr(cpc, 0)), const char*>::value), ""); + static_assert((std::is_same<decltype(strpbrk(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(strrchr(cpc, 0)), const char*>::value), ""); + static_assert((std::is_same<decltype(strstr(cpc, cpc)), const char*>::value), ""); + static_assert((std::is_same<decltype(memchr(vpc, 0, s)), const void*>::value), ""); +#endif } diff --git a/test/std/depr/depr.c.headers/time_h.pass.cpp b/test/std/depr/depr.c.headers/time_h.pass.cpp index 0d229af409bd..a2639383cda7 100644 --- a/test/std/depr/depr.c.headers/time_h.pass.cpp +++ b/test/std/depr/depr.c.headers/time_h.pass.cpp @@ -25,7 +25,7 @@ int main() clock_t c = 0; ((void)c); size_t s = 0; time_t t = 0; - tm tmv = {0}; + tm tmv = {}; static_assert((std::is_same<decltype(clock()), clock_t>::value), ""); static_assert((std::is_same<decltype(difftime(t,t)), double>::value), ""); static_assert((std::is_same<decltype(mktime(&tmv)), time_t>::value), ""); diff --git a/test/std/depr/depr.c.headers/wchar_h.pass.cpp b/test/std/depr/depr.c.headers/wchar_h.pass.cpp index e561b3e5a724..f2e42a328588 100644 --- a/test/std/depr/depr.c.headers/wchar_h.pass.cpp +++ b/test/std/depr/depr.c.headers/wchar_h.pass.cpp @@ -9,8 +9,8 @@ // <wchar.h> - #include <wchar.h> +#include <stdarg.h> #include <type_traits> #ifndef NULL @@ -32,25 +32,25 @@ int main() { // mbstate_t comes from the underlying C library; it is defined (in C99) as: -// a complete object type other than an array type that can hold the conversion -// state information necessary to convert between sequences of multibyte +// a complete object type other than an array type that can hold the conversion +// state information necessary to convert between sequences of multibyte // characters and wide characters -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wmissing-braces" - mbstate_t mb = {0}; -#pragma clang diagnostic pop - + mbstate_t mb = {}; size_t s = 0; tm *tm = 0; wint_t w = 0; ::FILE* fp = 0; -#ifdef __APPLE__ - __darwin_va_list va; -#else - __builtin_va_list va; -#endif + ::va_list va; char* ns = 0; wchar_t* ws = 0; + ((void)mb); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)tm); // Prevent unused warning + ((void)w); // Prevent unused warning + ((void)fp); // Prevent unused warning + ((void)va); // Prevent unused warning + ((void)ns); // Prevent unused warning + ((void)ws); // Prevent unused warning static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), ""); @@ -82,19 +82,14 @@ int main() static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), ""); - // const wchar_t* wcschr((const wchar_t*)0, L' ') - See below static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), ""); - // const wchar_t* wcspbrk((const wchar_t*)0, L"") - See below static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), ""); - // const wchar_t* wcsrchr((const wchar_t*)0, L' ') - See below static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), ""); - // const wchar_t* wcsstr((const wchar_t*)0, L"") - See below static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), ""); - // const wchar_t* wmemchr((const wchar_t*)0, L' ', s) - See below static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), ""); @@ -110,10 +105,10 @@ int main() static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), ""); -// This test fails on systems whose C library doesn't provide a correct overload -// set for wcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr. There's no way for -// libc++ to fix that on the C library's behalf. -#ifndef __APPLE__ + // These tests fail on systems whose C library doesn't provide a correct overload + // set for wcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr, unless the compiler is + // a suitably recent version of Clang. +#if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD) static_assert((std::is_same<decltype(wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); |