Skip to content

Commit d9de805

Browse files
committed
Fix additional clang issues
1 parent 357804a commit d9de805

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

test/core/core_func_integer_bit_count.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static int pop9(unsigned x)
176176
return static_cast<int>(y);
177177
}
178178

179-
int errors;
179+
static int errors;
180180
static void error(int x, int y)
181181
{
182182
errors = errors + 1;

test/core/core_func_integer_find_lsb.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int ntz3(unsigned x)
4545
if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;}
4646
if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;}
4747
if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;}
48-
return n - (x & 1);
48+
return n - static_cast<int>(x & 1);
4949
}
5050

5151
static int ntz4(unsigned x)
@@ -74,7 +74,7 @@ static int ntz4a(unsigned x)
7474
y = x << 8; if (y != 0) {n = n - 8; x = y;}
7575
y = x << 4; if (y != 0) {n = n - 4; x = y;}
7676
y = x << 2; if (y != 0) {n = n - 2; x = y;}
77-
n = n - ((x << 1) >> 31);
77+
n = n - static_cast<int>((x << 1) >> 31);
7878
return n;
7979
}
8080

@@ -145,7 +145,8 @@ could then all run in parallel). */
145145

146146
static int ntz7(unsigned x)
147147
{
148-
unsigned y, bz, b4, b3, b2, b1, b0;
148+
unsigned y;
149+
int bz, b4, b3, b2, b1, b0;
149150

150151
y = x & -x; // Isolate rightmost 1-bit.
151152
bz = y ? 0 : 1; // 1 if y = 0.
@@ -279,8 +280,8 @@ static int ntz11(unsigned int n) {
279280
# pragma warning(pop)
280281
#endif
281282

282-
int errors;
283-
static void error(int x, int y) {
283+
static int errors;
284+
static void error(unsigned x, int y) {
284285
errors = errors + 1;
285286
std::printf("Error for x = %08x, got %d\n", x, y);
286287
}
@@ -353,7 +354,7 @@ int main()
353354
for(std::size_t k = 0; k < Count; ++k)
354355
for(i = 0; i < n; i += 2)
355356
{
356-
m = test[i+1];
357+
m = static_cast<int>(test[i+1]);
357358
if(m > 8)
358359
m = 8;
359360
if(ntz5(static_cast<char>(test[i])) != m)

test/core/core_func_integer_find_msb.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int nlz1a(unsigned x) {
3939
if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
4040
if ((x >> 28) == 0) {n = n + 4; x = x << 4;}
4141
if ((x >> 30) == 0) {n = n + 2; x = x << 2;}
42-
n = n - (x >> 31);
42+
n = n - static_cast<int>(x >> 31);
4343
return n;
4444
}
4545
// On basic Risc, 12 to 20 instructions.
@@ -54,7 +54,7 @@ static int nlz2(unsigned x) {
5454
y = x >> 4; if (y != 0) {n = n - 4; x = y;}
5555
y = x >> 2; if (y != 0) {n = n - 2; x = y;}
5656
y = x >> 1; if (y != 0) return n - 2;
57-
return n - x;
57+
return n - static_cast<int>(x);
5858
}
5959

6060
// As above but coded as a loop for compactness:
@@ -69,15 +69,15 @@ static int nlz2a(unsigned x) {
6969
y = x >> c; if (y != 0) {n = n - c; x = y;}
7070
c = c >> 1;
7171
} while (c != 0);
72-
return n - x;
72+
return n - static_cast<int>(x);
7373
}
7474

75-
static int nlz3(int x) {
75+
static int nlz3(unsigned x) {
7676
int y, n;
7777

7878
n = 0;
79-
y = x;
80-
L: if (x < 0) return n;
79+
y = static_cast<int>(x);
80+
L: if (x > 0x7fffffff) return n;
8181
if (y == 0) return 32 - n;
8282
n = n + 1;
8383
x = x << 1;
@@ -98,19 +98,19 @@ static int nlz4(unsigned x) {
9898
n = 16 - m; // is nonzero, set n = 0 and
9999
x = x >> m; // shift x right 16.
100100
// Now x is of the form 0000xxxx.
101-
y = x - 0x100; // If positions 8-15 are 0,
102-
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
103-
n = n + m;
101+
y = static_cast<int>(x) - 0x100;
102+
m = (y >> 16) & 8; // If positions 8-15 are 0,
103+
n = n + m; // add 8 to n and shift x left 8.
104104
x = x << m;
105105

106-
y = x - 0x1000; // If positions 12-15 are 0,
107-
m = (y >> 16) & 4; // add 4 to n and shift x left 4.
108-
n = n + m;
106+
y = static_cast<int>(x) - 0x1000;
107+
m = (y >> 16) & 4; // If positions 12-15 are 0,
108+
n = n + m; // add 4 to n and shift x left 4.
109109
x = x << m;
110110

111-
y = x - 0x4000; // If positions 14-15 are 0,
112-
m = (y >> 16) & 2; // add 2 to n and shift x left 2.
113-
n = n + m;
111+
y = static_cast<int>(x) - 0x4000;
112+
m = (y >> 16) & 2; // If positions 14-15 are 0,
113+
n = n + m; // add 2 to n and shift x left 2.
114114
x = x << m;
115115

116116
y = x >> 14; // Set y = 0, 1, 2, or 3.
@@ -305,8 +305,8 @@ static int nlz10b(unsigned x)
305305
return table[x >> 26];
306306
}
307307

308-
int errors;
309-
static void error(int x, int y)
308+
static int errors;
309+
static void error(unsigned x, int y)
310310
{
311311
errors = errors + 1;
312312
std::printf("Error for x = %08x, got %d\n", x, y);

0 commit comments

Comments
 (0)