diff --git a/mk/rules.mk b/mk/rules.mk index 518f187fe74..74461f0b20b 100644 --- a/mk/rules.mk +++ b/mk/rules.mk @@ -42,6 +42,7 @@ CFLAGS=\ -Wcast-function-type-mismatch \ -Wsemicolon-before-method-body \ -Wsign-compare \ + -Wshadow \ -g \ -I. SWIFTFLAGS=-g -emit-library diff --git a/runtime/monovm-bridge.m b/runtime/monovm-bridge.m index 054fe565310..dda287dcfbf 100644 --- a/runtime/monovm-bridge.m +++ b/runtime/monovm-bridge.m @@ -267,7 +267,6 @@ bool xamarin_is_class_nsstring (MonoClass *cls) { - MonoClass *nsstring_class = xamarin_get_nsstring_class (); if (nsstring_class == NULL) return false; diff --git a/runtime/runtime.m b/runtime/runtime.m index 03c45fa995a..1a690403b91 100644 --- a/runtime/runtime.m +++ b/runtime/runtime.m @@ -2176,9 +2176,11 @@ -(struct NSObjectData*) xamarinGetNSObjectData; MarshalManagedExceptionMode mode; GCHandle exception_gchandle = INVALID_GCHANDLE; - GCHandle handle = xamarin_gchandle_new (exception, false); - mode = xamarin_on_marshal_managed_exception (handle, &exception_gchandle); - xamarin_gchandle_free (handle); + { + GCHandle handle = xamarin_gchandle_new (exception, false); + mode = xamarin_on_marshal_managed_exception (handle, &exception_gchandle); + xamarin_gchandle_free (handle); + } if (exception_gchandle != INVALID_GCHANDLE) { PRINT (PRODUCT ": Got an exception while executing the MarshalManagedException event (this exception will be ignored):"); @@ -2197,7 +2199,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData; switch (mode) { #if !defined (CORECLR_RUNTIME) // CoreCLR won't unwind through native frames, so we'll have to abort (in the default case statement) case MarshalManagedExceptionModeDisable: - case MarshalManagedExceptionModeUnwindNativeCode: + case MarshalManagedExceptionModeUnwindNativeCode: { // // We want to maintain the original stack trace of the exception, but unfortunately // calling mono_raise_exception directly with the original exception will overwrite @@ -2210,7 +2212,7 @@ -(struct NSObjectData*) xamarinGetNSObjectData; // to throw an exception that contains the original stack trace. // - handle = xamarin_gchandle_new (exception, false); + GCHandle handle = xamarin_gchandle_new (exception, false); xamarin_rethrow_managed_exception (handle, &exception_gchandle); xamarin_gchandle_free (handle); @@ -2231,8 +2233,9 @@ -(struct NSObjectData*) xamarinGetNSObjectData; xamarin_handling_unhandled_exceptions = 0; mono_raise_exception ((MonoException *) exception); -#endif break; + } +#endif case MarshalManagedExceptionModeThrowObjectiveCException: { GCHandle handle = xamarin_gchandle_new (exception, false); NSException *ns_exc = xamarin_unwrap_ns_exception (handle, &exception_gchandle); @@ -2295,13 +2298,14 @@ -(struct NSObjectData*) xamarinGetNSObjectData; case MarshalManagedExceptionModeUnwindNativeCode: #endif case MarshalManagedExceptionModeAbort: - default: - handle = xamarin_gchandle_new (exception, false); + default: { + GCHandle handle = xamarin_gchandle_new (exception, false); const char *msg = [xamarin_print_all_exceptions (handle) UTF8String]; xamarin_gchandle_free (handle); xamarin_assertion_message ("Aborting due to trying to marshal managed exception:\n%s\n", msg); break; } + } } void diff --git a/runtime/trampolines-invoke.m b/runtime/trampolines-invoke.m index 16bafd12002..ae05ab9c127 100644 --- a/runtime/trampolines-invoke.m +++ b/runtime/trampolines-invoke.m @@ -79,13 +79,13 @@ } void -xamarin_invoke_trampoline (enum TrampolineType type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context) +xamarin_invoke_trampoline (enum TrampolineType trampoline_type, id self, SEL sel, iterator_func iterator, marshal_return_value_func marshal_return_value, void *context) { MonoObject *exception = NULL; MonoObject **exception_ptr = xamarin_is_managed_exception_marshaling_disabled () ? NULL : &exception; GCHandle exception_gchandle = INVALID_GCHANDLE; - bool is_static = (type & Tramp_Static) == Tramp_Static; - bool is_ctor = type == Tramp_Ctor; + bool is_static = (trampoline_type & Tramp_Static) == Tramp_Static; + bool is_ctor = trampoline_type == Tramp_Ctor; const char *ret_type = NULL; MonoType *sig_ret_type = NULL; @@ -148,8 +148,6 @@ void *iter = NULL; gboolean needs_writeback = FALSE; // determines if there are any ref/out parameters. MonoType *p; - int ofs; - unsigned long i; unsigned long mofs = 0; unsigned long desc_arg_count = num_arg + 2; /* 1 for the return value + 1 if this is a category instance method */ @@ -207,11 +205,11 @@ if (exception_gchandle != INVALID_GCHANDLE) goto exception_handling; - for (i = 0, ofs = 0; i < num_arg; i++) { + for (unsigned long i = 0, ofs = 0; i < num_arg; i++) { const char *argType = [sig getArgumentTypeAtIndex: (i+2)]; const char *type = xamarin_skip_encoding_flags (argType); unsigned long size = xamarin_objc_type_size (type); - int frameofs = ofs; + unsigned long frameofs = ofs; p = mono_signature_get_params (msig, &iter); ADD_TO_MONOOBJECT_RELEASE_LIST (p); LOGZ (" argument %i's type: %s (argType: %s)\n", (int) i + 1, type, argType); @@ -633,7 +631,7 @@ iterator (IteratorStart, context, NULL, 0, NULL, &exception_gchandle); // start if (exception_gchandle != INVALID_GCHANDLE) goto exception_handling; - for (i = 0; i < num_arg; i++) { + for (unsigned long i = 0; i < num_arg; i++) { const char *type = [sig getArgumentTypeAtIndex: (i+2)]; type = xamarin_skip_encoding_flags (type);