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