diff options
author | Phil Christensen <philc@microsoft.com> | 2016-12-01 03:53:23 -0800 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2016-12-01 12:53:23 +0100 |
commit | 20275aa647c5733bc5b1929cba3fd1094c67fb1d (patch) | |
tree | 83175127d46a1eaf0071747a92876f3b3e43a6fa /src/vm/encee.cpp | |
parent | 3f4680c80dc510a96efa322054145a807480bab7 (diff) | |
download | coreclr-20275aa647c5733bc5b1929cba3fd1094c67fb1d.tar.gz coreclr-20275aa647c5733bc5b1929cba3fd1094c67fb1d.tar.bz2 coreclr-20275aa647c5733bc5b1929cba3fd1094c67fb1d.zip |
fix permissive C++ code (MSVC /permissive-) (#8337)
* fix permissive C++ code (MSVC /permissive-)
These were found by the C++ compiler group when doing "Real world code"
build tests using /permissive-. We are sharing these with you to help you clean up
your code before the new version of the compiler comes out. For more information on /permissive-
see https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/.
----------------------------
Under /permissive-, skipping the initialization of a variable is not allowed.
As an extension the compiler allowed this when there was no destructor for the type.
void func(bool b)
{
if(b) goto END;
int value = 0; //error C2362: initialization of 'value' is skipped by 'goto END'
int array[10]; //Okay, not initialized.
//... value used here
END:
return;
}
Fix 1) Limit the scope of value:
{
int value = 0;
//... value used here
}
END:
Fix 2) Initialize/declare value before the 'goto'
int value = 0;
if(b) goto END;
//... value used here
END:
Fix 3) Don't initialize value in the variable declaration.
int value;
value = 0
//... value used here
END:
-------------------
Alternative token representations.
The following are reserved as alternative representations for operators:
and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq
//Can't use reserved names for variables:
static int and = 0; // Change name (possibly to 'and_')
void func()
{
_asm {
xor edx,edx // xor is reserved, change to uppercase XOR
or eax,eax // or is reserved, change to uppercase OR
}
}
* Apply formatting patch.
* fixes from code review.
I addressed @janvorli requests from the pull request code review.
Diffstat (limited to 'src/vm/encee.cpp')
-rw-r--r-- | src/vm/encee.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/vm/encee.cpp b/src/vm/encee.cpp index ca4e7fe553..7f12643340 100644 --- a/src/vm/encee.cpp +++ b/src/vm/encee.cpp @@ -149,7 +149,11 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( HRESULT hr = S_OK; HENUMInternal enumENC; - + + BYTE *pLocalILMemory = NULL; + IMDInternalImport *pMDImport = NULL; + IMDInternalImport *pNewMDImport = NULL; + CONTRACT_VIOLATION(GCViolation); // SafeComHolder goes to preemptive mode, which will trigger a GC SafeComHolder<IMDInternalImportENC> pIMDInternalImportENC; SafeComHolder<IMetaDataEmit> pEmitter; @@ -175,8 +179,7 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( IfFailGo(hr); // Grab the current importer. - IMDInternalImport *pMDImport = GetMDImport(); - IMDInternalImport *pNewMDImport; + pMDImport = GetMDImport(); // Apply the EnC delta to this module's metadata. IfFailGo(pMDImport->ApplyEditAndContinue(pDeltaMD, cbDeltaMD, &pNewMDImport)); @@ -195,7 +198,7 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( IfFailGo(GetMetaDataPublicInterfaceFromInternal(pMDImport, IID_IMetaDataEmit, (void **)&pEmitter)); // Copy the deltaIL into our RVAable IL memory - BYTE *pLocalILMemory = new BYTE[cbDeltaIL]; + pLocalILMemory = new BYTE[cbDeltaIL]; memcpy(pLocalILMemory, pDeltaIL, cbDeltaIL); // Enumerate all of the EnC delta tokens @@ -203,7 +206,6 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( IfFailGo(pIMDInternalImportENC->EnumDeltaTokensInit(&enumENC)); mdToken token; - FieldDesc * pField = NULL; while (pIMDInternalImportENC->EnumNext(&enumENC, &token)) { STRESS_LOG3(LF_ENC, LL_INFO100, "EACM::AEAC: updated token 0x%x; type 0x%x; rid 0x%x\n", token, TypeFromToken(token), RidFromToken(token)); @@ -248,8 +250,7 @@ HRESULT EditAndContinueModule::ApplyEditAndContinue( // FieldDef token - add a new field LOG((LF_ENC, LL_INFO10000, "EACM::AEAC: Found field 0x%x\n", token)); - pField = LookupFieldDef(token); - if (pField) + if (LookupFieldDef(token)) { // Field already exists - just ignore for now continue; |