Fixing some C++ conversion errors.
* Implicit conversion from int to bool.
* Implicit conversion from size_t to uint32_t.
* Implicit conversion from char* to uint8_t.
Adding no-op color operators so unhandled platforms can still link.
const char* dec = "0123456789";
const char* lower = "abcdef";
const char* upper = "ABCDEF";
- if (auto p = strchr(dec, character)) return p - dec;
- if (auto p = strchr(lower, character)) return p - lower + 0xa;
- if (auto p = strchr(upper, character)) return p - upper + 0xa;
+ if (auto p = strchr(dec, character)) {
+ return static_cast<uint8_t>(p - dec);
+ } else if (auto p = strchr(lower, character)) {
+ return static_cast<uint8_t>(p - lower + 0xa);
+ } else if (auto p = strchr(upper, character)) {
+ return static_cast<uint8_t>(p - upper + 0xa);
+ }
assert(false && "This was called with a non-hex character");
return 0;
}
} // namespace libspirv
+#else
+namespace libspirv {
+
+clr::reset::operator const char*() { return ""; }
+
+clr::grey::operator const char*() { return ""; }
+
+clr::red::operator const char*() { return ""; }
+
+clr::green::operator const char*() { return ""; }
+
+clr::yellow::operator const char*() { return ""; }
+
+clr::blue::operator const char*() { return ""; }
+
+} // namespace libspirv
#endif
"Invalid immediate integer: !"))
return error;
context->binaryEncodeU32(parse_result, pInst);
- context->seekForward(strlen(text));
+ context->seekForward(static_cast<uint32_t>(strlen(text)));
return SPV_SUCCESS;
}
// Hex values are a bit special. They decode as unsigned values, but
// may represent a negative number. In this case, the overflow bits
// should be zero.
- failed = (value & overflow_mask);
+ failed = (value & overflow_mask) != 0;
} else {
const uint64_t value_as_u64 = static_cast<uint64_t>(value);
// Check overflow in the ordinary case.
} else if (5 == constInst->words.size()) {
uint64_t value =
constInst->words[3] | ((uint64_t)constInst->words[4]) << 32;
- bool signedness = constResultType->second.inst->words[3];
+ bool signedness = constResultType->second.inst->words[3] != 0;
if (signedness) {
spvCheck(1 > (int64_t)value, DIAG(lengthIndex)
<< "OpTypeArray Length <id> '"
<< "' is not a composite type.";
return false);
- uint32_t constituentCount = inst->words.size() - 3;
+ auto constituentCount = inst->words.size() - 3;
switch (resultType->second.opcode) {
case SpvOpTypeVector: {
auto componentCount = resultType->second.inst->words[3];
}
} break;
case SpvOpTypeStruct: {
- uint32_t memberCount = resultType->second.inst->words.size() - 2;
+ auto memberCount = resultType->second.inst->words.size() - 2;
spvCheck(memberCount != constituentCount,
DIAG(resultTypeIndex)
<< "OpConstantComposite Constituent <id> '"