This patch incorporates your review suggestions. Successfully checked as XHTML 1.0 Transitional. I've committed it to CVS.
I made this version using gcc-color-to-html.py from the previous patch, to turn the SGR codes into spans for use with our gcc.css. It adds various entries to the stylesheet to reflect the needs of the examples. --- htdocs/gcc-8/changes.html | 263 +++++++++++++++++++++++++++++++++++++++++++++- htdocs/gcc.css | 5 + 2 files changed, 267 insertions(+), 1 deletion(-) diff --git a/htdocs/gcc-8/changes.html b/htdocs/gcc-8/changes.html index 707cd4e..bc91156 100644 --- a/htdocs/gcc-8/changes.html +++ b/htdocs/gcc-8/changes.html @@ -183,11 +183,243 @@ a work-in-progress.</h2> is now undefined by default at all optimization levels. Using <code>-fsanitize=signed-integer-overflow</code> is now the preferred way to audit code, <code>-Wstrict-overflow</code> is deprecated.</li> + <li>When reporting mismatching argument types at a function call, the + C and C++ compilers now underline both the argument and the pertinent + parameter in the declaration. +<pre class="blackbg"> +$ gcc arg-type-mismatch.cc +<span class="bold">arg-type-mismatch.cc:</span> In function '<span class="bold">int caller(int, int, float)</span>': +<span class="bold">arg-type-mismatch.cc:5:24:</span> <span class="boldred">error: </span>invalid conversion from '<span class="bold">int</span>' to '<span class="bold">const char*</span>' [<span class="boldred">-fpermissive</span>] + return callee(first, <span class="boldred">second</span>, third); + <span class="boldred">^~~~~~</span> +<span class="bold">arg-type-mismatch.cc:1:40:</span> <span class="boldcyan">note: </span> initializing argument 2 of '<span class="bold">int callee(int, const char*, float)</span>' + extern int callee(int one, <span class="boldcyan">const char *two</span>, float three); + <span class="boldcyan">~~~~~~~~~~~~^~~</span> +</pre> + + </li> + <li>When reporting on unrecognized identifiers, the C and C++ compilers + will now emit fix-it hints suggesting <code>#include</code> directives + for various headers in the C and C++ standard libraries. +<pre class="blackbg"> +$ gcc incomplete.c +<span class="bold">incomplete.c:</span> In function '<span class="bold">test</span>': +<span class="bold">incomplete.c:3:10:</span> <span class="boldred">error: </span>'<span class="bold">NULL</span>' undeclared (first use in this function) + return <span class="boldred">NULL</span>; + <span class="boldred">^~~~</span> +<span class="bold">incomplete.c:3:10:</span> <span class="boldcyan">note: </span>'<span class="bold">NULL</span>' is defined in header '<span class="bold"><stddef.h></span>'; did you forget to '<span class="bold">#include <stddef.h></span>'? +<span class="bold">incomplete.c:1:1:</span> ++<span class="green">#include <stddef.h></span> + const char *test(void) +<span class="bold">incomplete.c:3:10:</span> + return <span class="boldcyan">NULL</span>; + <span class="boldcyan">^~~~</span> +<span class="bold">incomplete.c:3:10:</span> <span class="boldcyan">note: </span>each undeclared identifier is reported only once for each function it appears in +</pre> + +<pre class="blackbg"> +$ gcc incomplete.cc +<span class="bold">incomplete.cc:1:6:</span> <span class="boldred">error: </span>'<span class="bold">string</span>' in namespace '<span class="bold">std</span>' does not name a type + std::<span class="boldred">string</span> s("hello world"); + <span class="boldred">^~~~~~</span> +<span class="bold">incomplete.cc:1:1:</span> <span class="boldcyan">note: </span>'<span class="bold">std::string</span>' is defined in header '<span class="bold"><string></span>'; did you forget to '<span class="bold">#include <string></span>'? ++<span class="green">#include <string></span> + <span class="boldcyan">std</span>::string s("hello world"); + <span class="boldcyan">^~~</span> +</pre> + + </li> + <li>The C and C++ compilers now use more intuitive locations when + reporting on missing semicolons, and offer fix-it hints: +<pre class="blackbg"> +$ gcc t.c +<span class="bold">t.c:</span> In function '<span class="bold">test</span>': +<span class="bold">t.c:3:12:</span> <span class="boldred">error: </span>expected '<span class="bold">;</span>' before '<span class="bold">}</span>' token + return 42 + <span class="boldred">^</span> + <span class="green">;</span> + <span class="green">}</span> + <span class="green">~</span> +</pre> + + </li> + <li>When reporting on missing '}' and ')' tokens, the C and C++ + compilers will now highlight the corresponding '{' and '(' token, + issuing a 'note' if it's on a separate line: +<pre class="blackbg"> +$ gcc unclosed.c +<span class="bold">unclosed.c:</span> In function '<span class="bold">log_when_out_of_range</span>': +<span class="bold">unclosed.c:12:50:</span> <span class="boldred">error: </span>expected '<span class="bold">)</span>' before '<span class="bold">{</span>' token + && (temperature < MIN || temperature > MAX)<span class="boldred"> </span><span class="green">{</span> + <span class="boldred">^</span><span class="green">~</span> + <span class="green">)</span> +<span class="bold">unclosed.c:11:6:</span> <span class="boldcyan">note: </span>to match this '<span class="bold">(</span>' + if <span class="boldcyan">(</span>logging_enabled && check_range () + <span class="boldcyan">^</span> +</pre> + or highlighting it directly if it's on the same line: +<pre class="blackbg"> +$ gcc unclosed-2.c +<span class="bold">unclosed-2.c:</span> In function '<span class="bold">test</span>': +<span class="bold">unclosed-2.c:8:45:</span> <span class="boldred">error: </span>expected '<span class="bold">)</span>' before '<span class="bold">{</span>' token + if <span class="blue">(</span>temperature < MIN || temperature > MAX<span class="boldred"> </span><span class="green">{</span> + <span class="blue">~</span> <span class="boldred">^</span><span class="green">~</span> + <span class="green">)</span> +</pre> + They will also emit fix-it hints. + </li> </ul> <h3 id="cxx">C++</h3> <ul> - <li></li> + <li>When reporting on attempts to access private fields of a class or + struct, the C++ compiler will now offer fix-it hints showing how to + use an accessor function to get at the field in question, if one exists. +<pre class="blackbg"> +$ gcc accessor.cc +<span class="bold">accessor.cc:</span> In function '<span class="bold">void test(foo*)</span>': +<span class="bold">accessor.cc:12:12:</span> <span class="boldred">error: </span>'<span class="bold">double foo::m_ratio</span>' is private within this context + if (ptr-><span class="boldred">m_ratio</span> >= 0.5) + <span class="boldred">^~~~~~~</span> +<span class="bold">accessor.cc:7:10:</span> <span class="boldcyan">note: </span>declared private here + double <span class="boldcyan">m_ratio</span>; + <span class="boldcyan">^~~~~~~</span> +<span class="bold">accessor.cc:12:12:</span> <span class="boldcyan">note: </span>field '<span class="bold">double foo::m_ratio</span>' can be accessed via '<span class="bold">double foo::get_ratio() const</span>' + if (ptr-><span class="boldcyan">m_ratio</span> >= 0.5) + <span class="boldcyan">^~~~~~~</span> + <span class="green">get_ratio()</span> +</pre> + + </li> + <li>The C++ compiler can now give you a hint if you use a macro before it + was defined (e.g. if you mess up the order of your <code>#include</code> + directives): +<pre class="blackbg"> +$ gcc ordering.cc +<span class="bold">ordering.cc:2:24:</span> <span class="boldred">error: </span>expected '<span class="bold">;</span>' at end of member declaration + virtual void clone() <span class="boldred">const</span> OVERRIDE { } + <span class="boldred">^~~~~</span> + <span class="green">;</span> +<span class="bold">ordering.cc:2:30:</span> <span class="boldred">error: </span>'<span class="bold">OVERRIDE</span>' does not name a type + virtual void clone() const <span class="boldred">OVERRIDE</span> { } + <span class="boldred">^~~~~~~~</span> +<span class="bold">ordering.cc:2:30:</span> <span class="boldcyan">note: </span>the macro '<span class="bold">OVERRIDE</span>' had not yet been defined +In file included from <span class="bold">ordering.cc:5</span>: +<span class="bold">c++11-compat.h:2:</span> <span class="boldcyan">note: </span>it was later defined here + #define OVERRIDE override + +</pre> + + </li> + <li>The <code>-Wold-style-cast</code> diagnostic can now emit fix-it hints + telling you when you can use a <code>static_cast</code>, + <code>const_cast</code>, or <code>reinterpret_cast</code>. +<pre class="blackbg"> +$ gcc -c old-style-cast-fixits.cc -Wold-style-cast +<span class="bold">old-style-cast-fixits.cc:</span> In function '<span class="bold">void test(void*)</span>': +<span class="bold">old-style-cast-fixits.cc:5:19:</span> <span class="boldmagenta">warning: </span>use of old-style cast to '<span class="bold">struct foo*</span>' [<span class="boldmagenta">-Wold-style-cast</span>] + foo *f = (foo *)<span class="boldmagenta">ptr</span>; + <span class="boldmagenta">^~~</span> + <span class="red">----------</span> + <span class="green">static_cast<foo *> (ptr)</span> +</pre> + + </li> + <li>When reporting on problems within <code>extern "C"</code> linkage + specifications, the C++ compiler will now display the location of the + start of the <code>extern "C"</code>. +<pre class="blackbg"> +$ gcc -c extern-c.cc +<span class="bold">extern-c.cc:3:1:</span> <span class="boldred">error: </span>template with C linkage + <span class="boldred">template</span> <typename T> void test (void); + <span class="boldred">^~~~~~~~</span> +In file included from <span class="bold">extern-c.cc:1</span>: +<span class="bold">unclosed.h:1:1:</span> <span class="boldcyan">note: </span>'<span class="bold">extern "C"</span>' linkage started here + <span class="boldcyan">extern "C"</span> { + <span class="boldcyan">^~~~~~~~~~</span> +<span class="bold">extern-c.cc:3:39:</span> <span class="boldred">error: </span>expected '<span class="bold">}</span>' at end of input + template <typename T> void test (void)<span class="boldred">;</span> + <span class="boldred">^</span> +In file included from <span class="bold">extern-c.cc:1</span>: +<span class="bold">unclosed.h:1:12:</span> <span class="boldcyan">note: </span>to match this '<span class="bold">{</span>' + extern "C" <span class="boldcyan">{</span> + <span class="boldcyan">^</span> +</pre> + + </li> + <li>When reporting on mismatching template types, the C++ compiler will + now use color to highlight the mismatching parts of the template, and will + elide the parameters that are common between two mismatching templates, + printing <code>[...]</code> instead: +<pre class="blackbg"> +$ gcc templates.cc +<span class="bold">templates.cc:</span> In function '<span class="bold">void test()</span>': +<span class="bold">templates.cc:9:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="boldgreen">double</span>></span>' to '<span class="bold">vector<<span class="boldgreen">int</span>></span>' + fn_1(<span class="boldred">vector<double> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~</span> +<span class="bold">templates.cc:10:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">map<int, double>()</span>' from '<span class="bold">map<[...],<span class="boldgreen">double</span>></span>' to '<span class="bold">map<[...],<span class="boldgreen">int</span>></span>' + fn_2(<span class="boldred">map<int, double>()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~~</span> +</pre> + + Those <code>[...]</code> elided parameters can be seen using + <code>-fno-elide-type</code>: +<pre class="blackbg"> +$ gcc templates.cc -fno-elide-type +<span class="bold">templates.cc:</span> In function '<span class="bold">void test()</span>': +<span class="bold">templates.cc:9:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="boldgreen">double</span>></span>' to '<span class="bold">vector<<span class="boldgreen">int</span>></span>' + fn_1(<span class="boldred">vector<double> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~</span> +<span class="bold">templates.cc:10:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">map<int, double>()</span>' from '<span class="bold">map<int,<span class="boldgreen">double</span>></span>' to '<span class="bold">map<int,<span class="boldgreen">int</span>></span>' + fn_2(<span class="boldred">map<int, double>()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~~</span> +</pre> + + The C++ compiler has also gained an option + <code>-fdiagnostics-show-template-tree</code> which visualizes such + mismatching templates in a hierarchical form: +<pre class="blackbg"> +$ gcc templates-2.cc -fdiagnostics-show-template-tree +<span class="bold">templates-2.cc:</span> In function '<span class="bold">void test()</span>': +<span class="bold">templates-2.cc:9:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="boldgreen">double</span>></span>' to '<span class="bold">vector<<span class="boldgreen">int</span>></span>' + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">int</span>]> + fn_1(<span class="boldred">vector<double> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~</span> +<span class="bold">templates-2.cc:10:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">map<map<int, vector<double> >, vector<double> >()</span>' from '<span class="bold">map<map<[...],vector<<span class="boldgreen">double</span>>>,vector<<span class="boldgreen">double</span>>></span>' to '<span class="bold">map<map<[...],vector<<span class="boldgreen">float</span>>>,vector<<span class="boldgreen">float</span>>></span>' + map< + map< + [...], + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">float</span>]>>, + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">float</span>]>> + fn_2(<span class="boldred">map<map<int, vector<double>>, vector<double>> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span> +</pre> + + which again works with <code>-fno-elide-type</code>: +<pre class="blackbg"> +$ gcc templates-2.cc -fdiagnostics-show-template-tree -fno-elide-type +<span class="bold">templates-2.cc:</span> In function '<span class="bold">void test()</span>': +<span class="bold">templates-2.cc:9:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">vector<double>()</span>' from '<span class="bold">vector<<span class="boldgreen">double</span>></span>' to '<span class="bold">vector<<span class="boldgreen">int</span>></span>' + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">int</span>]> + fn_1(<span class="boldred">vector<double> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~</span> +<span class="bold">templates-2.cc:10:8:</span> <span class="boldred">error: </span>could not convert '<span class="bold">map<map<int, vector<double> >, vector<double> >()</span>' from '<span class="bold">map<map<int,vector<<span class="boldgreen">double</span>>>,vector<<span class="boldgreen">double</span>>></span>' to '<span class="bold">map<map<int,vector<<span class="boldgreen">float</span>>>,vector<<span class="boldgreen">float</span>>></span>' + map< + map< + int, + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">float</span>]>>, + vector< + [<span class="boldgreen">double</span> != <span class="boldgreen">float</span>]>> + fn_2(<span class="boldred">map<map<int, vector<double>>, vector<double>> ()</span>); + <span class="boldred">^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span> +</pre> + + </li> </ul> <h3 id="fortran">Fortran</h3> @@ -270,6 +502,19 @@ a work-in-progress.</h2> <!-- .................................................................. --> <h2 id="jit">libgccjit</h2> +<p>The libgccjit API gained four new entry points:</p> +<ul> + <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/types.html#gcc_jit_type_get_vector">gcc_jit_type_get_vector</a> + and + </li> + <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/expressions.html#gcc_jit_context_new_rvalue_from_vector">gcc_jit_context_new_rvalue_from_vector</a> for working with vectors, + </li> + <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/types.html#gcc_jit_type_get_aligned">gcc_jit_type_get_aligned</a></li> + <li><a href="https://gcc.gnu.org/onlinedocs/jit/topics/function-pointers.html#gcc_jit_function_get_address">gcc_jit_function_get_address</a></li> +</ul> +<p>The C code generated by +<a href="https://gcc.gnu.org/onlinedocs/jit/topics/contexts.html#gcc_jit_context_dump_reproducer_to_file">gcc_jit_context_dump_reproducer_to_file</a> +is now easier-to-read.</p> <!-- .................................................................. --> <h2 id="targets">New Targets and Target Specific Improvements</h2> @@ -637,6 +882,22 @@ a work-in-progress.</h2> <!-- .................................................................. --> +<h2 id="plugins">Improvements for plugin authors</h2> +<ul> + <li>Plugins can now register a callback hook for when comments are + encountered by the C and C++ compilers, e.g. allowing for plugins + to handle documentation markup in code comments. + </li> + <li>The gdbinit support script for debugging GCC now has a + <code>break-on-diagnostic</code> command, providing an easy way + to trigger a breakpoint whenever a diagnostic is emitted. + </li> + <li>The API for creating fix-it hints now supports newlines, and for + emitting mutually incompatible fix-it hints for one diagnostic. + </li> +</ul> + +<!-- .................................................................. --> <h2>Other significant improvements</h2> <ul> <li></li> diff --git a/htdocs/gcc.css b/htdocs/gcc.css index 35321f1..718dd80 100644 --- a/htdocs/gcc.css +++ b/htdocs/gcc.css @@ -68,12 +68,17 @@ div.copyright { } div.copyright p:nth-child(3) { margin-bottom: 0; } +.bold { font-weight:bold; } .boldcyan { font-weight:bold; color:cyan; } .boldlime { font-weight:bold; color:lime; } .boldmagenta { font-weight:bold; color:magenta; } .boldred { font-weight:bold; color:red; } +.boldgreen { font-weight:bold; color:green; } .boldblue { font-weight:bold; color:blue; } +.red { color:red; } .green { color:green; } +.blue { color:blue; } +.blackbg { color:white; background-color: #000000; } /* Quote an e-mail. The first <div> has the sender, the second the quote. */ blockquote.mail div:nth-child(2) { border-left: solid blue; padding-left: 4pt; } -- 1.8.5.3