diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c index 3827122a96..7aae1049cb 100644 --- a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c +++ b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c @@ -71,7 +71,7 @@ PeCoffLoaderRelocateImageExtraAction ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext ) { - #if !defined (MDEPKG_NDEBUG) + #if defined (__CC_ARM) || defined (__GNUC__) CHAR8 Temp[512]; #endif @@ -111,7 +111,7 @@ PeCoffLoaderUnloadImageExtraAction ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext ) { - #if !defined (MDEPKG_NDEBUG) + #if defined (__CC_ARM) || defined (__GNUC__) CHAR8 Temp[512]; #endif diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index f2bca5d740..00caf9db5d 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -151,7 +151,6 @@ DescribeExceptionSyndrome ( DEBUG ((DEBUG_ERROR, "\n %a \n", Message)); } -#ifndef MDEPKG_NDEBUG STATIC CONST CHAR8 * BaseName ( @@ -171,8 +170,6 @@ BaseName ( return Str; } -#endif - /** This is the default action to take on an unexpected exception diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index 9110be2f41..e7a86dfad3 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -401,7 +401,12 @@ UnitTestDebugAssert ( } \ } while (FALSE) #else -#define ASSERT(Expression) +#define ASSERT(Expression) \ + do { \ + if ((FALSE)) { \ + (VOID) (Expression); \ + } \ + } while (FALSE) #endif /** @@ -423,6 +428,16 @@ UnitTestDebugAssert ( _DEBUG (Expression); \ } \ } while (FALSE) +#elif defined (__GNUC__) || defined (__clang__) +#define DEBUG(Expression) \ + do { \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunused-value\"") \ + if ((FALSE)) { \ + (VOID) Expression; \ + } \ + _Pragma("GCC diagnostic pop") \ + } while (FALSE) #else #define DEBUG(Expression) #endif @@ -450,7 +465,12 @@ UnitTestDebugAssert ( } \ } while (FALSE) #else -#define ASSERT_EFI_ERROR(StatusParameter) +#define ASSERT_EFI_ERROR(StatusParameter) \ + do { \ + if ((FALSE)) { \ + (VOID) (StatusParameter); \ + } \ + } while (FALSE) #endif /** @@ -477,7 +497,12 @@ UnitTestDebugAssert ( } \ } while (FALSE) #else -#define ASSERT_RETURN_ERROR(StatusParameter) +#define ASSERT_RETURN_ERROR(StatusParameter) \ + do { \ + if ((FALSE)) { \ + (VOID) (StatusParameter); \ + } \ + } while (FALSE) #endif /**