1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 #include <type_traits>
14 #include "test_macros.h"
17 #error BUFSIZ not defined
21 #error EOF not defined
25 #error FILENAME_MAX not defined
29 #error FOPEN_MAX not defined
33 #error L_tmpnam not defined
37 #error NULL not defined
41 #error SEEK_CUR not defined
45 #error SEEK_END not defined
49 #error SEEK_SET not defined
53 #error TMP_MAX not defined
57 #error _IOFBF not defined
61 #error _IOLBF not defined
65 #error _IONBF not defined
69 #error stderr not defined
73 #error stdin not defined
77 #error stdout not defined
82 TEST_CLANG_DIAGNOSTIC_IGNORED("-Wformat-zero-length")
87 std::fpos_t fpos
= std::fpos_t();
92 ((void)fp
); // Prevent unused warning
93 ((void)fpos
); // Prevent unused warning
94 ((void)s
); // Prevent unused warning
95 ((void)cp
); // Prevent unused warning
96 ((void)va
); // Prevent unused warning
97 ((void)vp
); // Prevent unused warning
98 static_assert((std::is_same
<decltype(std::fclose(fp
)), int>::value
), "");
99 static_assert((std::is_same
<decltype(std::fflush(fp
)), int>::value
), "");
100 static_assert((std::is_same
<decltype(std::setbuf(fp
,cp
)), void>::value
), "");
101 static_assert((std::is_same
<decltype(std::vfprintf(fp
," ",va
)), int>::value
), "");
102 static_assert((std::is_same
<decltype(std::fprintf(fp
," ")), int>::value
), "");
103 static_assert((std::is_same
<decltype(std::fscanf(fp
," ")), int>::value
), "");
104 static_assert((std::is_same
<decltype(std::snprintf(cp
,0," ")), int>::value
), "");
106 TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
107 TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
108 static_assert((std::is_same
<decltype(std::sprintf(cp
," ")), int>::value
), "");
110 static_assert((std::is_same
<decltype(std::sscanf(""," ")), int>::value
), "");
111 static_assert((std::is_same
<decltype(std::vfprintf(fp
," ",va
)), int>::value
), "");
112 static_assert((std::is_same
<decltype(std::vfscanf(fp
," ",va
)), int>::value
), "");
113 static_assert((std::is_same
<decltype(std::vsnprintf(cp
,0," ",va
)), int>::value
), "");
115 TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
116 TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
117 static_assert((std::is_same
<decltype(std::vsprintf(cp
," ",va
)), int>::value
), "");
119 static_assert((std::is_same
<decltype(std::vsscanf(""," ",va
)), int>::value
), "");
120 static_assert((std::is_same
<decltype(std::fgetc(fp
)), int>::value
), "");
121 static_assert((std::is_same
<decltype(std::fgets(cp
,0,fp
)), char*>::value
), "");
122 static_assert((std::is_same
<decltype(std::fputc(0,fp
)), int>::value
), "");
123 static_assert((std::is_same
<decltype(std::fputs("",fp
)), int>::value
), "");
124 static_assert((std::is_same
<decltype(std::getc(fp
)), int>::value
), "");
125 static_assert((std::is_same
<decltype(std::putc(0,fp
)), int>::value
), "");
126 static_assert((std::is_same
<decltype(std::ungetc(0,fp
)), int>::value
), "");
127 static_assert((std::is_same
<decltype(std::fread((void*)0,0,0,fp
)), std::size_t>::value
), "");
128 static_assert((std::is_same
<decltype(std::fwrite(vp
,0,0,fp
)), std::size_t>::value
), "");
129 static_assert((std::is_same
<decltype(std::fgetpos(fp
, &fpos
)), int>::value
), "");
130 static_assert((std::is_same
<decltype(std::fseek(fp
, 0,0)), int>::value
), "");
131 static_assert((std::is_same
<decltype(std::fsetpos(fp
, &fpos
)), int>::value
), "");
132 static_assert((std::is_same
<decltype(std::ftell(fp
)), long>::value
), "");
133 static_assert((std::is_same
<decltype(std::rewind(fp
)), void>::value
), "");
134 static_assert((std::is_same
<decltype(std::clearerr(fp
)), void>::value
), "");
135 static_assert((std::is_same
<decltype(std::feof(fp
)), int>::value
), "");
136 static_assert((std::is_same
<decltype(std::ferror(fp
)), int>::value
), "");
137 static_assert((std::is_same
<decltype(std::perror("")), void>::value
), "");
139 static_assert((std::is_same
<decltype(std::fopen("", "")), std::FILE*>::value
), "");
140 static_assert((std::is_same
<decltype(std::freopen("", "", fp
)), std::FILE*>::value
), "");
141 static_assert((std::is_same
<decltype(std::remove("")), int>::value
), "");
142 static_assert((std::is_same
<decltype(std::rename("","")), int>::value
), "");
143 static_assert((std::is_same
<decltype(std::tmpfile()), std::FILE*>::value
), "");
146 TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
147 TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
148 static_assert((std::is_same
<decltype(std::tmpnam(cp
)), char*>::value
), "");
151 static_assert((std::is_same
<decltype(std::getchar()), int>::value
), "");
152 #if TEST_STD_VER <= 11
154 TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
155 TEST_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
156 static_assert((std::is_same
<decltype(std::gets(cp
)), char*>::value
), "");
159 static_assert((std::is_same
<decltype(std::scanf(" ")), int>::value
), "");
160 static_assert((std::is_same
<decltype(std::vscanf(" ",va
)), int>::value
), "");
162 static_assert((std::is_same
<decltype(std::printf(" ")), int>::value
), "");
163 static_assert((std::is_same
<decltype(std::putchar(0)), int>::value
), "");
164 static_assert((std::is_same
<decltype(std::puts("")), int>::value
), "");
165 static_assert((std::is_same
<decltype(std::vprintf(" ",va
)), int>::value
), "");