aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-01-03 09:12:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-01-03 09:12:17 -0300
commit8dd2c912d299b84566c6f6d659336edfa9b18e9b (patch)
treef4fda0bf84c1d52ceba86cbf8ecaeb42241ad6c0
parent05ac2409ee9ea312124bf71dcc93711d652e265b (diff)
downloadlua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.tar.gz
lua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.tar.bz2
lua-8dd2c912d299b84566c6f6d659336edfa9b18e9b.zip
Detail
Warnings with clang when using long double for Lua floats.
-rw-r--r--lcode.c2
-rw-r--r--lmathlib.c4
-rw-r--r--lobject.c10
3 files changed, 8 insertions, 8 deletions
diff --git a/lcode.c b/lcode.c
index 9cba24f9..06425a1d 100644
--- a/lcode.c
+++ b/lcode.c
@@ -607,7 +607,7 @@ static int luaK_numberK (FuncState *fs, lua_Number r) {
607 return addk(fs, &o, &o); /* use number itself as key */ 607 return addk(fs, &o, &o); /* use number itself as key */
608 else { /* must build an alternative key */ 608 else { /* must build an alternative key */
609 const int nbm = l_floatatt(MANT_DIG); 609 const int nbm = l_floatatt(MANT_DIG);
610 const lua_Number q = l_mathop(ldexp)(1.0, -nbm + 1); 610 const lua_Number q = l_mathop(ldexp)(l_mathop(1.0), -nbm + 1);
611 const lua_Number k = (ik == 0) ? q : r + r*q; /* new key */ 611 const lua_Number k = (ik == 0) ? q : r + r*q; /* new key */
612 TValue kv; 612 TValue kv;
613 setfltvalue(&kv, k); 613 setfltvalue(&kv, k);
diff --git a/lmathlib.c b/lmathlib.c
index 5f5983a4..e0c61a16 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -475,7 +475,7 @@ static lua_Number I2d (Rand64 x) {
475 475
476/* 2^(-FIGS) = 1.0 / 2^30 / 2^3 / 2^(FIGS-33) */ 476/* 2^(-FIGS) = 1.0 / 2^30 / 2^3 / 2^(FIGS-33) */
477#define scaleFIG \ 477#define scaleFIG \
478 ((lua_Number)1.0 / (UONE << 30) / 8.0 / (UONE << (FIGS - 33))) 478 (l_mathop(1.0) / (UONE << 30) / l_mathop(8.0) / (UONE << (FIGS - 33)))
479 479
480/* 480/*
481** use FIGS - 32 bits from lower half, throwing out the other 481** use FIGS - 32 bits from lower half, throwing out the other
@@ -486,7 +486,7 @@ static lua_Number I2d (Rand64 x) {
486/* 486/*
487** higher 32 bits go after those (FIGS - 32) bits: shiftHI = 2^(FIGS - 32) 487** higher 32 bits go after those (FIGS - 32) bits: shiftHI = 2^(FIGS - 32)
488*/ 488*/
489#define shiftHI ((lua_Number)(UONE << (FIGS - 33)) * 2.0) 489#define shiftHI ((lua_Number)(UONE << (FIGS - 33)) * l_mathop(2.0))
490 490
491 491
492static lua_Number I2d (Rand64 x) { 492static lua_Number I2d (Rand64 x) {
diff --git a/lobject.c b/lobject.c
index 0e504be0..301aa900 100644
--- a/lobject.c
+++ b/lobject.c
@@ -164,7 +164,7 @@ static int isneg (const char **s) {
164*/ 164*/
165static lua_Number lua_strx2number (const char *s, char **endptr) { 165static lua_Number lua_strx2number (const char *s, char **endptr) {
166 int dot = lua_getlocaledecpoint(); 166 int dot = lua_getlocaledecpoint();
167 lua_Number r = 0.0; /* result (accumulator) */ 167 lua_Number r = l_mathop(0.0); /* result (accumulator) */
168 int sigdig = 0; /* number of significant digits */ 168 int sigdig = 0; /* number of significant digits */
169 int nosigdig = 0; /* number of non-significant digits */ 169 int nosigdig = 0; /* number of non-significant digits */
170 int e = 0; /* exponent correction */ 170 int e = 0; /* exponent correction */
@@ -174,7 +174,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
174 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ 174 while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */
175 neg = isneg(&s); /* check sign */ 175 neg = isneg(&s); /* check sign */
176 if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */ 176 if (!(*s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))) /* check '0x' */
177 return 0.0; /* invalid format (no '0x') */ 177 return l_mathop(0.0); /* invalid format (no '0x') */
178 for (s += 2; ; s++) { /* skip '0x' and read numeral */ 178 for (s += 2; ; s++) { /* skip '0x' and read numeral */
179 if (*s == dot) { 179 if (*s == dot) {
180 if (hasdot) break; /* second dot? stop loop */ 180 if (hasdot) break; /* second dot? stop loop */
@@ -184,14 +184,14 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
184 if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */ 184 if (sigdig == 0 && *s == '0') /* non-significant digit (zero)? */
185 nosigdig++; 185 nosigdig++;
186 else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */ 186 else if (++sigdig <= MAXSIGDIG) /* can read it without overflow? */
187 r = (r * cast_num(16.0)) + luaO_hexavalue(*s); 187 r = (r * l_mathop(16.0)) + luaO_hexavalue(*s);
188 else e++; /* too many digits; ignore, but still count for exponent */ 188 else e++; /* too many digits; ignore, but still count for exponent */
189 if (hasdot) e--; /* decimal digit? correct exponent */ 189 if (hasdot) e--; /* decimal digit? correct exponent */
190 } 190 }
191 else break; /* neither a dot nor a digit */ 191 else break; /* neither a dot nor a digit */
192 } 192 }
193 if (nosigdig + sigdig == 0) /* no digits? */ 193 if (nosigdig + sigdig == 0) /* no digits? */
194 return 0.0; /* invalid format */ 194 return l_mathop(0.0); /* invalid format */
195 *endptr = cast_charp(s); /* valid up to here */ 195 *endptr = cast_charp(s); /* valid up to here */
196 e *= 4; /* each digit multiplies/divides value by 2^4 */ 196 e *= 4; /* each digit multiplies/divides value by 2^4 */
197 if (*s == 'p' || *s == 'P') { /* exponent part? */ 197 if (*s == 'p' || *s == 'P') { /* exponent part? */
@@ -200,7 +200,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) {
200 s++; /* skip 'p' */ 200 s++; /* skip 'p' */
201 neg1 = isneg(&s); /* sign */ 201 neg1 = isneg(&s); /* sign */
202 if (!lisdigit(cast_uchar(*s))) 202 if (!lisdigit(cast_uchar(*s)))
203 return 0.0; /* invalid; must have at least one digit */ 203 return l_mathop(0.0); /* invalid; must have at least one digit */
204 while (lisdigit(cast_uchar(*s))) /* read exponent */ 204 while (lisdigit(cast_uchar(*s))) /* read exponent */
205 exp1 = exp1 * 10 + *(s++) - '0'; 205 exp1 = exp1 * 10 + *(s++) - '0';
206 if (neg1) exp1 = -exp1; 206 if (neg1) exp1 = -exp1;