]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/depr/depr.c.headers/stdio_h.pass.cpp
Vendor import of libc++ trunk r300422:
[FreeBSD/FreeBSD.git] / test / std / depr / depr.c.headers / stdio_h.pass.cpp
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 <stdio.h>
11
12 #include <stdio.h>
13 #include <type_traits>
14 #include "test_macros.h"
15
16 #ifdef getc
17 #error getc is defined
18 #endif
19
20 #ifdef putc
21 #error putc is defined
22 #endif
23
24 #ifdef clearerr
25 #error clearerr is defined
26 #endif
27
28 #ifdef feof
29 #error feof is defined
30 #endif
31
32 #ifdef ferror
33 #error ferror is defined
34 #endif
35
36 #ifndef BUFSIZ
37 #error BUFSIZ not defined
38 #endif
39
40 #ifndef EOF
41 #error EOF not defined
42 #endif
43
44 #ifndef FILENAME_MAX
45 #error FILENAME_MAX not defined
46 #endif
47
48 #ifndef FOPEN_MAX
49 #error FOPEN_MAX not defined
50 #endif
51
52 #ifndef L_tmpnam
53 #error L_tmpnam not defined
54 #endif
55
56 #ifndef NULL
57 #error NULL not defined
58 #endif
59
60 #ifndef SEEK_CUR
61 #error SEEK_CUR not defined
62 #endif
63
64 #ifndef SEEK_END
65 #error SEEK_END not defined
66 #endif
67
68 #ifndef SEEK_SET
69 #error SEEK_SET not defined
70 #endif
71
72 #ifndef TMP_MAX
73 #error TMP_MAX not defined
74 #endif
75
76 #ifndef _IOFBF
77 #error _IOFBF not defined
78 #endif
79
80 #ifndef _IOLBF
81 #error _IOLBF not defined
82 #endif
83
84 #ifndef _IONBF
85 #error _IONBF not defined
86 #endif
87
88 #ifndef stderr
89 #error stderr not defined
90 #endif
91
92 #ifndef stdin
93 #error stdin not defined
94 #endif
95
96 #ifndef stdout
97 #error stdout not defined
98 #endif
99
100 #include <cstdarg>
101
102 #if defined(__GNUC__) || defined(__clang__)
103 #pragma GCC diagnostic ignored "-Wformat-zero-length"
104 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam
105 #endif
106
107 int main()
108 {
109     FILE* fp = 0;
110     fpos_t fpos = fpos_t();
111     size_t s = 0;
112     char* cp = 0;
113     char arr[] = {'a', 'b'};
114     va_list va;
115     ((void)fp); // Prevent unused warning
116     ((void)fpos); // Prevent unused warning
117     ((void)s); // Prevent unused warning
118     ((void)cp); // Prevent unused warning
119     ((void)arr); // Prevent unused warning
120     ((void)va); // Prevent unused warning
121     static_assert((std::is_same<decltype(remove("")), int>::value), "");
122     static_assert((std::is_same<decltype(rename("","")), int>::value), "");
123     static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), "");
124     static_assert((std::is_same<decltype(tmpnam(cp)), char*>::value), "");
125     static_assert((std::is_same<decltype(fclose(fp)), int>::value), "");
126     static_assert((std::is_same<decltype(fflush(fp)), int>::value), "");
127     static_assert((std::is_same<decltype(fopen("", "")), FILE*>::value), "");
128     static_assert((std::is_same<decltype(freopen("", "", fp)), FILE*>::value), "");
129     static_assert((std::is_same<decltype(setbuf(fp,cp)), void>::value), "");
130     static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
131     static_assert((std::is_same<decltype(fprintf(fp," ")), int>::value), "");
132     static_assert((std::is_same<decltype(fscanf(fp,"")), int>::value), "");
133     static_assert((std::is_same<decltype(printf("\n")), int>::value), "");
134     static_assert((std::is_same<decltype(scanf("\n")), int>::value), "");
135     static_assert((std::is_same<decltype(snprintf(cp,0,"p")), int>::value), "");
136     static_assert((std::is_same<decltype(sprintf(cp," ")), int>::value), "");
137     static_assert((std::is_same<decltype(sscanf("","")), int>::value), "");
138     static_assert((std::is_same<decltype(vfprintf(fp,"",va)), int>::value), "");
139     static_assert((std::is_same<decltype(vfscanf(fp,"",va)), int>::value), "");
140     static_assert((std::is_same<decltype(vprintf(" ",va)), int>::value), "");
141     static_assert((std::is_same<decltype(vscanf("",va)), int>::value), "");
142     static_assert((std::is_same<decltype(vsnprintf(cp,0," ",va)), int>::value), "");
143     static_assert((std::is_same<decltype(vsprintf(cp," ",va)), int>::value), "");
144     static_assert((std::is_same<decltype(vsscanf("","",va)), int>::value), "");
145     static_assert((std::is_same<decltype(fgetc(fp)), int>::value), "");
146     static_assert((std::is_same<decltype(fgets(cp,0,fp)), char*>::value), "");
147     static_assert((std::is_same<decltype(fputc(0,fp)), int>::value), "");
148     static_assert((std::is_same<decltype(fputs("",fp)), int>::value), "");
149     static_assert((std::is_same<decltype(getc(fp)), int>::value), "");
150     static_assert((std::is_same<decltype(getchar()), int>::value), "");
151 #if TEST_STD_VER < 14
152     static_assert((std::is_same<decltype(gets(cp)), char*>::value), "");
153 #endif
154     static_assert((std::is_same<decltype(putc(0,fp)), int>::value), "");
155     static_assert((std::is_same<decltype(putchar(0)), int>::value), "");
156     static_assert((std::is_same<decltype(puts("")), int>::value), "");
157     static_assert((std::is_same<decltype(ungetc(0,fp)), int>::value), "");
158     static_assert((std::is_same<decltype(fread((void*)0,0,0,fp)), size_t>::value), "");
159     static_assert((std::is_same<decltype(fwrite((const void*)arr,1,0,fp)), size_t>::value), "");
160     static_assert((std::is_same<decltype(fgetpos(fp, &fpos)), int>::value), "");
161     static_assert((std::is_same<decltype(fseek(fp, 0,0)), int>::value), "");
162     static_assert((std::is_same<decltype(fsetpos(fp, &fpos)), int>::value), "");
163     static_assert((std::is_same<decltype(ftell(fp)), long>::value), "");
164     static_assert((std::is_same<decltype(rewind(fp)), void>::value), "");
165     static_assert((std::is_same<decltype(clearerr(fp)), void>::value), "");
166     static_assert((std::is_same<decltype(feof(fp)), int>::value), "");
167     static_assert((std::is_same<decltype(ferror(fp)), int>::value), "");
168     static_assert((std::is_same<decltype(perror("")), void>::value), "");
169 }