diff mbox

[wwwdocs] Add various new warnings for GCC 7

Message ID 20170127161322.GC6809@redhat.com
State New
Headers show

Commit Message

Marek Polacek Jan. 27, 2017, 4:13 p.m. UTC
This patch adds a description for the following warnings:

-Wimplicit-fallthrough
-Wpointer-compare
-Wduplicated-branches
-Wrestrict
-Wmemset-elt-size
-Wint-in-bool-context
-Wswitch-unreachable
-Wexpansion-to-defined
-Wregister
-Wvla-larger-than=N
-Wduplicate-decl-specifier
-Waligned-new
-Wdangling-else

OK to commit?


	Marek

Comments

Jakub Jelinek Jan. 27, 2017, 4:36 p.m. UTC | #1
On Fri, Jan 27, 2017 at 05:13:22PM +0100, Marek Polacek wrote:
> +    <li><code>-Wregister</code> warns about uses of register storage specifier.
> +        </li>

For -Wregister I think it would be better to write more:
    <li><code>-Wregister</code> warns about uses of <code>register</code> storage
          specifier.  In C++17 this keyword has been removed and for C++17
          this is a pedantic warning enabled by default.  The warning is not
	  emitted for the GNU Explicit Register Variables extension.</li>
?

	Jakub
Gerald Pfeifer Jan. 27, 2017, 8:32 p.m. UTC | #2
On Fri, 27 Jan 2017, Jakub Jelinek wrote:
> For -Wregister I think it would be better to write more:
>     <li><code>-Wregister</code> warns about uses of <code>register</code> storage
>           specifier.  In C++17 this keyword has been removed and for C++17
>           this is a pedantic warning enabled by default.  The warning is not
> 	  emitted for the GNU Explicit Register Variables extension.</li>

Is C++17 correct in both cases?  If the register keyword has been 
removed, wouldn't that be an error as opposed to just a warning?

Gerald
Jakub Jelinek Jan. 27, 2017, 8:39 p.m. UTC | #3
On Fri, Jan 27, 2017 at 09:32:05PM +0100, Gerald Pfeifer wrote:
> On Fri, 27 Jan 2017, Jakub Jelinek wrote:
> > For -Wregister I think it would be better to write more:
> >     <li><code>-Wregister</code> warns about uses of <code>register</code> storage
> >           specifier.  In C++17 this keyword has been removed and for C++17
> >           this is a pedantic warning enabled by default.  The warning is not
> > 	  emitted for the GNU Explicit Register Variables extension.</li>
> 
> Is C++17 correct in both cases?  If the register keyword has been 
> removed, wouldn't that be an error as opposed to just a warning?

For C++17 it is a pedwarn, i.e. an error with -pedantic-errors, or
-Werror=register, warning otherwise, no diagnostics with -Wno-register.
For C++14 and ealier it is (non-default) normal warning, i.e. a warning
with -Wregister, no warning by default or with -Wno-register, error with
-Werror=register.

	Jakub
diff mbox

Patch

Index: changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-7/changes.html,v
retrieving revision 1.44
diff -u -r1.44 changes.html
--- changes.html	27 Jan 2017 09:54:32 -0000	1.44
+++ changes.html	27 Jan 2017 16:10:28 -0000
@@ -110,6 +110,47 @@ 
 
 <h3 id="c-family">C family</h3>
 <ul>
+<li>New command-line options have been added for the C and C++ compilers:
+  <ul>
+    <li><code>-Wimplicit-fallthrough</code> warns when a switch case falls
+        through.  This warning has five different levels.  The compiler is
+	able to parse a wide range of falls through comments, depending on
+	the level.  It also handles control-flow statements, such as ifs.
+	It's possible to suppres the warning by either adding a falls through
+	comment, or by using a null statement: <code>__attribute__
+	((fallthrough));</code> (C, C++), or <code>[[fallthrough]];</code>
+        (C++17), or <code>[[gnu::fallthrough]];</code> (C++11/C++14).
+        This warning is enabled by <code>-Wextra</code>.</li>
+    <li><code>-Wpointer-compare</code> warns when a pointer is compared with
+        a zero character constant.  This code is now invalid in C++11 and
+	GCC rejects such code.  This warning is enabled by default.</li>
+    <li><code>-Wduplicated-branches</code> warns when an if-else has identical
+        branches.</li>
+    <li><code>-Wrestrict</code> warns when an argument passed to a
+        restrict-qualified parameter aliases with another argument.</li>
+    <li><code>-Wmemset-elt-size</code> warns for memset calls, when the first
+        argument references an array, and the third argument is a number equal
+	to the number of elements of the array, but not the size of the array.
+	This warning is enabled by <code>-Wall</code>.</li>
+    <li><code>-Wint-in-bool-context</code> warns about suspicious uses of
+        integer values where boolean values are expected.  This warning is
+	enabled by <code>-Wall</code>.</li>
+    <li><code>-Wswitch-unreachable</code> warns when a switch statement has
+        statements between the controlling expression and the first case label
+	which will never be executed.  This warning is enabled by default.</li>
+    <li><code>-Wexpansion-to-defined</code> warns when <code>defined</code> is
+        used outside <code>#if</code>.  This warning is enabled by
+	<code>-Wextra</code> or <code>-Wpedantic</code>.</li>
+    <li><code>-Wregister</code> warns about uses of register storage specifier.
+        </li>
+    <li><code>-Wvla-larger-than=N</code> warns about unbounded uses of
+        variable-length arrays, and about bounded uses of variable-length
+	arrays whose bound can be larger than <code>N</code> bytes.</li>
+    <li><code>-Wduplicate-decl-specifier</code> warns when a declaration
+        has duplicate const, volatile, restrict or _Atomic specifier.
+        This warning is enabled by <code>-Wall</code>.</li>
+  </ul>
+</li>
   <li>GCC 6's C and C++ frontends were able to offer suggestions for
       misspelled field names:
       <blockquote><pre>
@@ -172,6 +213,8 @@ 
                           <span class="green">%d</span>
 </pre></blockquote></li>
 
+<li>The new <code>-Wdangling-else</code> command-line option has been split
+out of <code>-Wparentheses</code> and warns about dangling else.</li>
 <li><p>The <code>-Wshadow</code> warning has been split into three
 variants. <code>-Wshadow=global</code> warns for any shadowing.  This
 is the default when using <code>-Wshadow</code> without any
@@ -303,6 +346,9 @@ 
            <span class="boldred">^</span>
            <span class="green">;</span>
 </pre></blockquote></li>
+  <li><code>-Waligned-new</code> has been added to the C++ front end.  It warns
+      about <code>new</code> of type with extended alignment without
+      <code>-faligned-new</code>.</li>
 </ul>
 
 <h4 id="libstdcxx">Runtime Library (libstdc++)</h4>