diff mbox

genrecog: Address -Wsign-compare diagnostics (was: Mostly rewrite genrecog)

Message ID 87twvntoyn.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge May 8, 2015, 9:09 a.m. UTC
Hi!

On Mon, 27 Apr 2015 11:20:30 +0100, Richard Sandiford <richard.sandiford@arm.com> wrote:
> This patch [...] by replacing most of genrecog [...]

OK to commit?

Is it a bug that I'm seeing these warnings only in the stage 1 build with
the bootstrap GCC 4.6 compiler, but not anymore later on?  (I have not
verified the C++ standard on the rules for »comparison between signed and
unsigned integer expressions«.)

commit efef4f38205a13da90ca19b6eec1a6526756b433
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Fri May 8 10:55:19 2015 +0200

    genrecog: Address -Wsign-compare diagnostics.
    
        g++-4.6 [...] [...]/gcc/genrecog.c
        [...]/gcc/genrecog.c: In function 'state_size find_subroutines(routine_type, state*, vec<state*>&)':
        [...]/gcc/genrecog.c:3338:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        [...]/gcc/genrecog.c:3347:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        [...]/gcc/genrecog.c:3359:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
        [...]/gcc/genrecog.c:3365:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    
        3305   state_size size;
             [...]
        3337           state_size to_size = find_subroutines (type, trans->to, procs);
        3338           if (d->next && to_size.depth > MAX_DEPTH)
             [...]
        3347               if (to_size.num_statements < MIN_NUM_STATEMENTS)
             [...]
        3359   if (size.num_statements > MAX_NUM_STATEMENTS)
             [...]
        3365              && size.num_statements > MAX_NUM_STATEMENTS)
    
         175 static const int MAX_DEPTH = 6;
             [...]
         179 static const int MIN_NUM_STATEMENTS = 5;
             [...]
         185 static const int MAX_NUM_STATEMENTS = 200;
             [...]
        3258 struct state_size
        3259 {
             [...]
        3261   unsigned int num_statements;
             [...]
        3265   unsigned int depth;
        3266 };
    
    	gcc/
    	* genrecog.c (MAX_DEPTH, MIN_NUM_STATEMENTS, MAX_NUM_STATEMENTS):
    	Change to unsigned int.
---
 gcc/genrecog.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)



Grüße,
 Thomas

Comments

Richard Sandiford May 8, 2015, 2:43 p.m. UTC | #1
Thomas Schwinge <thomas@codesourcery.com> writes:
> Hi!
>
> On Mon, 27 Apr 2015 11:20:30 +0100, Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>> This patch [...] by replacing most of genrecog [...]
>
> OK to commit?

Looks good to me FWIW.  Probably counts as obvious.

Thanks,
Richard
Jeff Law May 8, 2015, 6:39 p.m. UTC | #2
On 05/08/2015 03:09 AM, Thomas Schwinge wrote:
> Hi!
>
> On Mon, 27 Apr 2015 11:20:30 +0100, Richard Sandiford <richard.sandiford@arm.com> wrote:
>> This patch [...] by replacing most of genrecog [...]
>
> OK to commit?
>
> Is it a bug that I'm seeing these warnings only in the stage 1 build with
> the bootstrap GCC 4.6 compiler, but not anymore later on?  (I have not
> verified the C++ standard on the rules for »comparison between signed and
> unsigned integer expressions«.)
>
> commit efef4f38205a13da90ca19b6eec1a6526756b433
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date:   Fri May 8 10:55:19 2015 +0200
>
>      genrecog: Address -Wsign-compare diagnostics.
>
>          g++-4.6 [...] [...]/gcc/genrecog.c
>          [...]/gcc/genrecog.c: In function 'state_size find_subroutines(routine_type, state*, vec<state*>&)':
>          [...]/gcc/genrecog.c:3338:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>          [...]/gcc/genrecog.c:3347:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>          [...]/gcc/genrecog.c:3359:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>          [...]/gcc/genrecog.c:3365:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
>
>          3305   state_size size;
>               [...]
>          3337           state_size to_size = find_subroutines (type, trans->to, procs);
>          3338           if (d->next && to_size.depth > MAX_DEPTH)
>               [...]
>          3347               if (to_size.num_statements < MIN_NUM_STATEMENTS)
>               [...]
>          3359   if (size.num_statements > MAX_NUM_STATEMENTS)
>               [...]
>          3365              && size.num_statements > MAX_NUM_STATEMENTS)
>
>           175 static const int MAX_DEPTH = 6;
>               [...]
>           179 static const int MIN_NUM_STATEMENTS = 5;
>               [...]
>           185 static const int MAX_NUM_STATEMENTS = 200;
>               [...]
>          3258 struct state_size
>          3259 {
>               [...]
>          3261   unsigned int num_statements;
>               [...]
>          3265   unsigned int depth;
>          3266 };
>
>      	gcc/
>      	* genrecog.c (MAX_DEPTH, MIN_NUM_STATEMENTS, MAX_NUM_STATEMENTS):
>      	Change to unsigned int.
> ---
>   gcc/genrecog.c |    6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
OK with a ChangeLog and the usual testing.  Or you can verify the output 
of genrecog doesn't change before/after if you don't want to go through 
the full bootstrap.

jeff
diff mbox

Patch

diff --git gcc/genrecog.c gcc/genrecog.c
index 73e7995..653f753 100644
--- gcc/genrecog.c
+++ gcc/genrecog.c
@@ -172,17 +172,17 @@  static const bool force_unique_params_p = true;
 /* The maximum (approximate) depth of block nesting that an individual
    routine or subroutine should have.  This limit is about keeping the
    output readable rather than reducing compile time.  */
-static const int MAX_DEPTH = 6;
+static const unsigned int MAX_DEPTH = 6;
 
 /* The minimum number of pseudo-statements that a state must have before
    we split it out into a subroutine.  */
-static const int MIN_NUM_STATEMENTS = 5;
+static const unsigned int MIN_NUM_STATEMENTS = 5;
 
 /* The number of pseudo-statements a state can have before we consider
    splitting out substates into subroutines.  This limit is about avoiding
    compile-time problems with very big functions (and also about keeping
    functions within --param optimization limits, etc.).  */
-static const int MAX_NUM_STATEMENTS = 200;
+static const unsigned int MAX_NUM_STATEMENTS = 200;
 
 /* The minimum number of pseudo-statements that can be used in a pattern
    routine.  */