stdio_h.pass.cpp
5.54 KB
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
169
170
//===----------------------------------------------------------------------===//
//
// 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 <stdio.h>
#include <stdio.h>
#include <type_traits>
#include "test_macros.h"
#ifdef getc
#error getc is defined
#endif
#ifdef putc
#error putc is defined
#endif
#ifdef clearerr
#error clearerr is defined
#endif
#ifdef feof
#error feof is defined
#endif
#ifdef ferror
#error ferror is defined
#endif
#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(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic ignored "-Wformat-zero-length"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam
#endif
int main(int, char**)
{
FILE* fp = 0;
fpos_t fpos = fpos_t();
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), "");
static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
static_assert((std::is_same<decltype(getchar()), int>::value), "");
#if TEST_STD_VER < 14
static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
#endif
static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
static_assert((std::is_same<decltype(puts("")), int>::value), "");
static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
static_assert((std::is_same<decltype(fwrite((const void*)arr,1,0,fp)), size_t>::value), "");
static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
static_assert((std::is_same<decltype(perror("")), void>::value), "");
return 0;
}