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