1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// test <cstdio>
#include <cstdio>
#include <type_traits>
#include "test_macros.h"
#ifndef BUFSIZ
#error BUFSIZ not defined
#endif
#ifndef EOF
#error EOF not defined
#endif
#ifndef FILENAME_MAX
#error FILENAME_MAX not defined
#endif
#ifndef FOPEN_MAX
#error FOPEN_MAX not defined
#endif
#ifndef L_tmpnam
#error L_tmpnam not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
#ifndef SEEK_CUR
#error SEEK_CUR not defined
#endif
#ifndef SEEK_END
#error SEEK_END not defined
#endif
#ifndef SEEK_SET
#error SEEK_SET not defined
#endif
#ifndef TMP_MAX
#error TMP_MAX not defined
#endif
#ifndef _IOFBF
#error _IOFBF not defined
#endif
#ifndef _IOLBF
#error _IOLBF not defined
#endif
#ifndef _IONBF
#error _IONBF not defined
#endif
#ifndef stderr
#error stderr not defined
#endif
#ifndef stdin
#error stdin not defined
#endif
#ifndef stdout
#error stdout not defined
#endif
#include <cstdarg>
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-zero-length"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
int main(int, char**)
{
std::FILE* fp = 0;
std::fpos_t fpos = std::fpos_t();
std::size_t s = 0;
char* cp = 0;
std::va_list va;
void const* vp = 0;
((void)fp); // Prevent unused warning
((void)fpos); // Prevent unused warning
((void)s); // Prevent unused warning
((void)cp); // Prevent unused warning
((void)va); // Prevent unused warning
((void)vp); // Prevent unused warning
static_assert((std::is_same<decltype(std::fclose(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), "");
static_assert((std::is_same<decltype(std::vfprintf(fp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::fprintf(fp," ")), int>::value), "");
static_assert((std::is_same<decltype(std::fscanf(fp," ")), int>::value), "");
static_assert((std::is_same<decltype(std::snprintf(cp,0," ")), int>::value), "");
static_assert((std::is_same<decltype(std::sprintf(cp," ")), int>::value), "");
static_assert((std::is_same<decltype(std::sscanf(""," ")), int>::value), "");
static_assert((std::is_same<decltype(std::vfprintf(fp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vfscanf(fp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsnprintf(cp,0," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsprintf(cp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::vsscanf(""," ",va)), int>::value), "");
static_assert((std::is_same<decltype(std::fgetc(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fgets(cp,0,fp)), char*>::value), "");
static_assert((std::is_same<decltype(std::fputc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fputs("",fp)), int>::value), "");
static_assert((std::is_same<decltype(std::getc(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::putc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(std::ungetc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(std::fread((void*)0,0,0,fp)), std::size_t>::value), "");
static_assert((std::is_same<decltype(std::fwrite(vp,0,0,fp)), std::size_t>::value), "");
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
static_assert((std::is_same<decltype(std::fgetpos(fp, &fpos)), int>::value), "");
#endif
static_assert((std::is_same<decltype(std::fseek(fp, 0,0)), int>::value), "");
#ifndef _LIBCPP_HAS_NO_FGETPOS_FSETPOS
static_assert((std::is_same<decltype(std::fsetpos(fp, &fpos)), int>::value), "");
#endif
static_assert((std::is_same<decltype(std::ftell(fp)), long>::value), "");
static_assert((std::is_same<decltype(std::rewind(fp)), void>::value), "");
static_assert((std::is_same<decltype(std::clearerr(fp)), void>::value), "");
static_assert((std::is_same<decltype(std::feof(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::ferror(fp)), int>::value), "");
static_assert((std::is_same<decltype(std::perror("")), void>::value), "");
#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
static_assert((std::is_same<decltype(std::fopen("", "")), std::FILE*>::value), "");
static_assert((std::is_same<decltype(std::freopen("", "", fp)), std::FILE*>::value), "");
static_assert((std::is_same<decltype(std::remove("")), int>::value), "");
static_assert((std::is_same<decltype(std::rename("","")), int>::value), "");
static_assert((std::is_same<decltype(std::tmpfile()), std::FILE*>::value), "");
static_assert((std::is_same<decltype(std::tmpnam(cp)), char*>::value), "");
#endif
#ifndef _LIBCPP_HAS_NO_STDIN
static_assert((std::is_same<decltype(std::getchar()), int>::value), "");
#if TEST_STD_VER <= 11
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-declarations" // disable the warning from the C library
static_assert((std::is_same<decltype(std::gets(cp)), char*>::value), "");
# pragma GCC diagnostic pop
#endif
static_assert((std::is_same<decltype(std::scanf(" ")), int>::value), "");
static_assert((std::is_same<decltype(std::vscanf(" ",va)), int>::value), "");
#endif
#ifndef _LIBCPP_HAS_NO_STDOUT
static_assert((std::is_same<decltype(std::printf(" ")), int>::value), "");
static_assert((std::is_same<decltype(std::putchar(0)), int>::value), "");
static_assert((std::is_same<decltype(std::puts("")), int>::value), "");
static_assert((std::is_same<decltype(std::vprintf(" ",va)), int>::value), "");
#endif
return 0;
}
|