You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

823 lines
35KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))</title>
  21. <meta name="description" content="Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))">
  22. <meta name="keywords" content="Diagnostic Message Formatting Options (Using the GNU Compiler Collection (GCC))">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
  30. <link href="Warning-Options.html#Warning-Options" rel="next" title="Warning Options">
  31. <link href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" rel="prev" title="Objective-C and Objective-C++ Dialect Options">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Diagnostic-Message-Formatting-Options"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Warning-Options.html#Warning-Options" accesskey="n" rel="next">Warning Options</a>, Previous: <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" accesskey="p" rel="prev">Objective-C and Objective-C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Options-to-Control-Diagnostic-Messages-Formatting"></a>
  68. <h3 class="section">3.7 Options to Control Diagnostic Messages Formatting</h3>
  69. <a name="index-options-to-control-diagnostics-formatting"></a>
  70. <a name="index-diagnostic-messages"></a>
  71. <a name="index-message-formatting"></a>
  72. <p>Traditionally, diagnostic messages have been formatted irrespective of
  73. the output device&rsquo;s aspect (e.g. its width, &hellip;). You can use the
  74. options described below
  75. to control the formatting algorithm for diagnostic messages,
  76. e.g. how many characters per line, how often source location
  77. information should be reported. Note that some language front ends may not
  78. honor these options.
  79. </p>
  80. <dl compact="compact">
  81. <dt><code>-fmessage-length=<var>n</var></code></dt>
  82. <dd><a name="index-fmessage_002dlength"></a>
  83. <p>Try to format error messages so that they fit on lines of about
  84. <var>n</var> characters. If <var>n</var> is zero, then no line-wrapping is
  85. done; each error message appears on a single line. This is the
  86. default for all front ends.
  87. </p>
  88. <p>Note - this option also affects the display of the &lsquo;<samp>#error</samp>&rsquo; and
  89. &lsquo;<samp>#warning</samp>&rsquo; pre-processor directives, and the &lsquo;<samp>deprecated</samp>&rsquo;
  90. function/type/variable attribute. It does not however affect the
  91. &lsquo;<samp>pragma GCC warning</samp>&rsquo; and &lsquo;<samp>pragma GCC error</samp>&rsquo; pragmas.
  92. </p>
  93. </dd>
  94. <dt><code>-fdiagnostics-show-location=once</code></dt>
  95. <dd><a name="index-fdiagnostics_002dshow_002dlocation"></a>
  96. <p>Only meaningful in line-wrapping mode. Instructs the diagnostic messages
  97. reporter to emit source location information <em>once</em>; that is, in
  98. case the message is too long to fit on a single physical line and has to
  99. be wrapped, the source location won&rsquo;t be emitted (as prefix) again,
  100. over and over, in subsequent continuation lines. This is the default
  101. behavior.
  102. </p>
  103. </dd>
  104. <dt><code>-fdiagnostics-show-location=every-line</code></dt>
  105. <dd><p>Only meaningful in line-wrapping mode. Instructs the diagnostic
  106. messages reporter to emit the same source location information (as
  107. prefix) for physical lines that result from the process of breaking
  108. a message which is too long to fit on a single line.
  109. </p>
  110. </dd>
  111. <dt><code>-fdiagnostics-color[=<var>WHEN</var>]</code></dt>
  112. <dt><code>-fno-diagnostics-color</code></dt>
  113. <dd><a name="index-fdiagnostics_002dcolor"></a>
  114. <a name="index-highlight_002c-color"></a>
  115. <a name="index-GCC_005fCOLORS-environment-variable"></a>
  116. <p>Use color in diagnostics. <var>WHEN</var> is &lsquo;<samp>never</samp>&rsquo;, &lsquo;<samp>always</samp>&rsquo;,
  117. or &lsquo;<samp>auto</samp>&rsquo;. The default depends on how the compiler has been configured,
  118. it can be any of the above <var>WHEN</var> options or also &lsquo;<samp>never</samp>&rsquo;
  119. if <code>GCC_COLORS</code> environment variable isn&rsquo;t present in the environment,
  120. and &lsquo;<samp>auto</samp>&rsquo; otherwise.
  121. &lsquo;<samp>auto</samp>&rsquo; makes GCC use color only when the standard error is a terminal,
  122. and when not executing in an emacs shell.
  123. The forms <samp>-fdiagnostics-color</samp> and <samp>-fno-diagnostics-color</samp> are
  124. aliases for <samp>-fdiagnostics-color=always</samp> and
  125. <samp>-fdiagnostics-color=never</samp>, respectively.
  126. </p>
  127. <p>The colors are defined by the environment variable <code>GCC_COLORS</code>.
  128. Its value is a colon-separated list of capabilities and Select Graphic
  129. Rendition (SGR) substrings. SGR commands are interpreted by the
  130. terminal or terminal emulator. (See the section in the documentation
  131. of your text terminal for permitted values and their meanings as
  132. character attributes.) These substring values are integers in decimal
  133. representation and can be concatenated with semicolons.
  134. Common values to concatenate include
  135. &lsquo;<samp>1</samp>&rsquo; for bold,
  136. &lsquo;<samp>4</samp>&rsquo; for underline,
  137. &lsquo;<samp>5</samp>&rsquo; for blink,
  138. &lsquo;<samp>7</samp>&rsquo; for inverse,
  139. &lsquo;<samp>39</samp>&rsquo; for default foreground color,
  140. &lsquo;<samp>30</samp>&rsquo; to &lsquo;<samp>37</samp>&rsquo; for foreground colors,
  141. &lsquo;<samp>90</samp>&rsquo; to &lsquo;<samp>97</samp>&rsquo; for 16-color mode foreground colors,
  142. &lsquo;<samp>38;5;0</samp>&rsquo; to &lsquo;<samp>38;5;255</samp>&rsquo;
  143. for 88-color and 256-color modes foreground colors,
  144. &lsquo;<samp>49</samp>&rsquo; for default background color,
  145. &lsquo;<samp>40</samp>&rsquo; to &lsquo;<samp>47</samp>&rsquo; for background colors,
  146. &lsquo;<samp>100</samp>&rsquo; to &lsquo;<samp>107</samp>&rsquo; for 16-color mode background colors,
  147. and &lsquo;<samp>48;5;0</samp>&rsquo; to &lsquo;<samp>48;5;255</samp>&rsquo;
  148. for 88-color and 256-color modes background colors.
  149. </p>
  150. <p>The default <code>GCC_COLORS</code> is
  151. </p><div class="smallexample">
  152. <pre class="smallexample">error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
  153. quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
  154. diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
  155. type-diff=01;32
  156. </pre></div>
  157. <p>where &lsquo;<samp>01;31</samp>&rsquo; is bold red, &lsquo;<samp>01;35</samp>&rsquo; is bold magenta,
  158. &lsquo;<samp>01;36</samp>&rsquo; is bold cyan, &lsquo;<samp>32</samp>&rsquo; is green, &lsquo;<samp>34</samp>&rsquo; is blue,
  159. &lsquo;<samp>01</samp>&rsquo; is bold, and &lsquo;<samp>31</samp>&rsquo; is red.
  160. Setting <code>GCC_COLORS</code> to the empty string disables colors.
  161. Supported capabilities are as follows.
  162. </p>
  163. <dl compact="compact">
  164. <dt><code>error=</code></dt>
  165. <dd><a name="index-error-GCC_005fCOLORS-capability"></a>
  166. <p>SGR substring for error: markers.
  167. </p>
  168. </dd>
  169. <dt><code>warning=</code></dt>
  170. <dd><a name="index-warning-GCC_005fCOLORS-capability"></a>
  171. <p>SGR substring for warning: markers.
  172. </p>
  173. </dd>
  174. <dt><code>note=</code></dt>
  175. <dd><a name="index-note-GCC_005fCOLORS-capability"></a>
  176. <p>SGR substring for note: markers.
  177. </p>
  178. </dd>
  179. <dt><code>path=</code></dt>
  180. <dd><a name="index-path-GCC_005fCOLORS-capability"></a>
  181. <p>SGR substring for colorizing paths of control-flow events as printed
  182. via <samp>-fdiagnostics-path-format=</samp>, such as the identifiers of
  183. individual events and lines indicating interprocedural calls and returns.
  184. </p>
  185. </dd>
  186. <dt><code>range1=</code></dt>
  187. <dd><a name="index-range1-GCC_005fCOLORS-capability"></a>
  188. <p>SGR substring for first additional range.
  189. </p>
  190. </dd>
  191. <dt><code>range2=</code></dt>
  192. <dd><a name="index-range2-GCC_005fCOLORS-capability"></a>
  193. <p>SGR substring for second additional range.
  194. </p>
  195. </dd>
  196. <dt><code>locus=</code></dt>
  197. <dd><a name="index-locus-GCC_005fCOLORS-capability"></a>
  198. <p>SGR substring for location information, &lsquo;<samp>file:line</samp>&rsquo; or
  199. &lsquo;<samp>file:line:column</samp>&rsquo; etc.
  200. </p>
  201. </dd>
  202. <dt><code>quote=</code></dt>
  203. <dd><a name="index-quote-GCC_005fCOLORS-capability"></a>
  204. <p>SGR substring for information printed within quotes.
  205. </p>
  206. </dd>
  207. <dt><code>fixit-insert=</code></dt>
  208. <dd><a name="index-fixit_002dinsert-GCC_005fCOLORS-capability"></a>
  209. <p>SGR substring for fix-it hints suggesting text to
  210. be inserted or replaced.
  211. </p>
  212. </dd>
  213. <dt><code>fixit-delete=</code></dt>
  214. <dd><a name="index-fixit_002ddelete-GCC_005fCOLORS-capability"></a>
  215. <p>SGR substring for fix-it hints suggesting text to
  216. be deleted.
  217. </p>
  218. </dd>
  219. <dt><code>diff-filename=</code></dt>
  220. <dd><a name="index-diff_002dfilename-GCC_005fCOLORS-capability"></a>
  221. <p>SGR substring for filename headers within generated patches.
  222. </p>
  223. </dd>
  224. <dt><code>diff-hunk=</code></dt>
  225. <dd><a name="index-diff_002dhunk-GCC_005fCOLORS-capability"></a>
  226. <p>SGR substring for the starts of hunks within generated patches.
  227. </p>
  228. </dd>
  229. <dt><code>diff-delete=</code></dt>
  230. <dd><a name="index-diff_002ddelete-GCC_005fCOLORS-capability"></a>
  231. <p>SGR substring for deleted lines within generated patches.
  232. </p>
  233. </dd>
  234. <dt><code>diff-insert=</code></dt>
  235. <dd><a name="index-diff_002dinsert-GCC_005fCOLORS-capability"></a>
  236. <p>SGR substring for inserted lines within generated patches.
  237. </p>
  238. </dd>
  239. <dt><code>type-diff=</code></dt>
  240. <dd><a name="index-type_002ddiff-GCC_005fCOLORS-capability"></a>
  241. <p>SGR substring for highlighting mismatching types within template
  242. arguments in the C++ frontend.
  243. </p></dd>
  244. </dl>
  245. </dd>
  246. <dt><code>-fdiagnostics-urls[=<var>WHEN</var>]</code></dt>
  247. <dd><a name="index-fdiagnostics_002durls"></a>
  248. <a name="index-urls"></a>
  249. <a name="index-GCC_005fURLS-environment-variable"></a>
  250. <a name="index-TERM_005fURLS-environment-variable"></a>
  251. <p>Use escape sequences to embed URLs in diagnostics. For example, when
  252. <samp>-fdiagnostics-show-option</samp> emits text showing the command-line
  253. option controlling a diagnostic, embed a URL for documentation of that
  254. option.
  255. </p>
  256. <p><var>WHEN</var> is &lsquo;<samp>never</samp>&rsquo;, &lsquo;<samp>always</samp>&rsquo;, or &lsquo;<samp>auto</samp>&rsquo;.
  257. &lsquo;<samp>auto</samp>&rsquo; makes GCC use URL escape sequences only when the standard error
  258. is a terminal, and when not executing in an emacs shell or any graphical
  259. terminal which is known to be incompatible with this feature, see below.
  260. </p>
  261. <p>The default depends on how the compiler has been configured.
  262. It can be any of the above <var>WHEN</var> options.
  263. </p>
  264. <p>GCC can also be configured (via the
  265. <samp>--with-diagnostics-urls=auto-if-env</samp> configure-time option)
  266. so that the default is affected by environment variables.
  267. Under such a configuration, GCC defaults to using &lsquo;<samp>auto</samp>&rsquo;
  268. if either <code>GCC_URLS</code> or <code>TERM_URLS</code> environment variables are
  269. present and non-empty in the environment of the compiler, or &lsquo;<samp>never</samp>&rsquo;
  270. if neither are.
  271. </p>
  272. <p>However, even with <samp>-fdiagnostics-urls=always</samp> the behavior is
  273. dependent on those environment variables:
  274. If <code>GCC_URLS</code> is set to empty or &lsquo;<samp>no</samp>&rsquo;, do not embed URLs in
  275. diagnostics. If set to &lsquo;<samp>st</samp>&rsquo;, URLs use ST escape sequences.
  276. If set to &lsquo;<samp>bel</samp>&rsquo;, the default, URLs use BEL escape sequences.
  277. Any other non-empty value enables the feature.
  278. If <code>GCC_URLS</code> is not set, use <code>TERM_URLS</code> as a fallback.
  279. Note: ST is an ANSI escape sequence, string terminator &lsquo;<samp>ESC \</samp>&rsquo;,
  280. BEL is an ASCII character, CTRL-G that usually sounds like a beep.
  281. </p>
  282. <p>At this time GCC tries to detect also a few terminals that are known to
  283. not implement the URL feature, and have bugs or at least had bugs in
  284. some versions that are still in use, where the URL escapes are likely
  285. to misbehave, i.e. print garbage on the screen.
  286. That list is currently xfce4-terminal, certain known to be buggy
  287. gnome-terminal versions, the linux console, and mingw.
  288. This check can be skipped with the <samp>-fdiagnostics-urls=always</samp>.
  289. </p>
  290. </dd>
  291. <dt><code>-fno-diagnostics-show-option</code></dt>
  292. <dd><a name="index-fno_002ddiagnostics_002dshow_002doption"></a>
  293. <a name="index-fdiagnostics_002dshow_002doption"></a>
  294. <p>By default, each diagnostic emitted includes text indicating the
  295. command-line option that directly controls the diagnostic (if such an
  296. option is known to the diagnostic machinery). Specifying the
  297. <samp>-fno-diagnostics-show-option</samp> flag suppresses that behavior.
  298. </p>
  299. </dd>
  300. <dt><code>-fno-diagnostics-show-caret</code></dt>
  301. <dd><a name="index-fno_002ddiagnostics_002dshow_002dcaret"></a>
  302. <a name="index-fdiagnostics_002dshow_002dcaret"></a>
  303. <p>By default, each diagnostic emitted includes the original source line
  304. and a caret &lsquo;<samp>^</samp>&rsquo; indicating the column. This option suppresses this
  305. information. The source line is truncated to <var>n</var> characters, if
  306. the <samp>-fmessage-length=n</samp> option is given. When the output is done
  307. to the terminal, the width is limited to the width given by the
  308. <code>COLUMNS</code> environment variable or, if not set, to the terminal width.
  309. </p>
  310. </dd>
  311. <dt><code>-fno-diagnostics-show-labels</code></dt>
  312. <dd><a name="index-fno_002ddiagnostics_002dshow_002dlabels"></a>
  313. <a name="index-fdiagnostics_002dshow_002dlabels"></a>
  314. <p>By default, when printing source code (via <samp>-fdiagnostics-show-caret</samp>),
  315. diagnostics can label ranges of source code with pertinent information, such
  316. as the types of expressions:
  317. </p>
  318. <div class="smallexample">
  319. <pre class="smallexample"> printf (&quot;foo %s bar&quot;, long_i + long_j);
  320. ~^ ~~~~~~~~~~~~~~~
  321. | |
  322. char * long int
  323. </pre></div>
  324. <p>This option suppresses the printing of these labels (in the example above,
  325. the vertical bars and the &ldquo;char *&rdquo; and &ldquo;long int&rdquo; text).
  326. </p>
  327. </dd>
  328. <dt><code>-fno-diagnostics-show-cwe</code></dt>
  329. <dd><a name="index-fno_002ddiagnostics_002dshow_002dcwe"></a>
  330. <a name="index-fdiagnostics_002dshow_002dcwe"></a>
  331. <p>Diagnostic messages can optionally have an associated
  332. <a href="https://cwe.mitre.org/index.html">CWE</a> identifier.
  333. GCC itself only provides such metadata for some of the <samp>-fanalyzer</samp>
  334. diagnostics. GCC plugins may also provide diagnostics with such metadata.
  335. By default, if this information is present, it will be printed with
  336. the diagnostic. This option suppresses the printing of this metadata.
  337. </p>
  338. </dd>
  339. <dt><code>-fno-diagnostics-show-line-numbers</code></dt>
  340. <dd><a name="index-fno_002ddiagnostics_002dshow_002dline_002dnumbers"></a>
  341. <a name="index-fdiagnostics_002dshow_002dline_002dnumbers"></a>
  342. <p>By default, when printing source code (via <samp>-fdiagnostics-show-caret</samp>),
  343. a left margin is printed, showing line numbers. This option suppresses this
  344. left margin.
  345. </p>
  346. </dd>
  347. <dt><code>-fdiagnostics-minimum-margin-width=<var>width</var></code></dt>
  348. <dd><a name="index-fdiagnostics_002dminimum_002dmargin_002dwidth"></a>
  349. <p>This option controls the minimum width of the left margin printed by
  350. <samp>-fdiagnostics-show-line-numbers</samp>. It defaults to 6.
  351. </p>
  352. </dd>
  353. <dt><code>-fdiagnostics-parseable-fixits</code></dt>
  354. <dd><a name="index-fdiagnostics_002dparseable_002dfixits"></a>
  355. <p>Emit fix-it hints in a machine-parseable format, suitable for consumption
  356. by IDEs. For each fix-it, a line will be printed after the relevant
  357. diagnostic, starting with the string &ldquo;fix-it:&rdquo;. For example:
  358. </p>
  359. <div class="smallexample">
  360. <pre class="smallexample">fix-it:&quot;test.c&quot;:{45:3-45:21}:&quot;gtk_widget_show_all&quot;
  361. </pre></div>
  362. <p>The location is expressed as a half-open range, expressed as a count of
  363. bytes, starting at byte 1 for the initial column. In the above example,
  364. bytes 3 through 20 of line 45 of &ldquo;test.c&rdquo; are to be replaced with the
  365. given string:
  366. </p>
  367. <div class="smallexample">
  368. <pre class="smallexample">00000000011111111112222222222
  369. 12345678901234567890123456789
  370. gtk_widget_showall (dlg);
  371. ^^^^^^^^^^^^^^^^^^
  372. gtk_widget_show_all
  373. </pre></div>
  374. <p>The filename and replacement string escape backslash as &ldquo;\\&quot;, tab as &ldquo;\t&rdquo;,
  375. newline as &ldquo;\n&rdquo;, double quotes as &ldquo;\&quot;&rdquo;, non-printable characters as octal
  376. (e.g. vertical tab as &ldquo;\013&rdquo;).
  377. </p>
  378. <p>An empty replacement string indicates that the given range is to be removed.
  379. An empty range (e.g. &ldquo;45:3-45:3&rdquo;) indicates that the string is to
  380. be inserted at the given position.
  381. </p>
  382. </dd>
  383. <dt><code>-fdiagnostics-generate-patch</code></dt>
  384. <dd><a name="index-fdiagnostics_002dgenerate_002dpatch"></a>
  385. <p>Print fix-it hints to stderr in unified diff format, after any diagnostics
  386. are printed. For example:
  387. </p>
  388. <div class="smallexample">
  389. <pre class="smallexample">--- test.c
  390. +++ test.c
  391. @ -42,5 +42,5 @
  392. void show_cb(GtkDialog *dlg)
  393. {
  394. - gtk_widget_showall(dlg);
  395. + gtk_widget_show_all(dlg);
  396. }
  397. </pre></div>
  398. <p>The diff may or may not be colorized, following the same rules
  399. as for diagnostics (see <samp>-fdiagnostics-color</samp>).
  400. </p>
  401. </dd>
  402. <dt><code>-fdiagnostics-show-template-tree</code></dt>
  403. <dd><a name="index-fdiagnostics_002dshow_002dtemplate_002dtree"></a>
  404. <p>In the C++ frontend, when printing diagnostics showing mismatching
  405. template types, such as:
  406. </p>
  407. <div class="smallexample">
  408. <pre class="smallexample"> could not convert 'std::map&lt;int, std::vector&lt;double&gt; &gt;()'
  409. from 'map&lt;[...],vector&lt;double&gt;&gt;' to 'map&lt;[...],vector&lt;float&gt;&gt;
  410. </pre></div>
  411. <p>the <samp>-fdiagnostics-show-template-tree</samp> flag enables printing a
  412. tree-like structure showing the common and differing parts of the types,
  413. such as:
  414. </p>
  415. <div class="smallexample">
  416. <pre class="smallexample"> map&lt;
  417. [...],
  418. vector&lt;
  419. [double != float]&gt;&gt;
  420. </pre></div>
  421. <p>The parts that differ are highlighted with color (&ldquo;double&rdquo; and
  422. &ldquo;float&rdquo; in this case).
  423. </p>
  424. </dd>
  425. <dt><code>-fno-elide-type</code></dt>
  426. <dd><a name="index-fno_002delide_002dtype"></a>
  427. <a name="index-felide_002dtype"></a>
  428. <p>By default when the C++ frontend prints diagnostics showing mismatching
  429. template types, common parts of the types are printed as &ldquo;[...]&rdquo; to
  430. simplify the error message. For example:
  431. </p>
  432. <div class="smallexample">
  433. <pre class="smallexample"> could not convert 'std::map&lt;int, std::vector&lt;double&gt; &gt;()'
  434. from 'map&lt;[...],vector&lt;double&gt;&gt;' to 'map&lt;[...],vector&lt;float&gt;&gt;
  435. </pre></div>
  436. <p>Specifying the <samp>-fno-elide-type</samp> flag suppresses that behavior.
  437. This flag also affects the output of the
  438. <samp>-fdiagnostics-show-template-tree</samp> flag.
  439. </p>
  440. </dd>
  441. <dt><code>-fdiagnostics-path-format=<var>KIND</var></code></dt>
  442. <dd><a name="index-fdiagnostics_002dpath_002dformat"></a>
  443. <p>Specify how to print paths of control-flow events for diagnostics that
  444. have such a path associated with them.
  445. </p>
  446. <p><var>KIND</var> is &lsquo;<samp>none</samp>&rsquo;, &lsquo;<samp>separate-events</samp>&rsquo;, or &lsquo;<samp>inline-events</samp>&rsquo;,
  447. the default.
  448. </p>
  449. <p>&lsquo;<samp>none</samp>&rsquo; means to not print diagnostic paths.
  450. </p>
  451. <p>&lsquo;<samp>separate-events</samp>&rsquo; means to print a separate &ldquo;note&rdquo; diagnostic for
  452. each event within the diagnostic. For example:
  453. </p>
  454. <div class="smallexample">
  455. <pre class="smallexample">test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
  456. test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
  457. test.c:27:3: note: (2) when 'i &lt; count'
  458. test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
  459. </pre></div>
  460. <p>&lsquo;<samp>inline-events</samp>&rsquo; means to print the events &ldquo;inline&rdquo; within the source
  461. code. This view attempts to consolidate the events into runs of
  462. sufficiently-close events, printing them as labelled ranges within the source.
  463. </p>
  464. <p>For example, the same events as above might be printed as:
  465. </p>
  466. <div class="smallexample">
  467. <pre class="smallexample"> 'test': events 1-3
  468. |
  469. | 25 | list = PyList_New(0);
  470. | | ^~~~~~~~~~~~~
  471. | | |
  472. | | (1) when 'PyList_New' fails, returning NULL
  473. | 26 |
  474. | 27 | for (i = 0; i &lt; count; i++) {
  475. | | ~~~
  476. | | |
  477. | | (2) when 'i &lt; count'
  478. | 28 | item = PyLong_FromLong(random());
  479. | 29 | PyList_Append(list, item);
  480. | | ~~~~~~~~~~~~~~~~~~~~~~~~~
  481. | | |
  482. | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
  483. |
  484. </pre></div>
  485. <p>Interprocedural control flow is shown by grouping the events by stack frame,
  486. and using indentation to show how stack frames are nested, pushed, and popped.
  487. </p>
  488. <p>For example:
  489. </p>
  490. <div class="smallexample">
  491. <pre class="smallexample"> 'test': events 1-2
  492. |
  493. | 133 | {
  494. | | ^
  495. | | |
  496. | | (1) entering 'test'
  497. | 134 | boxed_int *obj = make_boxed_int (i);
  498. | | ~~~~~~~~~~~~~~~~~~
  499. | | |
  500. | | (2) calling 'make_boxed_int'
  501. |
  502. +--&gt; 'make_boxed_int': events 3-4
  503. |
  504. | 120 | {
  505. | | ^
  506. | | |
  507. | | (3) entering 'make_boxed_int'
  508. | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
  509. | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  510. | | |
  511. | | (4) calling 'wrapped_malloc'
  512. |
  513. +--&gt; 'wrapped_malloc': events 5-6
  514. |
  515. | 7 | {
  516. | | ^
  517. | | |
  518. | | (5) entering 'wrapped_malloc'
  519. | 8 | return malloc (size);
  520. | | ~~~~~~~~~~~~~
  521. | | |
  522. | | (6) calling 'malloc'
  523. |
  524. &lt;-------------+
  525. |
  526. 'test': event 7
  527. |
  528. | 138 | free_boxed_int (obj);
  529. | | ^~~~~~~~~~~~~~~~~~~~
  530. | | |
  531. | | (7) calling 'free_boxed_int'
  532. |
  533. (etc)
  534. </pre></div>
  535. </dd>
  536. <dt><code>-fdiagnostics-show-path-depths</code></dt>
  537. <dd><a name="index-fdiagnostics_002dshow_002dpath_002ddepths"></a>
  538. <p>This option provides additional information when printing control-flow paths
  539. associated with a diagnostic.
  540. </p>
  541. <p>If this is option is provided then the stack depth will be printed for
  542. each run of events within <samp>-fdiagnostics-path-format=separate-events</samp>.
  543. </p>
  544. <p>This is intended for use by GCC developers and plugin developers when
  545. debugging diagnostics that report interprocedural control flow.
  546. </p>
  547. </dd>
  548. <dt><code>-fno-show-column</code></dt>
  549. <dd><a name="index-fno_002dshow_002dcolumn"></a>
  550. <a name="index-fshow_002dcolumn"></a>
  551. <p>Do not print column numbers in diagnostics. This may be necessary if
  552. diagnostics are being scanned by a program that does not understand the
  553. column numbers, such as <code>dejagnu</code>.
  554. </p>
  555. </dd>
  556. <dt><code>-fdiagnostics-format=<var>FORMAT</var></code></dt>
  557. <dd><a name="index-fdiagnostics_002dformat"></a>
  558. <p>Select a different format for printing diagnostics.
  559. <var>FORMAT</var> is &lsquo;<samp>text</samp>&rsquo; or &lsquo;<samp>json</samp>&rsquo;.
  560. The default is &lsquo;<samp>text</samp>&rsquo;.
  561. </p>
  562. <p>The &lsquo;<samp>json</samp>&rsquo; format consists of a top-level JSON array containing JSON
  563. objects representing the diagnostics.
  564. </p>
  565. <p>The JSON is emitted as one line, without formatting; the examples below
  566. have been formatted for clarity.
  567. </p>
  568. <p>Diagnostics can have child diagnostics. For example, this error and note:
  569. </p>
  570. <div class="smallexample">
  571. <pre class="smallexample">misleading-indentation.c:15:3: warning: this 'if' clause does not
  572. guard... [-Wmisleading-indentation]
  573. 15 | if (flag)
  574. | ^~
  575. misleading-indentation.c:17:5: note: ...this statement, but the latter
  576. is misleadingly indented as if it were guarded by the 'if'
  577. 17 | y = 2;
  578. | ^
  579. </pre></div>
  580. <p>might be printed in JSON form (after formatting) like this:
  581. </p>
  582. <div class="smallexample">
  583. <pre class="smallexample">[
  584. {
  585. &quot;kind&quot;: &quot;warning&quot;,
  586. &quot;locations&quot;: [
  587. {
  588. &quot;caret&quot;: {
  589. &quot;column&quot;: 3,
  590. &quot;file&quot;: &quot;misleading-indentation.c&quot;,
  591. &quot;line&quot;: 15
  592. },
  593. &quot;finish&quot;: {
  594. &quot;column&quot;: 4,
  595. &quot;file&quot;: &quot;misleading-indentation.c&quot;,
  596. &quot;line&quot;: 15
  597. }
  598. }
  599. ],
  600. &quot;message&quot;: &quot;this \u2018if\u2019 clause does not guard...&quot;,
  601. &quot;option&quot;: &quot;-Wmisleading-indentation&quot;,
  602. &quot;option_url&quot;: &quot;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation&quot;,
  603. &quot;children&quot;: [
  604. {
  605. &quot;kind&quot;: &quot;note&quot;,
  606. &quot;locations&quot;: [
  607. {
  608. &quot;caret&quot;: {
  609. &quot;column&quot;: 5,
  610. &quot;file&quot;: &quot;misleading-indentation.c&quot;,
  611. &quot;line&quot;: 17
  612. }
  613. }
  614. ],
  615. &quot;message&quot;: &quot;...this statement, but the latter is &hellip;&quot;
  616. }
  617. ]
  618. },
  619. &hellip;
  620. ]
  621. </pre></div>
  622. <p>where the <code>note</code> is a child of the <code>warning</code>.
  623. </p>
  624. <p>A diagnostic has a <code>kind</code>. If this is <code>warning</code>, then there is
  625. an <code>option</code> key describing the command-line option controlling the
  626. warning.
  627. </p>
  628. <p>A diagnostic can contain zero or more locations. Each location has up
  629. to three positions within it: a <code>caret</code> position and optional
  630. <code>start</code> and <code>finish</code> positions. A location can also have
  631. an optional <code>label</code> string. For example, this error:
  632. </p>
  633. <div class="smallexample">
  634. <pre class="smallexample">bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' {aka
  635. 'struct s'} and 'T' {aka 'struct t'})
  636. 64 | return callee_4a () + callee_4b ();
  637. | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
  638. | | |
  639. | | T {aka struct t}
  640. | S {aka struct s}
  641. </pre></div>
  642. <p>has three locations. Its primary location is at the &ldquo;+&rdquo; token at column
  643. 23. It has two secondary locations, describing the left and right-hand sides
  644. of the expression, which have labels. It might be printed in JSON form as:
  645. </p>
  646. <div class="smallexample">
  647. <pre class="smallexample"> {
  648. &quot;children&quot;: [],
  649. &quot;kind&quot;: &quot;error&quot;,
  650. &quot;locations&quot;: [
  651. {
  652. &quot;caret&quot;: {
  653. &quot;column&quot;: 23, &quot;file&quot;: &quot;bad-binary-ops.c&quot;, &quot;line&quot;: 64
  654. }
  655. },
  656. {
  657. &quot;caret&quot;: {
  658. &quot;column&quot;: 10, &quot;file&quot;: &quot;bad-binary-ops.c&quot;, &quot;line&quot;: 64
  659. },
  660. &quot;finish&quot;: {
  661. &quot;column&quot;: 21, &quot;file&quot;: &quot;bad-binary-ops.c&quot;, &quot;line&quot;: 64
  662. },
  663. &quot;label&quot;: &quot;S {aka struct s}&quot;
  664. },
  665. {
  666. &quot;caret&quot;: {
  667. &quot;column&quot;: 25, &quot;file&quot;: &quot;bad-binary-ops.c&quot;, &quot;line&quot;: 64
  668. },
  669. &quot;finish&quot;: {
  670. &quot;column&quot;: 36, &quot;file&quot;: &quot;bad-binary-ops.c&quot;, &quot;line&quot;: 64
  671. },
  672. &quot;label&quot;: &quot;T {aka struct t}&quot;
  673. }
  674. ],
  675. &quot;message&quot;: &quot;invalid operands to binary + &hellip;&quot;
  676. }
  677. </pre></div>
  678. <p>If a diagnostic contains fix-it hints, it has a <code>fixits</code> array,
  679. consisting of half-open intervals, similar to the output of
  680. <samp>-fdiagnostics-parseable-fixits</samp>. For example, this diagnostic
  681. with a replacement fix-it hint:
  682. </p>
  683. <div class="smallexample">
  684. <pre class="smallexample">demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
  685. mean 'color'?
  686. 8 | return ptr-&gt;colour;
  687. | ^~~~~~
  688. | color
  689. </pre></div>
  690. <p>might be printed in JSON form as:
  691. </p>
  692. <div class="smallexample">
  693. <pre class="smallexample"> {
  694. &quot;children&quot;: [],
  695. &quot;fixits&quot;: [
  696. {
  697. &quot;next&quot;: {
  698. &quot;column&quot;: 21,
  699. &quot;file&quot;: &quot;demo.c&quot;,
  700. &quot;line&quot;: 8
  701. },
  702. &quot;start&quot;: {
  703. &quot;column&quot;: 15,
  704. &quot;file&quot;: &quot;demo.c&quot;,
  705. &quot;line&quot;: 8
  706. },
  707. &quot;string&quot;: &quot;color&quot;
  708. }
  709. ],
  710. &quot;kind&quot;: &quot;error&quot;,
  711. &quot;locations&quot;: [
  712. {
  713. &quot;caret&quot;: {
  714. &quot;column&quot;: 15,
  715. &quot;file&quot;: &quot;demo.c&quot;,
  716. &quot;line&quot;: 8
  717. },
  718. &quot;finish&quot;: {
  719. &quot;column&quot;: 20,
  720. &quot;file&quot;: &quot;demo.c&quot;,
  721. &quot;line&quot;: 8
  722. }
  723. }
  724. ],
  725. &quot;message&quot;: &quot;\u2018struct s\u2019 has no member named &hellip;&quot;
  726. }
  727. </pre></div>
  728. <p>where the fix-it hint suggests replacing the text from <code>start</code> up
  729. to but not including <code>next</code> with <code>string</code>&rsquo;s value. Deletions
  730. are expressed via an empty value for <code>string</code>, insertions by
  731. having <code>start</code> equal <code>next</code>.
  732. </p>
  733. <p>If the diagnostic has a path of control-flow events associated with it,
  734. it has a <code>path</code> array of objects representing the events. Each
  735. event object has a <code>description</code> string, a <code>location</code> object,
  736. along with a <code>function</code> string and a <code>depth</code> number for
  737. representing interprocedural paths. The <code>function</code> represents the
  738. current function at that event, and the <code>depth</code> represents the
  739. stack depth relative to some baseline: the higher, the more frames are
  740. within the stack.
  741. </p>
  742. <p>For example, the intraprocedural example shown for
  743. <samp>-fdiagnostics-path-format=</samp> might have this JSON for its path:
  744. </p>
  745. <div class="smallexample">
  746. <pre class="smallexample"> &quot;path&quot;: [
  747. {
  748. &quot;depth&quot;: 0,
  749. &quot;description&quot;: &quot;when 'PyList_New' fails, returning NULL&quot;,
  750. &quot;function&quot;: &quot;test&quot;,
  751. &quot;location&quot;: {
  752. &quot;column&quot;: 10,
  753. &quot;file&quot;: &quot;test.c&quot;,
  754. &quot;line&quot;: 25
  755. }
  756. },
  757. {
  758. &quot;depth&quot;: 0,
  759. &quot;description&quot;: &quot;when 'i &lt; count'&quot;,
  760. &quot;function&quot;: &quot;test&quot;,
  761. &quot;location&quot;: {
  762. &quot;column&quot;: 3,
  763. &quot;file&quot;: &quot;test.c&quot;,
  764. &quot;line&quot;: 27
  765. }
  766. },
  767. {
  768. &quot;depth&quot;: 0,
  769. &quot;description&quot;: &quot;when calling 'PyList_Append', passing NULL from (1) as argument 1&quot;,
  770. &quot;function&quot;: &quot;test&quot;,
  771. &quot;location&quot;: {
  772. &quot;column&quot;: 5,
  773. &quot;file&quot;: &quot;test.c&quot;,
  774. &quot;line&quot;: 29
  775. }
  776. }
  777. ]
  778. </pre></div>
  779. </dd>
  780. </dl>
  781. <hr>
  782. <div class="header">
  783. <p>
  784. Next: <a href="Warning-Options.html#Warning-Options" accesskey="n" rel="next">Warning Options</a>, Previous: <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" accesskey="p" rel="prev">Objective-C and Objective-C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  785. </div>
  786. </body>
  787. </html>