Skip to content

Commit

Permalink
Fix additional clang issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomix1024 committed Mar 7, 2024
1 parent 357804a commit d9de805
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion test/core/core_func_integer_bit_count.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static int pop9(unsigned x)
return static_cast<int>(y);
}

int errors;
static int errors;
static void error(int x, int y)
{
errors = errors + 1;
Expand Down
13 changes: 7 additions & 6 deletions test/core/core_func_integer_find_lsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static int ntz3(unsigned x)
if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;}
if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;}
if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;}
return n - (x & 1);
return n - static_cast<int>(x & 1);
}

static int ntz4(unsigned x)
Expand Down Expand Up @@ -74,7 +74,7 @@ static int ntz4a(unsigned x)
y = x << 8; if (y != 0) {n = n - 8; x = y;}
y = x << 4; if (y != 0) {n = n - 4; x = y;}
y = x << 2; if (y != 0) {n = n - 2; x = y;}
n = n - ((x << 1) >> 31);
n = n - static_cast<int>((x << 1) >> 31);
return n;
}

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

static int ntz7(unsigned x)
{
unsigned y, bz, b4, b3, b2, b1, b0;
unsigned y;
int bz, b4, b3, b2, b1, b0;

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

int errors;
static void error(int x, int y) {
static int errors;
static void error(unsigned x, int y) {
errors = errors + 1;
std::printf("Error for x = %08x, got %d\n", x, y);
}
Expand Down Expand Up @@ -353,7 +354,7 @@ int main()
for(std::size_t k = 0; k < Count; ++k)
for(i = 0; i < n; i += 2)
{
m = test[i+1];
m = static_cast<int>(test[i+1]);
if(m > 8)
m = 8;
if(ntz5(static_cast<char>(test[i])) != m)
Expand Down
34 changes: 17 additions & 17 deletions test/core/core_func_integer_find_msb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int nlz1a(unsigned x) {
if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
if ((x >> 28) == 0) {n = n + 4; x = x << 4;}
if ((x >> 30) == 0) {n = n + 2; x = x << 2;}
n = n - (x >> 31);
n = n - static_cast<int>(x >> 31);
return n;
}
// On basic Risc, 12 to 20 instructions.
Expand All @@ -54,7 +54,7 @@ static int nlz2(unsigned x) {
y = x >> 4; if (y != 0) {n = n - 4; x = y;}
y = x >> 2; if (y != 0) {n = n - 2; x = y;}
y = x >> 1; if (y != 0) return n - 2;
return n - x;
return n - static_cast<int>(x);
}

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

static int nlz3(int x) {
static int nlz3(unsigned x) {
int y, n;

n = 0;
y = x;
L: if (x < 0) return n;
y = static_cast<int>(x);
L: if (x > 0x7fffffff) return n;
if (y == 0) return 32 - n;
n = n + 1;
x = x << 1;
Expand All @@ -98,19 +98,19 @@ static int nlz4(unsigned x) {
n = 16 - m; // is nonzero, set n = 0 and
x = x >> m; // shift x right 16.
// Now x is of the form 0000xxxx.
y = x - 0x100; // If positions 8-15 are 0,
m = (y >> 16) & 8; // add 8 to n and shift x left 8.
n = n + m;
y = static_cast<int>(x) - 0x100;
m = (y >> 16) & 8; // If positions 8-15 are 0,
n = n + m; // add 8 to n and shift x left 8.
x = x << m;

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

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

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

int errors;
static void error(int x, int y)
static int errors;
static void error(unsigned x, int y)
{
errors = errors + 1;
std::printf("Error for x = %08x, got %d\n", x, y);
Expand Down

0 comments on commit d9de805

Please sign in to comment.