Skip to content

Commit

Permalink
Minor tweaks for gcc (dotnet/coreclr#24391)
Browse files Browse the repository at this point in the history
* Fix a consistency check condition
Following error is reported by gcc 8 with debug configuration:

> error: enum constant in boolean context [-Werror=int-in-bool-context]

* Apply -Wno-register only to CXX flags
gcc 8 errors out like this:

```
[ 96%] Building C object src/ilasm/CMakeFiles/ilasm.dir/__/__/version.c.o
cc1: error: command line option -Wno-register is valid for C++/ObjC++ but not for C [-Werror]
cc1: all warnings being treated as errors
src/ilasm/CMakeFiles/ilasm.dir/build.make:254: recipe for target 'src/ilasm/CMakeFiles/ilasm.dir/__/__/version.c.o' failed
make[2]: *** [src/ilasm/CMakeFiles/ilasm.dir/__/__/version.c.o] Error 1
CMakeFiles/Makefile2:5710: recipe for target 'src/ilasm/CMakeFiles/ilasm.dir/all' failed
make[1]: *** [src/ilasm/CMakeFiles/ilasm.dir/all] Error 2
```

* Remove extra parantheses from variable declaration
gcc 8 reports:

> error: unnecessary parentheses in declaration of m_HashedModules [-Werror=parentheses]

* Use macro instead of const in C
gcc throws:

> error: variably modified collatorsPerOption at file scope
     UCollator* collatorsPerOption[CompareOptionsMask + 1];

* Cast to uintptr_t before (32-bit) DWORD
gcc error was:

> error: cast from LPCWSTR {aka const char16_t*} to DWORD {aka unsigned int} loses precision [-fpermissive]


Commit migrated from dotnet/coreclr@068aa8b
  • Loading branch information
am11 authored and jkotas committed May 4, 2019
1 parent 8da705f commit 18a1154
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ c_static_assert_msg(UCOL_LESS < 0, "managed side requires less than zero for a <
c_static_assert_msg(UCOL_GREATER > 0, "managed side requires greater than zero for a > b");
c_static_assert_msg(USEARCH_DONE == -1, "managed side requires -1 for not found");

const int32_t CompareOptionsIgnoreCase = 0x1;
const int32_t CompareOptionsIgnoreNonSpace = 0x2;
const int32_t CompareOptionsIgnoreSymbols = 0x4;
const int32_t CompareOptionsIgnoreKanaType = 0x8;
const int32_t CompareOptionsIgnoreWidth = 0x10;
const int32_t CompareOptionsMask = 0x1f;
// const int32_t CompareOptionsStringSort = 0x20000000;
#define CompareOptionsIgnoreCase 0x1
#define CompareOptionsIgnoreNonSpace 0x2
#define CompareOptionsIgnoreSymbols 0x4
#define CompareOptionsIgnoreKanaType 0x8
#define CompareOptionsIgnoreWidth 0x10
#define CompareOptionsMask 0x1f
// #define CompareOptionsStringSort 0x20000000
// ICU's default is to use "StringSort", i.e. nonalphanumeric symbols come before alphanumeric.
// When StringSort is not specified (.NET's default), the sort order will be different between
// Windows and Unix platforms. The nonalphanumeric symbols will come after alphanumeric
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/src/ilasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ if(CLR_CMAKE_PLATFORM_UNIX)
# Need generate a right form of asmparse.cpp to avoid the following options.
# Clang also produces a bad-codegen on this prebuilt file with optimization.
# https://github.com/dotnet/coreclr/issues/2305
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
add_compile_options(-Wno-register)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor -Wno-register")
add_compile_options(-Wno-array-bounds)
add_compile_options(-Wno-unused-label)
set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" )
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/md/compiler/mdutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

LOADEDMODULES * LOADEDMODULES::s_pLoadedModules = NULL;
UTSemReadWrite * LOADEDMODULES::m_pSemReadWrite = NULL;
RegMeta * (LOADEDMODULES::m_HashedModules[LOADEDMODULES_HASH_SIZE]) = { NULL };
RegMeta * LOADEDMODULES::m_HashedModules[LOADEDMODULES_HASH_SIZE] = { NULL };

//*****************************************************************************
// Hash a file name.
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/md/compiler/mdutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class LOADEDMODULES : public CDynArray<RegMeta *>

// Named for locking macros - see code:LOCKREAD
static UTSemReadWrite * m_pSemReadWrite;
static RegMeta *(m_HashedModules[LOADEDMODULES_HASH_SIZE]);
static RegMeta *m_HashedModules[LOADEDMODULES_HASH_SIZE];

static ULONG HashFileName(LPCWSTR szName);

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/utilcode/pedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ bool EnumerateLangIDs(const PEDecoder *pDecoder, DWORD rvaOfResourceSection, boo

BYTE *pData = (BYTE*)pDecoder->GetRvaData(resourceDataRva);

return state->langIDcallback(state->nameName, state->nameType, (DWORD)name, pData, cbData, state->context);
return state->langIDcallback(state->nameName, state->nameType, (DWORD)(uintptr_t)name, pData, cbData, state->context);
}


Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/stubgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ bool ILCodeStream::IsSupportedInstruction(ILInstrEnum instr)
LIMITED_METHOD_CONTRACT;

CONSISTENCY_CHECK_MSG(instr != CEE_SWITCH, "CEE_SWITCH is not supported currently due to InlineSwitch in s_rgbOpcodeSizes");
CONSISTENCY_CHECK_MSG(((instr >= CEE_BR_S) && (instr <= CEE_BLT_UN_S)) || (CEE_LEAVE), "we only use long-form branch opcodes");
CONSISTENCY_CHECK_MSG(((instr >= CEE_BR_S) && (instr <= CEE_BLT_UN_S)) || instr == CEE_LEAVE, "we only use long-form branch opcodes");
return true;
}
#endif // _DEBUG
Expand Down

0 comments on commit 18a1154

Please sign in to comment.