Re: [wwwdocs] Add various new warnings for GCC 7

2017-02-03 Thread Marek Polacek
On Thu, Feb 02, 2017 at 10:24:34PM +0100, Gerald Pfeifer wrote:
> Hi Marek,
> 
> a couple of comments (and minor changes) below.  Once you have made
> those, this is okay to commit.  Quite some stuff going into GCC 7!
>
> On Fri, 27 Jan 2017, Marek Polacek wrote:
> > Index: changes.html
> > ===
> > +New command-line options have been added for the C and C++ compilers:
> > +  
> > +-Wimplicit-fallthrough 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
> 
> Perhaps say "fall through" (in quotes)?
> 
> And why is it 'fallthrough' in doc/invoke.texi and 'falls through' here?
 
I don't think there's one established term.  I changed this to fallthrough.

> > +   the level.  It also handles control-flow statements, such as ifs.
> 
> I have to admit I am not sure what the above means practically, i.e.,
> in what manner control-flow statement interact here.
> 
> (So I did check doc/invoke.texi and there is an example, alas no
> explanation.  Is the point that GCC only warns about the "i < 1"
> arm?  That may be good describing in the documentation.)
 
Yeah, it means that the warning can figure out that only some (or none)
of the branches of an if can fall through.  (In the future it should also
handle switches much in the same way.)

> > +   It's possible to suppres the warning by either adding a falls through
> > +   comment, or by using a null statement: __attribute__
> 
> Same as above.
 
Changed, too.

> > +-Wpointer-compare 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.
> 
> How about "Such code is now invalid in C++11 and GCC rejects it"?
 
Ok. 
 
> > +-Wrestrict warns when an argument passed to a
> > +restrict-qualified parameter aliases with another argument.
> 
> restrict-qualified
> 
> > +-Wmemset-elt-size warns for memset calls, when the 
> > first
> 
> memset
> 
> > +-Wswitch-unreachable warns when a switch statement has
> 
> switch
> 
> > +-Wregister warns about uses of register
> > +storage specifier.  In C++17 this keyword has been removed and for 
> > C++17
> 
> "the...storage specified" (adding "the")
> 
> > +has duplicate const, volatile, restrict or _Atomic specifier.
> 
> const
> volatile
> restrict
> _Atomic
> 
> > +The new -Wdangling-else command-line option has been split
> > +out of -Wparentheses and warns about dangling else.
> 
> else

All fixed & committed.

Marek


Re: [wwwdocs] Add various new warnings for GCC 7

2017-02-02 Thread Gerald Pfeifer
Hi Marek,

a couple of comments (and minor changes) below.  Once you have made
those, this is okay to commit.  Quite some stuff going into GCC 7!

On Fri, 27 Jan 2017, Marek Polacek wrote:
> Index: changes.html
> ===
> +New command-line options have been added for the C and C++ compilers:
> +  
> +-Wimplicit-fallthrough 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

Perhaps say "fall through" (in quotes)?

And why is it 'fallthrough' in doc/invoke.texi and 'falls through' here?

> + the level.  It also handles control-flow statements, such as ifs.

I have to admit I am not sure what the above means practically, i.e.,
in what manner control-flow statement interact here.

(So I did check doc/invoke.texi and there is an example, alas no
explanation.  Is the point that GCC only warns about the "i < 1"
arm?  That may be good describing in the documentation.)

> + It's possible to suppres the warning by either adding a falls through
> + comment, or by using a null statement: __attribute__

Same as above.

> +-Wpointer-compare 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.

How about "Such code is now invalid in C++11 and GCC rejects it"?

> +-Wrestrict warns when an argument passed to a
> +restrict-qualified parameter aliases with another argument.

restrict-qualified

> +-Wmemset-elt-size warns for memset calls, when the first

memset

> +-Wswitch-unreachable warns when a switch statement has

switch

> +-Wregister warns about uses of register
> +storage specifier.  In C++17 this keyword has been removed and for 
> C++17

"the...storage specified" (adding "the")

> +has duplicate const, volatile, restrict or _Atomic specifier.

const
volatile
restrict
_Atomic

> +The new -Wdangling-else command-line option has been split
> +out of -Wparentheses and warns about dangling else.

else


Gerald


Re: [wwwdocs] Add various new warnings for GCC 7

2017-01-27 Thread Jakub Jelinek
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:
> > -Wregister warns about uses of register 
> > 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.
> 
> 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


Re: [wwwdocs] Add various new warnings for GCC 7

2017-01-27 Thread Gerald Pfeifer
On Fri, 27 Jan 2017, Jakub Jelinek wrote:
> For -Wregister I think it would be better to write more:
> -Wregister warns about uses of register 
> 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.

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


Re: [wwwdocs] Add various new warnings for GCC 7

2017-01-27 Thread Marek Polacek
On Fri, Jan 27, 2017 at 05:36:48PM +0100, Jakub Jelinek wrote:
> On Fri, Jan 27, 2017 at 05:13:22PM +0100, Marek Polacek wrote:
> > +-Wregister warns about uses of register storage 
> > specifier.
> > +
> 
> For -Wregister I think it would be better to write more:
> -Wregister warns about uses of register 
> 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.
> ?

Sure:

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.html27 Jan 2017 09:54:32 -  1.44
+++ changes.html27 Jan 2017 17:06:40 -
@@ -110,6 +110,49 @@
 
 C family
 
+New command-line options have been added for the C and C++ compilers:
+  
+-Wimplicit-fallthrough 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: __attribute__
+   ((fallthrough)); (C, C++), or [[fallthrough]];
+(C++17), or [[gnu::fallthrough]]; (C++11/C++14).
+This warning is enabled by -Wextra.
+-Wpointer-compare 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.
+-Wduplicated-branches warns when an if-else has identical
+branches.
+-Wrestrict warns when an argument passed to a
+restrict-qualified parameter aliases with another argument.
+-Wmemset-elt-size 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 -Wall.
+-Wint-in-bool-context warns about suspicious uses of
+integer values where boolean values are expected.  This warning is
+   enabled by -Wall.
+-Wswitch-unreachable 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.
+-Wexpansion-to-defined warns when defined is
+used outside #if.  This warning is enabled by
+   -Wextra or -Wpedantic.
+-Wregister warns about uses of register
+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.
+-Wvla-larger-than=N warns about unbounded uses of
+variable-length arrays, and about bounded uses of variable-length
+   arrays whose bound can be larger than N bytes.
+-Wduplicate-decl-specifier warns when a declaration
+has duplicate const, volatile, restrict or _Atomic specifier.
+This warning is enabled by -Wall.
+  
+
   GCC 6's C and C++ frontends were able to offer suggestions for
   misspelled field names:
   
@@ -172,6 +215,8 @@
   %d
 
 
+The new -Wdangling-else command-line option has been split
+out of -Wparentheses and warns about dangling else.
 The -Wshadow warning has been split into three
 variants. -Wshadow=global warns for any shadowing.  This
 is the default when using -Wshadow without any
@@ -303,6 +348,9 @@
^
;
 
+  -Waligned-new has been added to the C++ front end.  It warns
+  about new of type with extended alignment without
+  -faligned-new.
 
 
 Runtime Library (libstdc++)

Marek


Re: [wwwdocs] Add various new warnings for GCC 7

2017-01-27 Thread Jakub Jelinek
On Fri, Jan 27, 2017 at 05:13:22PM +0100, Marek Polacek wrote:
> +-Wregister warns about uses of register storage 
> specifier.
> +

For -Wregister I think it would be better to write more:
-Wregister warns about uses of register 
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.
?

Jakub