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