Commit 75782629 by hendrikw Committed by Corentin Wallez

Fix possible compiler errors on linux

Change-Id: Ifc45446c749690eddc406f66f144304262f04664 Reviewed-on: https://chromium-review.googlesource.com/302478Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 928cccc6
......@@ -6,6 +6,8 @@
// This file is automatically generated.
#include "common/mathutil.h"
namespace gl
{
......@@ -2197,7 +2199,7 @@ const static unsigned g_offset[64] = {
float float16ToFloat32(unsigned short h)
{
unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10];
return *(float*) &i32;
return bitCast<float>(i32);
}
}
......@@ -7,6 +7,8 @@
# point numbers to 32-bit.
# It is based on ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf.
#include "common/mathutil.h"
def convertMantissa(i):
if i == 0:
return 0
......@@ -72,7 +74,7 @@ print "};\n"
print """float float16ToFloat32(unsigned short h)
{
unsigned i32 = g_mantissa[g_offset[h >> 10] + (h & 0x3ff)] + g_exponent[h >> 10];
return *(float*) &i32;
return bitCast<float>(i32);
}
}
"""
......@@ -52,7 +52,7 @@ unsigned int convertRGBFloatsTo999E5(float red, float green, float blue)
output.B = static_cast<unsigned int>(floor((blue_c / (pow(2.0f, exp_s - g_sharedexp_bias - g_sharedexp_mantissabits))) + 0.5f));
output.E = exp_s;
return *reinterpret_cast<unsigned int*>(&output);
return bitCast<unsigned int>(output);
}
void convert999E5toRGBFloats(unsigned int input, float *red, float *green, float *blue)
......
......@@ -151,7 +151,7 @@ destType bitCast(const sourceType &source)
inline unsigned short float32ToFloat16(float fp32)
{
unsigned int fp32i = (unsigned int&)fp32;
unsigned int fp32i = bitCast<unsigned int>(fp32);
unsigned int sign = (fp32i & 0x80000000) >> 16;
unsigned int abs = fp32i & 0x7FFFFFFF;
......
......@@ -223,9 +223,9 @@ bool TStructure::containsSamplers() const
return false;
}
TString TFieldListCollection::buildMangledName() const
TString TFieldListCollection::buildMangledName(const TString &mangledNamePrefix) const
{
TString mangledName(mangledNamePrefix());
TString mangledName(mangledNamePrefix);
mangledName += *mName;
for (size_t i = 0; i < mFields->size(); ++i)
{
......
......@@ -73,12 +73,6 @@ class TFieldListCollection : angle::NonCopyable
return *mFields;
}
const TString &mangledName() const
{
if (mMangledName.empty())
mMangledName = buildMangledName();
return mMangledName;
}
size_t objectSize() const
{
if (mObjectSize == 0)
......@@ -93,9 +87,8 @@ class TFieldListCollection : angle::NonCopyable
mObjectSize(0)
{
}
TString buildMangledName() const;
TString buildMangledName(const TString &mangledNamePrefix) const;
size_t calculateObjectSize() const;
virtual TString mangledNamePrefix() const = 0;
const TString *mName;
TFieldList *mFields;
......@@ -150,6 +143,13 @@ class TStructure : public TFieldListCollection
return mAtGlobalScope;
}
const TString &mangledName() const
{
if (mMangledName.empty())
mMangledName = buildMangledName("struct-");
return mMangledName;
}
private:
// TODO(zmo): Find a way to get rid of the const_cast in function
// setName(). At the moment keep this function private so only
......@@ -161,7 +161,6 @@ class TStructure : public TFieldListCollection
*mutableName = name;
}
TString mangledNamePrefix() const override { return "struct-"; }
int calculateDeepestNesting() const;
mutable int mDeepestNesting;
......@@ -207,10 +206,14 @@ class TInterfaceBlock : public TFieldListCollection
{
return mMatrixPacking;
}
const TString &mangledName() const
{
if (mMangledName.empty())
mMangledName = buildMangledName("iblock-");
return mMangledName;
}
private:
TString mangledNamePrefix() const override { return "iblock-"; }
const TString *mInstanceName; // for interface block instance names
int mArraySize; // 0 if not an array
TLayoutBlockStorage mBlockStorage;
......
......@@ -50,6 +50,7 @@ class COMPILER_EXPORT BlockLayoutEncoder
{
public:
BlockLayoutEncoder();
virtual ~BlockLayoutEncoder() {}
BlockMemberInfo encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
......
......@@ -4,8 +4,6 @@
// found in the LICENSE file.
//
#pragma warning(disable: 4718)
#include "compiler/translator/depgraph/DependencyGraph.h"
#include "compiler/translator/depgraph/DependencyGraphBuilder.h"
......
......@@ -191,6 +191,7 @@ private:
class TDependencyGraphTraverser : angle::NonCopyable {
public:
TDependencyGraphTraverser() : mDepth(0) {}
virtual ~TDependencyGraphTraverser() {}
virtual void visitSymbol(TGraphSymbol* symbol) {};
virtual void visitArgument(TGraphArgument* selection) {};
......
......@@ -41,6 +41,7 @@ class GetVariableTraverser : angle::NonCopyable
{
public:
GetVariableTraverser(const TSymbolTable &symbolTable);
virtual ~GetVariableTraverser() {}
template <typename VarT>
void traverse(const TType &type, const TString &name, std::vector<VarT> *output);
......
......@@ -15,15 +15,15 @@
namespace egl
{
class AttributeMap
class AttributeMap final
{
public:
AttributeMap();
explicit AttributeMap(const EGLint *attributes);
virtual void insert(EGLint key, EGLint value);
virtual bool contains(EGLint key) const;
virtual EGLint get(EGLint key, EGLint defaultValue) const;
void insert(EGLint key, EGLint value);
bool contains(EGLint key) const;
EGLint get(EGLint key, EGLint defaultValue) const;
typedef std::map<EGLint, EGLint>::const_iterator const_iterator;
......
......@@ -47,7 +47,7 @@ class BinaryInputStream : angle::NonCopyable
template <class IntT>
IntT readInt()
{
int value;
int value = 0;
read(&value);
return static_cast<IntT>(value);
}
......@@ -60,7 +60,7 @@ class BinaryInputStream : angle::NonCopyable
bool readBool()
{
int value;
int value = 0;
read(&value);
return (value > 0);
}
......
......@@ -146,6 +146,7 @@ class FramebufferAttachmentObject
{
public:
FramebufferAttachmentObject() {}
virtual ~FramebufferAttachmentObject() {}
virtual GLsizei getAttachmentWidth(const FramebufferAttachment::Target &target) const = 0;
virtual GLsizei getAttachmentHeight(const FramebufferAttachment::Target &target) const = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment