]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/d/doc/invoking-gdc/warnings.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / d / doc / invoking-gdc / warnings.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. index:: options to control warnings, warning messages, messages, warning, suppressing warnings
7
8 .. _warnings:
9
10 Warnings
11 ********
12
13 Warnings are diagnostic messages that report constructions that
14 are not inherently erroneous but that are risky or suggest there
15 is likely to be a bug in the program. Unless :option:`-Werror` is
16 specified, they do not prevent compilation of the program.
17
18 .. option:: -Wall
19
20 .. index:: -Wall, -Wno-all
21
22 Turns on all warnings messages. Warnings are not a defined part of
23 the D language, and all constructs for which this may generate a
24 warning message are valid code.
25
26 .. option:: -Walloca
27
28 .. index:: -Walloca
29
30 This option warns on all uses of "alloca" in the source.
31
32 .. option:: -Walloca-larger-than=n
33
34 .. index:: -Walloca-larger-than, -Wno-alloca-larger-than
35
36 Warn on unbounded uses of alloca, and on bounded uses of alloca
37 whose bound can be larger than :samp:`{n}` bytes.
38 :option:`-Wno-alloca-larger-than` disables
39 :option:`-Walloca-larger-than` warning and is equivalent to
40 :option:`-Walloca-larger-than=SIZE_MAX` or larger.
41
42 .. option:: -Wcast-result
43
44 .. index:: -Wcast-result, -Wno-cast-result
45
46 Warn about casts that will produce a null or zero result. Currently
47 this is only done for casting between an imaginary and non-imaginary
48 data type, or casting between a D and C++ class.
49
50 .. option:: -Wno-deprecated
51
52 .. index:: -Wdeprecated, -Wno-deprecated
53
54 Do not warn about usage of deprecated features and symbols with
55 ``deprecated`` attributes.
56
57 .. option:: -Werror
58
59 .. index:: -Werror, -Wno-error
60
61 Turns all warnings into errors.
62
63 .. option:: -Wspeculative
64
65 .. index:: -Wspeculative, -Wno-speculative
66
67 List all error messages from speculative compiles, such as
68 ``__traits(compiles, ...)``. This option does not report
69 messages as warnings, and these messages therefore never become
70 errors when the :option:`-Werror` option is also used.
71
72 .. option:: -Wtemplates
73
74 .. index:: -Wtemplates, -Wno-templates
75
76 Warn when a template instantiation is encountered. Some coding
77 rules disallow templates, and this may be used to enforce that rule.
78
79 .. option:: -Wunknown-pragmas
80
81 .. index:: -Wunknown-pragmas, -Wno-unknown-pragmas
82
83 Warn when a ``pragma()`` is encountered that is not understood by
84 :command:`gdc`. This differs from :option:`-fignore-unknown-pragmas`
85 where a pragma that is part of the D language, but not implemented by
86 the compiler, won't get reported.
87
88 .. option:: -Wno-varargs
89
90 .. index:: Wvarargs, Wno-varargs
91
92 Do not warn upon questionable usage of the macros used to handle variable
93 arguments like ``va_start``.
94
95 .. option:: -fignore-unknown-pragmas
96
97 .. index:: -fignore-unknown-pragmas, -fno-ignore-unknown-pragmas
98
99 Turns off errors for unsupported pragmas.
100
101 .. option:: -fmax-errors=n
102
103 .. index:: -fmax-errors
104
105 Limits the maximum number of error messages to :samp:`{n}`, at which point
106 :command:`gdc` bails out rather than attempting to continue processing the
107 source code. If :samp:`{n}` is 0 (the default), there is no limit on the
108 number of error messages produced.
109
110 .. option:: -fsyntax-only
111
112 .. index:: -fsyntax-only, -fno-syntax-only
113
114 Check the code for syntax errors, but do not actually compile it. This
115 can be used in conjunction with :option:`-fdoc` or :option:`-H` to generate
116 files for each module present on the command-line, but no other output
117 file.
118
119 .. option:: -ftransition=id
120
121 .. index:: -ftransition
122
123 Report additional information about D language changes identified by
124 :samp:`{id}`. The following values are supported:
125
126 :samp:`all`
127 List information on all D language transitions.
128
129 :samp:`complex`
130 List all usages of complex or imaginary types.
131
132 :samp:`field`
133 List all non-mutable fields which occupy an object instance.
134
135 :samp:`in`
136 List all usages of ``in`` on parameter.
137
138 :samp:`nogc`
139 List all hidden GC allocations.
140
141 :samp:`templates`
142 List statistics on template instantiations.
143
144 :samp:`tls`
145 List all variables going into thread local storage.
146
147 :samp:`vmarkdown`
148 List instances of Markdown replacements in Ddoc.