Improve diagnostic handling: Add [-Wfoo] and -Werror-foo.
[cparser] / cparser.1
1 .\" Please adjust this date whenever revising the manpage.
2 .Dd December 21, 2008
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- Ns | Ns Cm error- Oc Ns Ar warn
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 .It Fl W Ns Oo Cm no- Ns | Ns Cm error- Oc Ns Ar warn
95 .\" TODO expand
96 Disable/enable a specific warning.
97 Every warning option has a corresponding
98 .Cm no-
99 switch to deactivate it and an
100 .Cm error-
101 switch to turn it into an error.
102 .It Fl Waddress
103 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.
104 .It Fl Waggregate-return
105 Warn about defining or calling a function, which returns a struct or union by value.
106 .It Fl Wall
107 Activate most warnings.
108 In particular these are
109 .Fl Waddress ,
110 .Fl Wattribute ,
111 .Fl Wchar-subscripts ,
112 .Fl Wcomment ,
113 .Fl Wempty-statement ,
114 .Fl Wformat ,
115 .Fl Wimplicit-function-declaration ,
116 .Fl Wimplicit-int ,
117 .Fl Winit-self ,
118 .Fl Wmain ,
119 .Fl Wnonnull ,
120 .Fl Wparentheses ,
121 .Fl Wpointer-arith ,
122 .Fl Wredundant-decls ,
123 .Fl Wreturn-type ,
124 .Fl Wshadow-local ,
125 .Fl Wsign-compare ,
126 .Fl Wstrict-prototypes ,
127 .Fl Wswitch-enum ,
128 .Fl Wunknown-pragmas ,
129 .Fl Wunreachable-code ,
130 .Fl Wunused-function ,
131 .Fl Wunused-label ,
132 .Fl Wunused-parameter ,
133 .Fl Wunused-value ,
134 .Fl Wunused-variable .
135 .It Fl Wcast-qual
136 Warn whenever a pointer cast removes qualifiers from the pointed-to type, e.g. casting a const char* to char*.
137 .It Fl Wchar-subscripts
138 Warn about using an expression of type char as array subscript, e.g. char\ c; arr[c].
139 .It Fl Wdeclaration-after-statement
140 Warn about mixing declarations and statements, which is not allowed prior to C99.
141 .It Fl Wdiv-by-zero
142 Warn about compile-time integer division by zero.
143 .It Fl Wempty-statement
144 Warn about empty statements, i.e. statements which only consist of a single
145 .Sq \&; .
146 Use {} as replacement to avoid this warning.
147 .It Fl Werror
148 Treat warnings as errors, i.e. do not continue after parsing when a warning is encountered.
149 .It Fl Wextra
150 (Alias
151 .Fl W Ns )
152 Activate some more warnings.
153 In particular these are
154 .Fl Wempty-statement ,
155 .Fl Wshadow ,
156 .Fl Wunused-parameter ,
157 .Fl Wunused-value .
158 .It Fl Wfatal-errors
159 Immediately abort compilation when encountering an error.
160 .It Fl Wformat
161 Check format strings of char and wchar_t functions.
162 .It Fl Wimplicit
163 Activate
164 .Fl Wimplicit-function-declaration ,
165 .Fl Wimplicit-int .
166 .It Fl Wimplicit-function-declaration
167 Warn about calling a function without a prior declaration.
168 .It Fl Wimplicit-int
169 Warn about declarations whose declaration specifiers do not include a type specifier.
170 .It Fl Winit-self
171 Warn about uninitialized variables which are initialized with themselves.
172 .It Fl Wlong-long
173 Warn if the type
174 .Sq long long
175 is used.
176 .It Fl Wmain
177 Warn if the type of
178 .Sq main
179 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**).
180 .It Fl Wmissing-declarations
181 Warn if a non-static function or a global variable without a storage class is defined without a prior declaration.
182 This is typically a sign of a missing #include or that the object should be static.
183 .It Fl Wmissing-noreturn
184 Warn about functions, which are candidates for the attribute
185 .Sq noreturn .
186 .It Fl Wmissing-prototypes
187 Warn if a global function is defined without a previous prototype declaration.
188 .It Fl Wmultichar
189 Warn if a multicharacter constant
190 .Pf ( Sq FOOF )
191 is used.
192 .It Fl Wnested-externs
193 Warn if an
194 .Sq extern
195 declaration is encountered within a function.
196 .It Fl Wparentheses
197 Warn if parentheses are omitted in certain contexts.
198 Warn if an assignment is used as condition, e.g. if\ (x\ =\ 23).
199 Warn if && without parentheses is used within ||, e.g. if\ (x\ ||\ y\ &&\ z).
200 Warn if it there may be confusion which
201 .Sq if Ns
202 -statement an
203 .Sq else Ns
204 -branch belongs to, e.g. if\ (x)\ if\ (y)\ {}\ else\ {}.
205 Warn if cascaded comparisons appear which do not have their mathematical meaning, e.g. if\ (23\ <=\ x\ <\ 42).
206 Warn if + or - is used as operand of << or >>, e.g. x\ +\ y\ <<\ z.
207 .It Fl Wredundant-decls
208 Warn about redundant declarations, i.e. multiple declarations of the same object or static forward declarations which have no use before their definition.
209 .It Fl Wshadow
210 Warn when a new declaration shadows another declaration with the same name in an outer scope.
211 .It Fl Wshadow-local
212 Like
213 .Fl Wshadow ,
214 but only warn if the shadowed declaration is not global, e.g. a local variable shadows a parameter or another local variable.
215 .It Fl Wunreachable-code
216 Warn when the compiler determines that a statement (or in some cases a part thereof) will never be executed.
217 .It Fl Wunused
218 Activate
219 .Fl Wunused-function ,
220 .Fl Wunused-label ,
221 .Fl Wunused-parameter ,
222 .Fl Wunused-value ,
223 .Fl Wunused-variable .
224 .It Fl Wunused-parameter
225 Warn when a parameter is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
226 .It Fl Wunused-variable
227 Warn when a variable is never used or only ever read to calculate its own new value, e.g. x\ =\ x\ +\ 1.
228 .It Fl w
229 Suppress all warnings.
230 .It Fl I Ar dir
231 Add the directory
232 .Ar dir
233 to the paths to be searched for include files.
234 .It Fl L Ar dir
235 Add the directory
236 .Ar dir
237 to the paths to be searched for libraries.
238 .It Fl D Ns Ar macro
239 Define the preprocessor macro
240 .Ar macro
241 which will expand to 1.
242 .It Fl D Ns Ar macro=defn
243 Define the preprocessor macro
244 .Ar macro
245 and set its expanded value to
246 .Ar defn .
247 .It Fl U Ns Ar macro
248 Undefine the preprocessor macro
249 .Ar macro .
250 .It Fl f Ar option
251 Set a frontend or optimizer option.
252 Use
253 .Fl fhelp
254 to get a list of supported optimizer options.
255 .It Fl finput-charset= Ns Ar encoding
256 Select the encoding of the input.
257 Supported values are
258 .Cm ISO_8859-1:1987
259 (aliases
260 .Cm CP819 ,
261 .Cm IBM819 ,
262 .Cm ISO-8859-1 ,
263 .Cm ISO8859-1 ,
264 .Cm ISO_8859-1 ,
265 .Cm csISOLatin1 ,
266 .Cm iso-ir-100 ,
267 .Cm l1
268 and
269 .Cm latin1 Ns
270 ),
271 .Cm ISO-8859-15
272 (aliases
273 .Cm ISO8859-15 ,
274 .Cm ISO_8859-15
275 and
276 .Cm Latin-9 Ns
277 ),
278 .Cm windows-1252
279 (alias
280 .Cm cp1252 Ns
281 ) and
282 .Cm UTF-8
283 (default).
284 Case is ignored.
285 .It Fl f Ns Oo Cm no- Oc Ns Cm show-column
286 Show the column number in diagnostic messages.
287 .It Fl fsigned-char
288 Define
289 .Sq char
290 to have the same range, representation and behaviour as
291 .Sq signed char .
292 .It Fl funsigned-char
293 Define
294 .Sq char
295 to have the same range, representation and behaviour as
296 .Sq unsigned char .
297 .It Fl b Ar option
298 Set a backend option.
299 Use
300 .Fl bhelp
301 to get a list of supported options.
302 .It Fl l Ar library
303 Link with the specified library.
304 .It Fl o Ar outfile
305 Specify the output filename.
306 This is only valid when using a single input filename.
307 .Fl
308 as filename uses stdout for output.
309 .It Fl x Ar language
310 Overwrite the language auto-detection for the following filenames by the
311 specified
312 .Ar language .
313 Supported values are:
314 .Bl -tag -compact -width "assembler-with-cpp"
315 .It Cm assembler
316 Assembler file
317 .It Cm assembler-with-cpp
318 Assembler file, which needs to be preprocessed
319 .It Cm c
320 .It Cm c-header
321 C file
322 .It Cm c++
323 .It Cm c++-header
324 C++ file
325 .It Cm none
326 Revert to auto-detection
327 .El
328 .It Fl Wl, Ns Ar option
329 Pass
330 .Ar option
331 to the linker.
332 .It Fl Wp, Ns Ar option
333 Pass
334 .Ar option
335 to the preprocessor.
336 .El
337 .Sh SEE ALSO
338 .Xr gcc 1 ,
339 http://www.libfirm.org/
340 .Sh BUGS
341 Probably many - if you hit one, please report it.
342 .Pp
343 .Nm
344 needs to support more switches for better GCC compatibility.
345 .Pp
346 This manual page is incomplete.
347 .Sh AUTHORS
348 .An -nosplit
349 .Nm
350 was written by
351 .An Matthias Braun
352 .Aq matze@braunis.de ,
353 .An Christoph Mallon
354 .Aq christoph.mallon@gmx.de
355 and
356 .An Michael Beck .