Fix warnings/errors for strict aliasing & function prototypes
This fixes various issues related to gcc's strict-aliasing warning by using unions. It also handles various cases hit with gcc's missing-declarations warning.
This commit is contained in:
parent
0967748fbc
commit
18b637f9dc
11 changed files with 39 additions and 17 deletions
8
SPIRV/SpvBuilder.cpp
Executable file → Normal file
8
SPIRV/SpvBuilder.cpp
Executable file → Normal file
|
|
@ -698,7 +698,9 @@ Id Builder::makeFloatConstant(float f, bool specConstant)
|
|||
{
|
||||
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||
Id typeId = makeFloatType(32);
|
||||
unsigned value = *(unsigned int*)&f;
|
||||
union { float fl; unsigned int ui; } u;
|
||||
u.fl = f;
|
||||
unsigned value = u.ui;
|
||||
|
||||
// See if we already made it. Applies only to regular constants, because specialization constants
|
||||
// must remain distinct for the purpose of applying a SpecId decoration.
|
||||
|
|
@ -721,7 +723,9 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
|
|||
{
|
||||
Op opcode = specConstant ? OpSpecConstant : OpConstant;
|
||||
Id typeId = makeFloatType(64);
|
||||
unsigned long long value = *(unsigned long long*)&d;
|
||||
union { double db; unsigned long long ull; } u;
|
||||
u.db = d;
|
||||
unsigned long long value = u.ull;
|
||||
unsigned op1 = value & 0xFFFFFFFF;
|
||||
unsigned op2 = value >> 32;
|
||||
|
||||
|
|
|
|||
4
SPIRV/disassemble.cpp
Executable file → Normal file
4
SPIRV/disassemble.cpp
Executable file → Normal file
|
|
@ -59,7 +59,7 @@ const char* GlslStd450DebugNames[spv::GLSLstd450Count];
|
|||
|
||||
namespace spv {
|
||||
|
||||
void Kill(std::ostream& out, const char* message)
|
||||
static void Kill(std::ostream& out, const char* message)
|
||||
{
|
||||
out << std::endl << "Disassembly failed: " << message << std::endl;
|
||||
exit(1);
|
||||
|
|
@ -481,7 +481,7 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
|
|||
return;
|
||||
}
|
||||
|
||||
void GLSLstd450GetDebugNames(const char** names)
|
||||
static void GLSLstd450GetDebugNames(const char** names)
|
||||
{
|
||||
for (int i = 0; i < GLSLstd450Count; ++i)
|
||||
names[i] = "Unknown";
|
||||
|
|
|
|||
3
SPIRV/doc.h
Executable file → Normal file
3
SPIRV/doc.h
Executable file → Normal file
|
|
@ -67,6 +67,8 @@ const char* SamplerFilterModeString(int);
|
|||
const char* ImageFormatString(int);
|
||||
const char* ImageChannelOrderString(int);
|
||||
const char* ImageChannelTypeString(int);
|
||||
const char* ImageChannelDataTypeString(int type);
|
||||
const char* ImageOperandsString(int format);
|
||||
const char* ImageOperands(int);
|
||||
const char* FPFastMathString(int);
|
||||
const char* FPRoundingModeString(int);
|
||||
|
|
@ -81,6 +83,7 @@ const char* KernelEnqueueFlagsString(int);
|
|||
const char* KernelProfilingInfoString(int);
|
||||
const char* CapabilityString(int);
|
||||
const char* OpcodeString(int);
|
||||
const char* ScopeString(int mem);
|
||||
|
||||
// For grouping opcodes into subsections
|
||||
enum OpcodeClass {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue