public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan-Benedict Glaw <jbglaw@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2711] Fix unsigned comparison warning
Date: Sat, 17 Sep 2022 13:41:12 +0000 (GMT)	[thread overview]
Message-ID: <20220917134112.E19183856DDC@sourceware.org> (raw)

https://gcc.gnu.org/g:c8e93a08693cdd8e18f129f3a1918ed3d32eeebe

commit r13-2711-gc8e93a08693cdd8e18f129f3a1918ed3d32eeebe
Author: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Date:   Sat Sep 17 15:40:28 2022 +0200

    Fix unsigned comparison warning
    
    When -mfloat-abi=hard support was added, a cast went missing that
    used to silence a warning in common code:
    
    /usr/lib/gcc-snapshot/bin/g++  -fno-PIE -c   -g -O2   -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE   -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I../../gcc/gcc/../libcody  -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace   -o builtins.o -MT builtins.o -MMD -MP -MF ./.deps/builtins.TPo ../../gcc/gcc/builtins.cc
    In file included from ./tm.h:21,
                     from ../../gcc/gcc/backend.h:28,
                     from ../../gcc/gcc/builtins.cc:27:
    ../../gcc/gcc/builtins.cc: In function 'int apply_args_size()':
    ../../gcc/gcc/config/csky/csky.h:421:13: error: comparison of unsigned expression in '>= 0' is always true [-Werror=type-limits]
      421 |   (((REGNO) >= CSKY_FIRST_PARM_REGNUM                        \
    ../../gcc/gcc/builtins.cc:1444:13: note: in expansion of macro 'FUNCTION_ARG_REGNO_P'
     1444 |         if (FUNCTION_ARG_REGNO_P (regno))
          |             ^~~~~~~~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
    make[1]: *** [Makefile:1146: builtins.o] Error 1
    
    The needed (int) cast is even mentioned in the comment above, so reinstate
    it here.
    
    gcc/ChangeLog:
            * config/csky/csky.h (FUNCTION_ARG_REGNO_P): Cast REGNO to (int)
            to prevent warning.

Diff:
---
 gcc/config/csky/csky.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/csky/csky.h b/gcc/config/csky/csky.h
index f786ad55d43..a9d13691db3 100644
--- a/gcc/config/csky/csky.h
+++ b/gcc/config/csky/csky.h
@@ -422,7 +422,7 @@ typedef struct
    The int cast is to prevent a complaint about unsigned comparison to
    zero, since CSKY_FIRST_PARM_REGNUM is zero.  */
 #define FUNCTION_ARG_REGNO_P(REGNO)                          \
-  (((REGNO) >= CSKY_FIRST_PARM_REGNUM                        \
+  (((int)(REGNO) >= CSKY_FIRST_PARM_REGNUM                   \
     && (REGNO) < (CSKY_NPARM_REGS + CSKY_FIRST_PARM_REGNUM)) \
    || FUNCTION_VARG_REGNO_P(REGNO))

                 reply	other threads:[~2022-09-17 13:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220917134112.E19183856DDC@sourceware.org \
    --to=jbglaw@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).