[PATCH] D12747: Implement [depr.c.headers]
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 20:33:33 PDT 2015
Attached patch adds a test that all required functions from the C standard
library (and any required overloads) are present with the correct types,
and that the declarations in the <foo.h> and <cfoo> headers declare the
same entity as required by [depr.c.headers]p2.
On Thu, Oct 8, 2015 at 6:58 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Thu, Oct 8, 2015 at 6:25 PM, Eric Fiselier <eric at efcs.ca> wrote:
>
>> Patch #12 needs revision. A bunch of function definitions were moved
>> out of the std namespace and into the global.
>> That change is incorrect.
>
>
> Slightly updated version attached. I should probably explain what's going
> on here in more detail:
>
> Per [c.strings]p4-p13, we're supposed to replace C functions of the form
>
> char *foo(const char*);
>
> with a pair of const-correct overloads of the form
>
> char *foo(char *);
> const char *foo(const char*);
>
> Now, most C standard libraries will do this for us when included in C++
> mode (because it's not possible for the C++ library to fix this up after
> the fact). For the cases where we *don't* believe we have such a
> considerate C library, we add one declaration to C's overload, to get:
>
> char *foo(char*);
> char *foo(const char*)
>
> ... which doesn't really help much, but is the closest we can get to the
> right set of declarations. The declarations we add just dispatch to the C
> declarations.
>
> These new declarations *should* be in the global namespace when including
> <string.h>, and it makes sense for us to put them in the global namespace
> when including <cstring> (otherwise, that header leaves us with a broken
> overload set in the global namespace, containing just one of the two
> expected functions).
>
> Anyway, most of the above is a description of what we did before. What's
> new here is that we attempt to fix the overload set for both <string.h> and
> for <cstring>, not just for the latter. At the end of all these changes,
> you'll see that all that the <cfoo> headers do is to include the <foo.h>
> header and use using-declarations to pull the names into namespace std;
> this is no exception to that pattern.
>
>
>> On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier <eric at efcs.ca> wrote:
>> > Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored
>> > "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?
>> > I would like to leave it in so this test doesn't fail with older clang
>> > versions.
>> >
>> > /Eric
>> >
>> > On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier <eric at efcs.ca> wrote:
>> >> Patch #10 LGTM.
>> >>
>> >> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>> >>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow <mclow.lists at gmail.com
>> >
>> >>> wrote:
>> >>>>
>> >>>> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith <richard at metafoo.co.uk
>> >
>> >>>> wrote:
>> >>>>>
>> >>>>> <stddef.h>. This one is tricky:
>> >>>>>
>> >>>>> 1) There's an (undocumented) interface between the C standard
>> library and
>> >>>>> this header, where the macros __need_ptrdiff_t, __need_size_t,
>> >>>>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of
>> this
>> >>>>> header rather than the whole thing. If we see any of those, just go
>> straight
>> >>>>> to the underlying header.
>> >>>>
>> >>>>
>> >>>> Ok, but in that case we don't get nullptr. I suspect that's OK.
>> >>>>
>> >>>>>
>> >>>>> 2) We probably don't want <stddef.h> to include <cstddef> (for
>> >>>>> consistency with other headers)
>> >>>>
>> >>>>
>> >>>> No, we do not! :-)
>> >>>>
>> >>>>>
>> >>>>> , but <stddef.h> must provide a ::nullptr_t (which we don't want
>> >>>>> <cstddef> to provide). So neither header includes the other.
>> Instead, both
>> >>>>> include <__nullptr> for std::nullptr_t, and we duplicate the
>> definition of
>> >>>>> max_align_t between them, in the case where the compiler's
>> <stddef.h>
>> >>>>> doesn't provide it.
>> >>>>>
>> >>>>> If you prefer, I could make <stddef.h> include <cstddef> to avoid
>> the
>> >>>>> duplication of the max_align_t logic.
>> >>>>
>> >>>>
>> >>>> No; this is a minor annoyance, and layer jumping (<stdXXX.h>
>> including
>> >>>> <cstdXXX>) is a major annoyance - and I'm pretty sure that that
>> would come
>> >>>> back to bite us in the future.
>> >>>>
>> >>>> Looks ok to me.
>> >>>
>> >>>
>> >>> Thanks, everything up to and including patch 09 is now committed.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151008/12f0d847/attachment-0001.html>
-------------- next part --------------
diff --git test/std/depr/depr.c.headers/same_decls.pass.cpp test/std/depr/depr.c.headers/same_decls.pass.cpp
new file mode 100644
index 0000000..c5a5cf1
--- /dev/null
+++ test/std/depr/depr.c.headers/same_decls.pass.cpp
@@ -0,0 +1,513 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Every C header behaves as if the names in namespace std are placed into the
+// global namespace. This implies that the addresses of such functions must
+// match between the declaration in the global namespace and the declaration in
+// namespace std.
+
+#include <__config>
+
+template<typename T, T *F, T *G> struct check { static_assert(F == G, ""); };
+
+// ctype.h
+
+#include <ctype.h>
+#include <cctype>
+
+void test_ctype() {
+ check<int(int), isalnum, std::isalnum>();
+ check<int(int), isalpha, std::isalpha>();
+ check<int(int), isblank, std::isblank>();
+ check<int(int), iscntrl, std::iscntrl>();
+ check<int(int), isdigit, std::isdigit>();
+ check<int(int), isgraph, std::isgraph>();
+ check<int(int), islower, std::islower>();
+ check<int(int), isprint, std::isprint>();
+ check<int(int), ispunct, std::ispunct>();
+ check<int(int), isspace, std::isspace>();
+ check<int(int), isupper, std::isupper>();
+ check<int(int), isxdigit, std::isxdigit>();
+ check<int(int), tolower, std::tolower>();
+ check<int(int), toupper, std::toupper>();
+}
+
+// fenv.h
+
+#include <fenv.h>
+#include <cfenv>
+
+void test_fenv() {
+ check<int(int), feclearexcept, std::feclearexcept>();
+ check<int(fexcept_t *, int), fegetexceptflag, std::fegetexceptflag>();
+ check<int(int), feraiseexcept, std::feraiseexcept>();
+ check<int(const fexcept_t *, int), fesetexceptflag, std::fesetexceptflag>();
+ check<int(int), fetestexcept, std::fetestexcept>();
+ check<int(), fegetround, std::fegetround>();
+ check<int(int), fesetround, std::fesetround>();
+ check<int(fenv_t *), fegetenv, std::fegetenv>();
+ check<int(fenv_t *), feholdexcept, std::feholdexcept>();
+ check<int(const fenv_t *), fesetenv, std::fesetenv>();
+ check<int(const fenv_t *), feupdateenv, std::feupdateenv>();
+}
+
+// inttypes.h
+
+#include <inttypes.h>
+#include <cinttypes>
+
+// Avoid error if abs and div are not declared by <inttypes.h>.
+struct nat {};
+static void abs(nat);
+static void div(nat);
+namespace std {
+ static void abs(nat);
+ static void div(nat);
+}
+
+// These may or may not exist, depending on whether intmax_t
+// is an extended integer type (larger than long long).
+template<typename I = intmax_t, bool = (sizeof(I) > sizeof(long long))>
+void test_inttypes_abs_div() {
+ check<I(I), abs, std::abs>();
+ check<imaxdiv_t(I, I), div, std::div>();
+}
+template<> void test_inttypes_abs_div<intmax_t, false>() {}
+
+void test_inttypes() {
+ test_inttypes_abs_div();
+
+ check<intmax_t(intmax_t), imaxabs, std::imaxabs>();
+ check<imaxdiv_t(intmax_t, intmax_t), imaxdiv, std::imaxdiv>();
+ check<intmax_t(const char *, char **, int), strtoimax, std::strtoimax>();
+ check<uintmax_t(const char *, char **, int), strtoumax, std::strtoumax>();
+ check<intmax_t(const wchar_t *, wchar_t **, int), wcstoimax, std::wcstoimax>();
+ check<uintmax_t(const wchar_t *, wchar_t **, int), wcstoumax, std::wcstoumax>();
+}
+
+// locale.h
+
+#include <locale.h>
+#include <clocale>
+
+void test_locale() {
+ check<char *(int, const char *), setlocale, std::setlocale>();
+ check<lconv *(), localeconv, std::localeconv>();
+}
+
+// math.h
+
+#include <math.h>
+#include <cmath>
+
+template<typename Float>
+void test_math_float() {
+ typedef Float ff(Float);
+ typedef Float ffi(Float, int);
+ typedef Float ffpi(Float, int*);
+ typedef Float ffl(Float, long);
+ typedef Float fff(Float, Float);
+ typedef Float ffpf(Float, Float*);
+ typedef Float ffld(Float, long double);
+ typedef Float fffpi(Float, Float, int*);
+ typedef Float ffff(Float, Float, Float);
+ typedef bool bf(Float);
+ typedef bool bff(Float, Float);
+ typedef int i_f(Float);
+ typedef long lf(Float);
+ typedef long long llf(Float);
+
+ check<ff, abs, std::abs>();
+ check<ff, acos, std::acos>();
+ check<ff, acosh, std::acosh>();
+ check<ff, asin, std::asin>();
+ check<ff, asinh, std::asinh>();
+ check<ff, atan, std::atan>();
+ check<fff, atan2, std::atan2>();
+ check<ff, atanh, std::atanh>();
+ check<ff, cbrt, std::cbrt>();
+ check<ff, ceil, std::ceil>();
+ check<fff, copysign, std::copysign>();
+ check<ff, cos, std::cos>();
+ check<ff, cosh, std::cosh>();
+ check<ff, erf, std::erf>();
+ check<ff, erfc, std::erfc>();
+ check<ff, exp, std::exp>();
+ check<ff, exp2, std::exp2>();
+ check<ff, expm1, std::expm1>();
+ check<ff, fabs, std::fabs>();
+ check<fff, fdim, std::fdim>();
+ check<ff, floor, std::floor>();
+ check<ffff, fma, std::fma>();
+ check<fff, fmax, std::fmax>();
+ check<fff, fmin, std::fmin>();
+ check<fff, fmod, std::fmod>();
+ check<ffpi, frexp, std::frexp>();
+ check<fff, hypot, std::hypot>();
+ check<i_f, ilogb, std::ilogb>();
+ check<ffi, ldexp, std::ldexp>();
+ check<ff, lgamma, std::lgamma>();
+ check<llf, llrint, std::llrint>();
+ check<llf, llround, std::llround>();
+ check<ff, log, std::log>();
+ check<ff, log10, std::log10>();
+ check<ff, log1p, std::log1p>();
+ check<ff, log2, std::log2>();
+ check<ff, logb, std::logb>();
+ check<lf, lrint, std::lrint>();
+ check<lf, lround, std::lround>();
+ check<ffpf, modf, std::modf>();
+ check<ff, nearbyint, std::nearbyint>();
+ check<fff, nextafter, std::nextafter>();
+ check<ffld, nexttoward, std::nexttoward>();
+ check<fff, pow, std::pow>();
+ check<fff, remainder, std::remainder>();
+ check<fffpi, remquo, std::remquo>();
+ check<ff, rint, std::rint>();
+ check<ff, round, std::round>();
+ check<ffl, scalbln, std::scalbln>();
+ check<ffi, scalbn, std::scalbn>();
+ check<ff, sin, std::sin>();
+ check<ff, sinh, std::sinh>();
+ check<ff, sqrt, std::sqrt>();
+ check<ff, tan, std::tan>();
+ check<ff, tanh, std::tanh>();
+ check<ff, tgamma, std::tgamma>();
+ check<ff, trunc, std::trunc>();
+
+ check<i_f, fpclassify, std::fpclassify>();
+ check<bf, isfinite, std::isfinite>();
+ check<bff, isgreater, std::isgreater>();
+ check<bff, isgreaterequal, std::isgreaterequal>();
+ check<bf, isinf, std::isinf>();
+ check<bff, isless, std::isless>();
+ check<bff, islessequal, std::islessequal>();
+ check<bff, islessgreater, std::islessgreater>();
+ check<bf, isnan, std::isnan>();
+ check<bf, isnormal, std::isnormal>();
+ check<bff, isunordered, std::isunordered>();
+ check<bf, signbit, std::signbit>();
+}
+
+void test_math() {
+ test_math_float<float>();
+ test_math_float<double>();
+ test_math_float<long double>();
+
+ check<float(const char *), nanf, std::nanf>();
+ check<double(const char *), nan, std::nan>();
+ check<long double(const char *), nanl, std::nanl>();
+}
+
+// setjmp.h
+
+#include <setjmp.h>
+#include <csetjmp>
+
+void test_setjmp() {
+ check<void(jmp_buf, int), longjmp, std::longjmp>();
+}
+
+// signal.h
+
+#include <signal.h>
+#include <csignal>
+
+void test_signal() {
+ check<int(int), raise, std::raise>();
+ typedef void Handler(int);
+ check<Handler *(int, Handler *), signal, std::signal>();
+}
+
+// stdio.h
+
+#include <stdio.h>
+#include <cstdio>
+
+void test_stdio() {
+ check<void(FILE *), clearerr, std::clearerr>();
+ check<int(FILE *), fclose, std::fclose>();
+ check<int(FILE *), feof, std::feof>();
+ check<int(FILE *), ferror, std::ferror>();
+ check<int(FILE *), fflush, std::fflush>();
+ check<int(FILE *), fgetc, std::fgetc>();
+ check<int(FILE *, fpos_t *), fgetpos, std::fgetpos>();
+ check<char *(char *, int, FILE *), fgets, std::fgets>();
+ check<FILE *(const char *, const char *), fopen, std::fopen>();
+ check<int(FILE *, const char *, ...), fprintf, std::fprintf>();
+ check<int(int, FILE *), fputc, std::fputc>();
+ check<int(const char *, FILE *), fputs, std::fputs>();
+ check<size_t(void *, size_t, size_t, FILE *), fread, std::fread>();
+ check<FILE *(const char *, const char *, FILE *), freopen, std::freopen>();
+ check<int(FILE *, const char *, ...), fscanf, std::fscanf>();
+ check<int(FILE *, long, int), fseek, std::fseek>();
+ check<int(FILE *, const fpos_t *), fsetpos, std::fsetpos>();
+ check<long(FILE *), ftell, std::ftell>();
+ check<size_t(const void *, size_t, size_t, FILE *), fwrite, std::fwrite>();
+ check<int(FILE *), getc, std::getc>();
+ check<int(), getchar, std::getchar>();
+ check<void(const char *), perror, std::perror>();
+ check<int(const char *, ...), printf, std::printf>();
+ check<int(int, FILE *), putc, std::putc>();
+ check<int(int), putchar, std::putchar>();
+ check<int(const char *), puts, std::puts>();
+ check<int(const char *), remove, std::remove>();
+ check<int(const char *, const char *), rename, std::rename>();
+ check<void(FILE *), rewind, std::rewind>();
+ check<int(const char *, ...), scanf, std::scanf>();
+ check<void(FILE *, char *), setbuf, std::setbuf>();
+ check<int(FILE *, char *, int, size_t), setvbuf, std::setvbuf>();
+ check<int(char *, size_t, const char *, ...), snprintf, std::snprintf>();
+ check<int(char *, const char *, ...), sprintf, std::sprintf>();
+ check<int(const char *, const char *, ...), sscanf, std::sscanf>();
+ check<FILE *(), tmpfile, std::tmpfile>();
+ check<char *(char *), tmpnam, std::tmpnam>();
+ check<int(int, FILE *), ungetc, std::ungetc>();
+ check<int(FILE *, const char *, va_list), vfprintf, std::vfprintf>();
+ check<int(const char *, va_list), vprintf, std::vprintf>();
+ check<int(const char *, va_list), vscanf, std::vscanf>();
+ check<int(char *, size_t, const char *, va_list), vsnprintf, std::vsnprintf>();
+ check<int(char *, const char *, va_list), vsprintf, std::vsprintf>();
+ check<int(const char *, const char *, va_list), vsscanf, std::vsscanf>();
+}
+
+// stdlib.h
+
+#include <stdlib.h>
+#include <cstdlib>
+
+void test_stdlib() {
+ typedef int Comp(const void*, const void*);
+
+ check<void(int), _Exit, std::_Exit>();
+ check<int(void()), at_quick_exit, std::at_quick_exit>();
+ check<void(), abort, std::abort>();
+ check<void(int), exit, std::exit>();
+ check<int(void()), atexit, std::atexit>();
+ check<void(int), quick_exit, std::quick_exit>();
+ check<char *(const char *), getenv, std::getenv>();
+ check<int(const char *), system, std::system>();
+ check<void *(size_t, size_t), calloc, std::calloc>();
+ check<void(void *), free, std::free>();
+ check<void *(size_t), malloc, std::malloc>();
+ check<void *(void *, size_t), realloc, std::realloc>();
+ check<double(const char *), atof, std::atof>();
+ check<int(const char *), atoi, std::atoi>();
+ check<long(const char *), atol, std::atol>();
+ check<long long(const char *), atoll, std::atoll>();
+ check<int(const char *, size_t), mblen, std::mblen>();
+ check<int(wchar_t *, const char *, size_t), mbtowc, std::mbtowc>();
+ check<size_t(wchar_t *, const char *, size_t), mbstowcs, std::mbstowcs>();
+ check<double(const char *, char **), strtod, std::strtod>();
+ check<float(const char *, char **), strtof, std::strtof>();
+ check<long(const char *, char **, int), strtol, std::strtol>();
+ check<long double(const char *, char **), strtold, std::strtold>();
+ check<long long(const char *, char **, int), strtoll, std::strtoll>();
+ check<unsigned long(const char *, char **, int), strtoul, std::strtoul>();
+ check<unsigned long long(const char *, char **, int), strtoull, std::strtoull>();
+ check<int(char *, wchar_t), wctomb, std::wctomb>();
+ check<size_t(char *, const wchar_t *, size_t), wcstombs, std::wcstombs>();
+ check<void *(const void *, const void *, size_t, size_t, Comp *), bsearch, std::bsearch>();
+ check<void(void *, size_t, size_t, Comp *), qsort, std::qsort>();
+ check<int(int), abs, std::abs>();
+ check<div_t(int, int), div, std::div>();
+ check<long(long), abs, std::abs>();
+ check<long(long), labs, std::labs>();
+ check<ldiv_t(long, long), div, std::div>();
+ check<ldiv_t(long, long), ldiv, std::ldiv>();
+ check<long long(long long), abs, std::abs>();
+ check<long long(long long), llabs, std::llabs>();
+ check<lldiv_t(long long, long long), div, std::div>();
+ check<lldiv_t(long long, long long), lldiv, std::lldiv>();
+ check<int(), rand, std::rand>();
+ check<void(unsigned), srand, std::srand>();
+}
+
+// string.h
+
+#include <string.h>
+#include <cstring>
+
+void test_string() {
+ check<void *(void *, int, size_t), memchr, std::memchr>();
+ check<const void *(const void *, int, size_t), memchr, std::memchr>();
+ check<int(const void *, const void *, size_t), memcmp, std::memcmp>();
+ check<void *(void *, const void *, size_t), memcpy, std::memcpy>();
+ check<void *(void *, const void *, size_t), memmove, std::memmove>();
+ check<void *(void *, int, size_t), memset, std::memset>();
+ check<char *(char *, const char *), strcat, std::strcat>();
+ check<char *(char *, int), strchr, std::strchr>();
+ check<const char *(const char *, int), strchr, std::strchr>();
+ check<int(const char *, const char *), strcmp, std::strcmp>();
+ check<int(const char *, const char *), strcoll, std::strcoll>();
+ check<char *(char *, const char *), strcpy, std::strcpy>();
+ check<size_t(const char *, const char *), strcspn, std::strcspn>();
+ check<char *(int), strerror, std::strerror>();
+ check<size_t(const char *), strlen, std::strlen>();
+ check<char *(char *, const char *, size_t), strncat, std::strncat>();
+ check<int(const char *, const char *, size_t), strncmp, std::strncmp>();
+ check<char *(char *, const char *, size_t), strncpy, std::strncpy>();
+ check<char *(char *, const char *), strpbrk, std::strpbrk>();
+ check<const char *(const char *, const char *), strpbrk, std::strpbrk>();
+ check<char *(char *, int), strrchr, std::strrchr>();
+ check<const char *(const char *, int), strrchr, std::strrchr>();
+ check<size_t(const char *, const char *), strspn, std::strspn>();
+ check<char *(char *, const char *), strstr, std::strstr>();
+ check<const char *(const char *, const char *), strstr, std::strstr>();
+ check<char *(char *, const char *), strtok, std::strtok>();
+ check<size_t(char *, const char *, size_t), strxfrm, std::strxfrm>();
+}
+
+// time.h
+
+#include <time.h>
+#include <ctime>
+
+void test_time() {
+ check<char *(const tm *), asctime, std::asctime>();
+ check<char *(const time_t *), ctime, std::ctime>();
+ check<clock_t(), clock, std::clock>();
+ check<tm *(const time_t *), gmtime, std::gmtime>();
+ check<double(time_t, time_t), difftime, std::difftime>();
+ check<time_t(tm *), mktime, std::mktime>();
+ check<tm *(const time_t *), localtime, std::localtime>();
+ check<time_t(time_t *), time, std::time>();
+ check<size_t(char *, size_t, const char *, const tm *), strftime, std::strftime>();
+}
+
+#if 0
+// FIXME: <cuchar> and <uchar.h> are missing.
+
+// uchar.h
+
+#include <uchar.h>
+#include <cuchar>
+
+void test_uchar() {
+ check<size_t(char16_t *, const char *, size_t, mbstate_t *), mbrtoc16, std::mbrtoc16>();
+ check<size_t(char32_t *, const char *, size_t, mbstate_t *), mbrtoc32, std::mbrtoc32>();
+ check<size_t(char *, char16_t, mbstate_t *), c16rtomb, std::c16rtomb>();
+ check<size_t(char *, char32_t, mbstate_t *), c32rtomb, std::c32rtomb>();
+}
+#endif
+
+// wchar.h
+
+#include <wchar.h>
+#include <cwchar>
+
+void test_wchar() {
+ check<wint_t(int), btowc, std::btowc>();
+ check<wint_t(FILE *), fgetwc, std::fgetwc>();
+ check<wchar_t *(wchar_t *, int, FILE *), fgetws, std::fgetws>();
+ check<wint_t(wchar_t, FILE *), fputwc, std::fputwc>();
+ check<int(const wchar_t *, FILE *), fputws, std::fputws>();
+ check<int(FILE *, int), fwide, std::fwide>();
+ check<int(FILE *, const wchar_t *, ...), fwprintf, std::fwprintf>();
+ check<int(FILE *, const wchar_t *, ...), fwscanf, std::fwscanf>();
+ check<wint_t(), getwchar, std::getwchar>();
+ check<wint_t(FILE *), getwc, std::getwc>();
+ check<size_t(const char *, size_t, mbstate_t *), mbrlen, std::mbrlen>();
+ check<size_t(wchar_t *, const char *, size_t, mbstate_t *), mbrtowc, std::mbrtowc>();
+ check<int(const mbstate_t *), mbsinit, std::mbsinit>();
+ check<size_t(wchar_t *, const char **, size_t, mbstate_t *), mbsrtowcs, std::mbsrtowcs>();
+ check<wint_t(wchar_t), putwchar, std::putwchar>();
+ check<wint_t(wchar_t, FILE *), putwc, std::putwc>();
+ check<int(wchar_t *, size_t, const wchar_t *, ...), swprintf, std::swprintf>();
+ check<int(const wchar_t *, const wchar_t *, ...), swscanf, std::swscanf>();
+ check<wint_t(wint_t, FILE *), ungetwc, std::ungetwc>();
+ check<int(FILE *, const wchar_t *, va_list), vfwprintf, std::vfwprintf>();
+ check<int(FILE *, const wchar_t *, va_list), vfwscanf, std::vfwscanf>();
+ check<int(wchar_t *, size_t, const wchar_t *, va_list), vswprintf, std::vswprintf>();
+ check<int(const wchar_t *, const wchar_t *, va_list), vswscanf, std::vswscanf>();
+ check<int(const wchar_t *, va_list), vwprintf, std::vwprintf>();
+ check<int(const wchar_t *, va_list), vwscanf, std::vwscanf>();
+ check<size_t(char *, wchar_t, mbstate_t *), wcrtomb, std::wcrtomb>();
+ check<wchar_t *(wchar_t *, const wchar_t *), wcscat, std::wcscat>();
+ check<wchar_t *(wchar_t *, wchar_t), wcschr, std::wcschr>();
+ check<const wchar_t *(const wchar_t *, wchar_t), wcschr, std::wcschr>();
+ check<int(const wchar_t *, const wchar_t *), wcscmp, std::wcscmp>();
+ check<int(const wchar_t *, const wchar_t *), wcscoll, std::wcscoll>();
+ check<wchar_t *(wchar_t *, const wchar_t *), wcscpy, std::wcscpy>();
+ check<size_t(const wchar_t *, const wchar_t *), wcscspn, std::wcscspn>();
+ check<size_t(wchar_t *, size_t, const wchar_t *, const tm *), wcsftime, std::wcsftime>();
+ check<size_t(const wchar_t *), wcslen, std::wcslen>();
+ check<wchar_t *(wchar_t *, const wchar_t *, size_t), wcsncat, std::wcsncat>();
+ check<int(const wchar_t *, const wchar_t *, size_t), wcsncmp, std::wcsncmp>();
+ check<wchar_t *(wchar_t *, const wchar_t *, size_t), wcsncpy, std::wcsncpy>();
+ check<wchar_t *(wchar_t *, const wchar_t *), wcspbrk, std::wcspbrk>();
+ check<const wchar_t *(const wchar_t *, const wchar_t *), wcspbrk, std::wcspbrk>();
+ check<wchar_t *(wchar_t *, wchar_t), wcsrchr, std::wcsrchr>();
+ check<const wchar_t *(const wchar_t *, wchar_t), wcsrchr, std::wcsrchr>();
+ check<size_t(char *, const wchar_t **, size_t, mbstate_t *), wcsrtombs, std::wcsrtombs>();
+ check<size_t(const wchar_t *, const wchar_t *), wcsspn, std::wcsspn>();
+ check<wchar_t *(wchar_t *, const wchar_t *), wcsstr, std::wcsstr>();
+ check<const wchar_t *(const wchar_t *, const wchar_t *), wcsstr, std::wcsstr>();
+ check<double(const wchar_t *, wchar_t **), wcstod, std::wcstod>();
+ check<float(const wchar_t *, wchar_t **), wcstof, std::wcstof>();
+ check<wchar_t *(wchar_t *, const wchar_t *, wchar_t **), wcstok, std::wcstok>();
+ check<long double(const wchar_t *, wchar_t **), wcstold, std::wcstold>();
+ check<long long(const wchar_t *, wchar_t **, int), wcstoll, std::wcstoll>();
+ check<long(const wchar_t *, wchar_t **, int), wcstol, std::wcstol>();
+ check<unsigned long long(const wchar_t *, wchar_t **, int), wcstoull, std::wcstoull>();
+ check<unsigned long(const wchar_t *, wchar_t **, int), wcstoul, std::wcstoul>();
+ check<size_t(wchar_t *, const wchar_t *, size_t), wcsxfrm, std::wcsxfrm>();
+ check<int(wint_t), wctob, std::wctob>();
+ check<wchar_t *(wchar_t *, wchar_t, size_t), wmemchr, std::wmemchr>();
+ check<const wchar_t *(const wchar_t *, wchar_t, size_t), wmemchr, std::wmemchr>();
+ check<int(const wchar_t *, const wchar_t *, size_t), wmemcmp, std::wmemcmp>();
+ check<wchar_t *(wchar_t *, const wchar_t *, size_t), wmemcpy, std::wmemcpy>();
+ check<wchar_t *(wchar_t *, const wchar_t *, size_t), wmemmove, std::wmemmove>();
+ check<wchar_t *(wchar_t *, wchar_t, size_t), wmemset, std::wmemset>();
+ check<int(const wchar_t *, ...), wprintf, std::wprintf>();
+ check<int(const wchar_t *, ...), wscanf, std::wscanf>();
+}
+
+// wctype.h
+
+#include <wctype.h>
+#include <cwctype>
+
+void test_wctype() {
+ check<int(wint_t), iswalnum, std::iswalnum>();
+ check<int(wint_t), iswalpha, std::iswalpha>();
+ check<int(wint_t), iswblank, std::iswblank>();
+ check<int(wint_t), iswcntrl, std::iswcntrl>();
+ check<int(wint_t, wctype_t), iswctype, std::iswctype>();
+ check<int(wint_t), iswdigit, std::iswdigit>();
+ check<int(wint_t), iswgraph, std::iswgraph>();
+ check<int(wint_t), iswlower, std::iswlower>();
+ check<int(wint_t), iswprint, std::iswprint>();
+ check<int(wint_t), iswpunct, std::iswpunct>();
+ check<int(wint_t), iswspace, std::iswspace>();
+ check<int(wint_t), iswupper, std::iswupper>();
+ check<int(wint_t), iswxdigit, std::iswxdigit>();
+ check<wint_t(wint_t, wctrans_t), towctrans, std::towctrans>();
+ check<wint_t(wint_t), towlower, std::towlower>();
+ check<wint_t(wint_t), towupper, std::towupper>();
+ check<wctrans_t(const char *), wctrans, std::wctrans>();
+ check<wctype_t(const char *), wctype, std::wctype>();
+}
+
+int main() {
+ test_ctype();
+ test_fenv();
+ test_inttypes();
+ test_locale();
+ test_math();
+ test_setjmp();
+ test_signal();
+ test_stdio();
+ test_stdlib();
+ test_string();
+ test_time();
+ //test_uchar();
+ test_wchar();
+ test_wctype();
+}
More information about the cfe-commits
mailing list