Make warning switch parsing compatible to GCC: -W[no-][error=]warning.
[cparser] / cparser.1
1 .\" Please adjust this date whenever revising the manpage.
2 .Dd June 21, 2011
3 .Dt CPARSER 1
4 .Sh NAME
5 .Nm cparser
6 .Nd C compiler
7 .Sh SYNOPSIS
8 .Nm
9 .Op Fl c | S | E | -print-ast
10 .Op Fl -print-implicit-cast
11 .Op Fl -print-parenthesis
12 .Op Fl std= Ns Ar standard
13 .Op Fl - Ns Oo Cm no- Oc Ns Cm gcc
14 .Op Fl - Ns Oo Cm no- Oc Ns Cm ms
15 .Op Fl g
16 .Op Fl O Ns Ar level
17 .Op Fl W Ns Oo Cm no- Oc Ns Oo Cm error= Oc Ns Ar warning
18 .Op Fl w
19 .Op Fl I Ar dir
20 .Op Fl L Ar dir
21 .Op Fl D Ns Ar macro Ns Op Ar =defn
22 .Op Fl U Ns Ar macro
23 .Op Fl f Ar option
24 .Op Fl finput-charset= Ns Ar encoding
25 .Op Fl b Ar option
26 .Op Fl l Ar library
27 .Op Fl o Ar outfile
28 .Op Fl x Ar language
29 .Op Fl Wl, Ns Ar option
30 .Op Fl Wp, Ns Ar option
31 .Ar
32 .Sh DESCRIPTION
33 .Nm
34 is a C compiler, which can parse C90 and C99 as well as many GCC and some MSC extensions.
35 It also provides many useful analyses for warnings and generates concise messages in case of error.
36 It uses libFIRM for optimization and code generation.
37 The compiler driver is largely compatible with GCC.
38 .Sh OPTIONS
39 .Bl -tag
40 .It Fl c
41 Compile the input files to object files.
42 The default output filename is the input filename with the extension replaced by .o.
43 .It Fl S
44 Compile the input files to assembler.
45 The default output filename is the input filename with the extension replaced by .s.
46 .It Fl E
47 Preprocess the input file only.
48 By default the result is output to stdout.
49 .It Fl -print-ast
50 Output the abstract syntax tree of the parsed input file as C again.
51 .It Fl -print-implicit-cast
52 When using
53 .Fl -print-ast ,
54 show casts, which are inserted by the semantic checks.
55 .It Fl -print-parenthesis
56 When using
57 .Fl -print-ast ,
58 show all expressions fully parenthesized.
59 .It Fl std= Ns Ar standard
60 Select the language standard.
61 Supported values are:
62 .Bl -tag -compact -width "iso9899:1990"
63 .It Cm c89
64 .It Cm iso9899:1990
65 ISO C90
66 .It Cm gnu89
67 ISO C90 with GCC extensions
68 .It Cm c99
69 .It Cm iso9899:1999
70 ISO C99
71 .It Cm gnu99
72 ISO C99 with GCC extensions
73 .It Cm c++98
74 ISO C++ 1998.
75 Not supported yet.
76 .It Cm gnu++98
77 ISO C++ 1998 with GCC extensions.
78 Not supported yet.
79 .El
80 .It Fl - Ns Oo Cm no- Oc Ns Cm gcc
81 Disable/enable GCC extensions.
82 This switch supersedes
83 .Fl std .
84 .It Fl - Ns Oo Cm no- Oc Ns Cm ms
85 Disable/enable MSC extensions.
86 .It Fl g
87 When compiling C files, add debug information in
88 .Tn stabs
89 format.
90 .It Fl O Ns Ar level
91 .\" TODO expand
92 Select the optimization level.
93 Sensible values are between 0 and 4, inclusive.
94 .\" TODO expand
95 .It Fl W Ns Ar warning
96 Enable the specified warning.
97 .It Fl Wno- Ns Ar warning
98 Disable the specified warning.
99 .It Fl Werror= Ns Ar warning
100 Enable the specified warning and turn it into an error.
101 .It Fl Wno-error= Ns Ar warning
102 Force the specified warning to only be a warning, even in the presence of
103 .Fl Werror .
104 This neither enables nor disables the warning itself.
105 .It Fl Waddress
106 Warn about suspicious use of addresses, like using the address of a function or variable as boolean condition or comparing with the address of a string literal.
107 .It Fl Waggregate-return
108 Warn about defining or calling a function, which returns a struct or union by value.
109 .It Fl Wall
110 Activate most warnings.
111 In particular these are
112 .Fl Waddress ,
113 .Fl Wattribute ,
114 .Fl Wchar-subscripts ,
115 .Fl Wcomment ,
116 .Fl Wempty-statement ,
117 .Fl Wformat ,
118 .Fl Wimplicit-function-declaration ,
119 .Fl Wimplicit-int ,
120 .Fl Winit-self ,
121 .Fl Wmain ,
122 .Fl Wnonnull ,
123 .Fl Wparentheses ,
124 .Fl Wpointer-arith ,
125 .Fl Wredundant-decls ,
126 .Fl Wreturn-type ,
127 .Fl Wshadow-local ,
128 .Fl Wsign-compare ,
129 .Fl Wstrict-prototypes ,
130 .Fl Wswitch-enum ,
131 .Fl Wunknown-pragmas ,
132 .Fl Wunreachable-code ,
133 .Fl Wunused-function ,
134 .Fl Wunused-label ,
135 .Fl Wunused-parameter ,
136 .Fl Wunused-value ,
137 .Fl Wunused-variable .
138 .It Fl Wcast-qual
139 Warn whenever a pointer cast removes qualifiers from the pointed-to type, e.g. casting a const char* to char*.
140 .It Fl Wchar-subscripts
141 Warn about using an expression of type char as array subscript, e.g. char\ c; arr[c].
142 .It Fl Wdeclaration-after-statement
143 Warn about mixing declarations and statements, which is not allowed prior to C99.
144 .It Fl Wdiv-by-zero
145 Warn about compile-time integer division by zero.
146 .It Fl Wempty-statement
147 Warn about empty statements, i.e. statements which only consist of a single
148 .Sq \&; .
149 Use {} as replacement to avoid this warning.
150 .It Fl Werror
151 Treat warnings as errors, i.e. do not continue after parsing when a warning is encountered.
152 .It Fl Wextra
153 (Alias
154 .Fl W Ns )
155 Activate some more warnings.
156 In particular these are
157 .Fl Wempty-statement ,
158 .Fl Wshadow ,
159 .Fl Wunused-parameter ,
160 .Fl Wunused-value .
161 .It Fl Wfatal-errors
162 Immediately abort compilation when encountering an error.
163 .It Fl Wformat
164 Check format strings of char and wchar_t functions.
165 .It Fl Wimplicit
166 Activate
167 .Fl Wimplicit-function-declaration ,
168 .Fl Wimplicit-int .
169 .It Fl Wimplicit-function-declaration
170 Warn about calling a function without a prior declaration.
171 .It Fl Wimplicit-int
172 Warn about declarations whose declaration specifiers do not include a type specifier.
173 .It Fl Winit-self
174 Warn about uninitialized variables which are initialized with themselves.
175 .It Fl Wlong-long
176 Warn if the type
177 .Sq long long
178 is used.
179 .It Fl Wmain
180 Warn if the type of
181 .Sq main
182 is suspicious, i.e. if it is not a non-static function declared as either int\ main(void), int\ main(int,\ char**) or, as an extension, int\ main(int,\ char**,\ char**).
183 .It Fl Wmissing-declarations
184 Warn if a non-static function or a global variable without a storage class is defined without a prior declaration.
185 This is typically a sign of a missing #include or that the object should be static.
186 .It Fl Wmissing-noreturn
187 Warn about functions, which are candidates for the attribute
188 .Sq noreturn .
189 .It Fl Wmissing-prototypes
190 Warn if a global function is defined without a previous prototype declaration.
191 .It Fl Wmultichar
192 Warn if a multicharacter constant
193 .Pf ( Sq FOOF )
194 is used.
195 .It Fl Wnested-externs
196 Warn if an
197 .Sq extern
198 declaration is encountered within a function.
199 .It Fl Wparentheses
200 Warn if parentheses are omitted in certain contexts.
201 Warn if an assignment is used as condition, e.g. if\ (x\ =\ 23).
202 Warn if && without parentheses is used within ||, e.g. if\ (x\ ||\ y\ &&\ z).
203 Warn if it there may be confusion which
204 .Sq if Ns
205 -statement an
206 .Sq else Ns
207 -branch belongs to, e.g. if\ (x)\ if\ (y)\ {}\ else\ {}.
208 Warn if cascaded comparisons appear which do not have their mathematical meaning, e.g. if\ (23\ <=\ x\ <\ 42).
209 Warn if + or - is used as operand of << or >>, e.g. x\ +\ y\ <<\ z.
210 .It Fl Wredundant-decls
211 Warn about redundant declarations, i.e. multiple declarations of the same object or static forward declarations which have no use before their definition.
212 .It Fl Wshadow
213 Warn when a new declaration shadows another declaration with the same name in an outer scope.
214 .It Fl Wshadow-local
215 Like
216 .Fl Wshadow ,
217 but only warn if the shadowed declaration is not global, e.g. a local variable shadows a parameter or another local variable.
218 .It Fl Wunreachable-code
219 Warn when the compiler determines that a statement (or in some cases a part thereof) will never be executed.
220 .It Fl Wunused
221 Activate
222 .Fl Wunused-function ,
223 .Fl Wunused-label ,
224 .Fl Wunused-parameter ,
225 .Fl Wunused-value ,
226 .Fl Wunused-variable .
227 .It Fl Wunused-parameter
228 Warn when a parameter is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
229 .It Fl Wunused-variable
230 Warn when a variable is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
231 .It Fl w
232 Suppress all warnings.
233 .It Fl I Ar dir
234 Add the directory
235 .Ar dir
236 to the paths to be searched for include files.
237 .It Fl L Ar dir
238 Add the directory
239 .Ar dir
240 to the paths to be searched for libraries.
241 .It Fl D Ns Ar macro
242 Define the preprocessor macro
243 .Ar macro
244 which will expand to 1.
245 .It Fl D Ns Ar macro=defn
246 Define the preprocessor macro
247 .Ar macro
248 and set its expanded value to
249 .Ar defn .
250 .It Fl U Ns Ar macro
251 Undefine the preprocessor macro
252 .Ar macro .
253 .It Fl f Ar option
254 Set a frontend or optimizer option.
255 Use
256 .Fl fhelp
257 to get a list of supported optimizer options.
258 .It Fl finput-charset= Ns Ar encoding
259 Select the encoding of the input.
260 Supported values are
261 .Cm ISO_8859-1:1987
262 (aliases
263 .Cm CP819 ,
264 .Cm IBM819 ,
265 .Cm ISO-8859-1 ,
266 .Cm ISO8859-1 ,
267 .Cm ISO_8859-1 ,
268 .Cm csISOLatin1 ,
269 .Cm iso-ir-100 ,
270 .Cm l1
271 and
272 .Cm latin1 Ns
273 ),
274 .Cm ISO-8859-15
275 (aliases
276 .Cm ISO8859-15 ,
277 .Cm ISO_8859-15
278 and
279 .Cm Latin-9 Ns
280 ),
281 .Cm windows-1252
282 (alias
283 .Cm cp1252 Ns
284 ) and
285 .Cm UTF-8
286 (default).
287 Case is ignored.
288 .It Fl f Ns Oo Cm no- Oc Ns Cm show-column
289 Show the column number in diagnostic messages.
290 .It Fl fsigned-char
291 Define
292 .Sq char
293 to have the same range, representation and behaviour as
294 .Sq signed char .
295 .It Fl funsigned-char
296 Define
297 .Sq char
298 to have the same range, representation and behaviour as
299 .Sq unsigned char .
300 .It Fl b Ar option
301 Set a backend option.
302 Use
303 .Fl bhelp
304 to get a list of supported options.
305 .It Fl l Ar library
306 Link with the specified library.
307 .It Fl o Ar outfile
308 Specify the output filename.
309 This is only valid when using a single input filename.
310 .Fl
311 as filename uses stdout for output.
312 .It Fl x Ar language
313 Overwrite the language auto-detection for the following filenames by the
314 specified
315 .Ar language .
316 Supported values are:
317 .Bl -tag -compact -width "assembler-with-cpp"
318 .It Cm assembler
319 Assembler file
320 .It Cm assembler-with-cpp
321 Assembler file, which needs to be preprocessed
322 .It Cm c
323 .It Cm c-header
324 C file
325 .It Cm c++
326 .It Cm c++-header
327 C++ file
328 .It Cm none
329 Revert to auto-detection
330 .El
331 .It Fl Wl, Ns Ar option
332 Pass
333 .Ar option
334 to the linker.
335 .It Fl Wp, Ns Ar option
336 Pass
337 .Ar option
338 to the preprocessor.
339 .El
340 .Sh SEE ALSO
341 .Xr gcc 1 ,
342 http://www.libfirm.org/
343 .Sh BUGS
344 Probably many - if you hit one, please report it.
345 .Pp
346 .Nm
347 needs to support more switches for better GCC compatibility.
348 .Pp
349 This manual page is incomplete.
350 .Sh AUTHORS
351 .An -nosplit
352 .Nm
353 was written by
354 .An Matthias Braun
355 .Aq matze@braunis.de ,
356 .An Christoph Mallon
357 .Aq christoph.mallon@gmx.de
358 and
359 .An Michael Beck .