diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-14 16:24:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-01-14 16:24:46 -0300 |
commit | 3cdd49c94a8feed94853ba3a6adaa556fb34fd8d (patch) | |
tree | 1f552c966d1fb5f5c23e956e6d98679f02a558b3 | |
parent | 10e931da82268a9d190c17a9bdb9b1a4b48c2947 (diff) | |
download | lua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.tar.gz lua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.tar.bz2 lua-3cdd49c94a8feed94853ba3a6adaa556fb34fd8d.zip |
Fixed conversion warnings from clang
Plus some other details. (Option '-Wuninitialized' was removed from
the makefile because it is already enabled by -Wall.)
-rw-r--r-- | lcode.c | 2 | ||||
-rw-r--r-- | llex.c | 7 | ||||
-rw-r--r-- | lmem.h | 4 | ||||
-rw-r--r-- | lobject.c | 1 | ||||
-rw-r--r-- | lparser.c | 2 | ||||
-rw-r--r-- | ltable.c | 4 | ||||
-rw-r--r-- | makefile | 1 | ||||
-rw-r--r-- | manual/manual.of | 7 | ||||
-rw-r--r-- | testes/libs/makefile | 2 |
9 files changed, 17 insertions, 13 deletions
@@ -1439,7 +1439,7 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, | |||
1439 | e1->u.info = pc; | 1439 | e1->u.info = pc; |
1440 | e1->k = VRELOC; /* all those operations are relocatable */ | 1440 | e1->k = VRELOC; /* all those operations are relocatable */ |
1441 | luaK_fixline(fs, line); | 1441 | luaK_fixline(fs, line); |
1442 | luaK_codeABCk(fs, mmop, v1, v2, event, flip); /* to call metamethod */ | 1442 | luaK_codeABCk(fs, mmop, v1, v2, cast_int(event), flip); /* metamethod */ |
1443 | luaK_fixline(fs, line); | 1443 | luaK_fixline(fs, line); |
1444 | } | 1444 | } |
1445 | 1445 | ||
@@ -349,9 +349,14 @@ static int readhexaesc (LexState *ls) { | |||
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | /* | ||
353 | ** When reading a UTF-8 escape sequence, save everything to the buffer | ||
354 | ** for error reporting in case of errors; 'i' counts the number of | ||
355 | ** saved characters, so that they can be removed if case of success. | ||
356 | */ | ||
352 | static unsigned long readutf8esc (LexState *ls) { | 357 | static unsigned long readutf8esc (LexState *ls) { |
353 | unsigned long r; | 358 | unsigned long r; |
354 | int i = 4; /* chars to be removed: '\', 'u', '{', and first digit */ | 359 | int i = 4; /* number of chars to be removed: start with #"\u{X" */ |
355 | save_and_next(ls); /* skip 'u' */ | 360 | save_and_next(ls); /* skip 'u' */ |
356 | esccheck(ls, ls->current == '{', "missing '{'"); | 361 | esccheck(ls, ls->current == '{', "missing '{'"); |
357 | r = cast_ulong(gethexa(ls)); /* must have at least one digit */ | 362 | r = cast_ulong(gethexa(ls)); /* must have at least one digit */ |
@@ -39,11 +39,11 @@ | |||
39 | ** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that | 39 | ** Computes the minimum between 'n' and 'MAX_SIZET/sizeof(t)', so that |
40 | ** the result is not larger than 'n' and cannot overflow a 'size_t' | 40 | ** the result is not larger than 'n' and cannot overflow a 'size_t' |
41 | ** when multiplied by the size of type 't'. (Assumes that 'n' is an | 41 | ** when multiplied by the size of type 't'. (Assumes that 'n' is an |
42 | ** 'int' or 'unsigned int' and that 'int' is not larger than 'size_t'.) | 42 | ** 'int' and that 'int' is not larger than 'size_t'.) |
43 | */ | 43 | */ |
44 | #define luaM_limitN(n,t) \ | 44 | #define luaM_limitN(n,t) \ |
45 | ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ | 45 | ((cast_sizet(n) <= MAX_SIZET/sizeof(t)) ? (n) : \ |
46 | cast_uint((MAX_SIZET/sizeof(t)))) | 46 | cast_int((MAX_SIZET/sizeof(t)))) |
47 | 47 | ||
48 | 48 | ||
49 | /* | 49 | /* |
@@ -194,6 +194,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2, | |||
194 | 194 | ||
195 | 195 | ||
196 | lu_byte luaO_hexavalue (int c) { | 196 | lu_byte luaO_hexavalue (int c) { |
197 | lua_assert(lisxdigit(c)); | ||
197 | if (lisdigit(c)) return cast_byte(c - '0'); | 198 | if (lisdigit(c)) return cast_byte(c - '0'); |
198 | else return cast_byte((ltolower(c) - 'a') + 10); | 199 | else return cast_byte((ltolower(c) - 'a') + 10); |
199 | } | 200 | } |
@@ -405,7 +405,7 @@ static int searchvar (FuncState *fs, TString *n, expdesc *var) { | |||
405 | init_exp(var, VCONST, fs->firstlocal + i); | 405 | init_exp(var, VCONST, fs->firstlocal + i); |
406 | else /* real variable */ | 406 | else /* real variable */ |
407 | init_var(fs, var, i); | 407 | init_var(fs, var, i); |
408 | return var->k; | 408 | return cast_int(var->k); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | return -1; /* not found */ | 411 | return -1; /* not found */ |
@@ -96,7 +96,7 @@ typedef union { | |||
96 | ** between 2^MAXHBITS and the maximum size such that, measured in bytes, | 96 | ** between 2^MAXHBITS and the maximum size such that, measured in bytes, |
97 | ** it fits in a 'size_t'. | 97 | ** it fits in a 'size_t'. |
98 | */ | 98 | */ |
99 | #define MAXHSIZE luaM_limitN(1u << MAXHBITS, Node) | 99 | #define MAXHSIZE luaM_limitN(1 << MAXHBITS, Node) |
100 | 100 | ||
101 | 101 | ||
102 | /* | 102 | /* |
@@ -598,7 +598,7 @@ static void setnodevector (lua_State *L, Table *t, unsigned size) { | |||
598 | else { | 598 | else { |
599 | int i; | 599 | int i; |
600 | int lsize = luaO_ceillog2(size); | 600 | int lsize = luaO_ceillog2(size); |
601 | if (lsize > MAXHBITS || (1u << lsize) > MAXHSIZE) | 601 | if (lsize > MAXHBITS || (1 << lsize) > MAXHSIZE) |
602 | luaG_runerror(L, "table overflow"); | 602 | luaG_runerror(L, "table overflow"); |
603 | size = twoto(lsize); | 603 | size = twoto(lsize); |
604 | if (lsize < LIMFORLAST) /* no 'lastfree' field? */ | 604 | if (lsize < LIMFORLAST) /* no 'lastfree' field? */ |
@@ -15,7 +15,6 @@ CWARNSCPP= \ | |||
15 | -Wdouble-promotion \ | 15 | -Wdouble-promotion \ |
16 | -Wmissing-declarations \ | 16 | -Wmissing-declarations \ |
17 | -Wconversion \ | 17 | -Wconversion \ |
18 | -Wuninitialized \ | ||
19 | -Wstrict-overflow=2 \ | 18 | -Wstrict-overflow=2 \ |
20 | # the next warnings might be useful sometimes, | 19 | # the next warnings might be useful sometimes, |
21 | # but usually they generate too much noise | 20 | # but usually they generate too much noise |
diff --git a/manual/manual.of b/manual/manual.of index bb95148a..77e37de3 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -3848,7 +3848,6 @@ or zero if the value at @id{idx} is not a number. | |||
3848 | 3848 | ||
3849 | Calls a function (or a callable object) in protected mode. | 3849 | Calls a function (or a callable object) in protected mode. |
3850 | 3850 | ||
3851 | |||
3852 | Both @id{nargs} and @id{nresults} have the same meaning as | 3851 | Both @id{nargs} and @id{nresults} have the same meaning as |
3853 | in @Lid{lua_call}. | 3852 | in @Lid{lua_call}. |
3854 | If there are no errors during the call, | 3853 | If there are no errors during the call, |
@@ -3998,9 +3997,9 @@ Lua will call @id{falloc} before raising the error. | |||
3998 | Pushes onto the stack a formatted string | 3997 | Pushes onto the stack a formatted string |
3999 | and returns a pointer to this string @see{constchar}. | 3998 | and returns a pointer to this string @see{constchar}. |
4000 | The result is a copy of @id{fmt} with | 3999 | The result is a copy of @id{fmt} with |
4001 | each @emph{conversion specifier} replaced by its respective | 4000 | each @emph{conversion specifier} replaced by a string representation |
4002 | extra argument. | 4001 | of its respective extra argument. |
4003 | A conversion specifier can be | 4002 | A conversion specifier (and its corresponding extra argument) can be |
4004 | @Char{%%} (inserts the character @Char{%}), | 4003 | @Char{%%} (inserts the character @Char{%}), |
4005 | @Char{%s} (inserts a zero-terminated string, with no size restrictions), | 4004 | @Char{%s} (inserts a zero-terminated string, with no size restrictions), |
4006 | @Char{%f} (inserts a @Lid{lua_Number}), | 4005 | @Char{%f} (inserts a @Lid{lua_Number}), |
diff --git a/testes/libs/makefile b/testes/libs/makefile index 9c0c4e3f..4e7f965e 100644 --- a/testes/libs/makefile +++ b/testes/libs/makefile | |||
@@ -5,7 +5,7 @@ LUA_DIR = ../../ | |||
5 | CC = gcc | 5 | CC = gcc |
6 | 6 | ||
7 | # compilation should generate Dynamic-Link Libraries | 7 | # compilation should generate Dynamic-Link Libraries |
8 | CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared | 8 | CFLAGS = -Wall -std=c99 -O2 -I$(LUA_DIR) -fPIC -shared |
9 | 9 | ||
10 | # libraries used by the tests | 10 | # libraries used by the tests |
11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so | 11 | all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so |