aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsayjones.plus.com>2020-06-05 22:29:24 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-06 00:32:50 +0200
commitcadbd1245acecf5d91f07834e2820b0e2a91faf9 (patch)
treec8fc95f59a9f416494a7a28a3e3006447c8f7c92
parent41f651b442fa4ef2b562573aa4da1b6a644eed76 (diff)
downloadsparse-cadbd1245acecf5d91f07834e2820b0e2a91faf9.tar.gz
pre-process: fix a compiler array subscript type warning
On cygwin, the <ctype.h> header is written in such a way as to cause a gcc compiler warning if a plain 'char' is passed to the character classification macros (in this case isdigit). The result is defined only if the parameter is representable as an unsigned char, or if it is EOF. When passing a 'char' type argument to isdigit(), the compiler warns like so: CC pre-process.o In file included from pre-process.c:33: pre-process.c: In function ‘predefine’: pre-process.c:1429:18: warning: array subscript has type ‘char’ [-Wchar-subscripts] 1429 | if (isdigit(buf[0])) { | ~~~^~~ In order to suppress the warning, cast the argument of isdigit() to an 'unsigned char' type. Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--pre-process.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pre-process.c b/pre-process.c
index c8725dc8..d96035e2 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1426,7 +1426,7 @@ void predefine(const char *name, int weak, const char *fmt, ...)
va_end(ap);
value = __alloc_token(0);
- if (isdigit(buf[0])) {
+ if (isdigit((unsigned char)buf[0])) {
token_type(value) = TOKEN_NUMBER;
value->number = xstrdup(buf);
} else {