Skip to content

Commit

Permalink
Fix required for build with RelWithDebInfo (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Jun 28, 2018
1 parent 2837c15 commit ea096a5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/CLR/Core/CLR_RT_Interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,20 @@ unsigned int &Interop_Marshal_GetField_UINT32( CLR_RT_HeapBlock *pThis, unsigned
return pThis[ fieldIndex ].NumericByRef().u4;
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif

unsigned __int64 &Interop_Marshal_GetField_UINT64( CLR_RT_HeapBlock *pThis, unsigned int fieldIndex )
{
return (unsigned __int64 &)pThis[ fieldIndex ].NumericByRef().u8;
}

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

char &Interop_Marshal_GetField_CHAR( CLR_RT_HeapBlock *pThis, unsigned int fieldIndex )
{
return (char &)pThis[ fieldIndex ].NumericByRef().s1;
Expand All @@ -722,11 +731,20 @@ signed int &Interop_Marshal_GetField_INT32( CLR_RT_HeapBlock *pThis, unsigned i
return pThis[ fieldIndex ].NumericByRef().s4;
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif

signed __int64 &Interop_Marshal_GetField_INT64( CLR_RT_HeapBlock *pThis, unsigned int fieldIndex )
{
return (signed __int64 &)pThis[ fieldIndex ].NumericByRef().s8;
}

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

//----------------- Float point types - float and double
#if !defined(NANOCLR_EMULATED_FLOATINGPOINT)

Expand All @@ -735,10 +753,20 @@ float &Interop_Marshal_GetField_float( CLR_RT_HeapBlock *pThis, unsigned int fi
return pThis[ fieldIndex ].NumericByRef().r4;
}

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif

double &Interop_Marshal_GetField_double( CLR_RT_HeapBlock *pThis, unsigned int fieldIndex )
{
return (double &)pThis[ fieldIndex ].NumericByRef().r8;
}

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

#else

signed int &Interop_Marshal_GetField_float( CLR_RT_HeapBlock *pThis, unsigned int fieldIndex )
Expand Down
11 changes: 11 additions & 0 deletions src/CLR/Include/nanoCLR_Runtime__HeapBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,18 @@ struct CLR_RT_HeapBlock
#if !defined(NANOCLR_EMULATED_FLOATINGPOINT)
void SetFloat ( const float num ) { CLR_RT_HEAPBLOCK_ASSIGN_FLOAT32 (DATATYPE_R4, num); }
void SetDouble ( const double num ) { CLR_RT_HEAPBLOCK_ASSIGN_FLOAT64 (DATATYPE_R8, num); }

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif

void SetFloatFromBits ( const CLR_UINT32 num ) { SetFloat ( *(const float *)&num ); }

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

void SetDoubleFromBits( const CLR_UINT64& num ) { SetDouble( *(const double*)&num ); }
#else
void SetFloat ( const CLR_INT32 num ) { CLR_RT_HEAPBLOCK_ASSIGN_FLOAT32 (DATATYPE_R4, num); }
Expand Down
10 changes: 10 additions & 0 deletions src/CLR/Include/nanoCLR_Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,12 @@ struct CLR_RECORD_METHODDEF
CLR_SIG sig; // TBL_Signatures
};

#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
// pragma required here because compiler is not too happy with the cast to CLR_UINT32* from a CLR_UINT16 variable

struct CLR_RECORD_ATTRIBUTE
{
CLR_UINT16 ownerType; // one of TBL_TypeDef, TBL_MethodDef, or TBL_FieldDef.
Expand All @@ -1062,6 +1068,10 @@ struct CLR_RECORD_ATTRIBUTE
CLR_UINT32 Key() const { return *(CLR_UINT32*)&ownerType; }
};

#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif

struct CLR_RECORD_TYPESPEC
{
CLR_SIG sig; // TBL_Signatures
Expand Down

0 comments on commit ea096a5

Please sign in to comment.