diff --git a/.clang-format b/.clang-format index 7252d3eee3f..2fd9142befd 100644 --- a/.clang-format +++ b/.clang-format @@ -297,6 +297,7 @@ StatementMacros: - ITK_CLANG_PRAGMA_PUSH - ITK_CLANG_PRAGMA_POP - ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant + - ITK_CLANG_SUPPRESS_Wduplicate_enum - CLANG_PRAGMA_PUSH - CLANG_PRAGMA_POP - CLANG_SUPPRESS_Wfloat_equal diff --git a/Examples/.clang-format b/Examples/.clang-format index aee28847baa..37bd3afa8a1 100644 --- a/Examples/.clang-format +++ b/Examples/.clang-format @@ -297,6 +297,7 @@ StatementMacros: - ITK_CLANG_PRAGMA_PUSH - ITK_CLANG_PRAGMA_POP - ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant + - ITK_CLANG_SUPPRESS_Wduplicate_enum - CLANG_PRAGMA_PUSH - CLANG_PRAGMA_POP - CLANG_SUPPRESS_Wfloat_equal diff --git a/Modules/Core/Common/include/itkCommonEnums.h b/Modules/Core/Common/include/itkCommonEnums.h index d6d2422f059..127275afd9c 100644 --- a/Modules/Core/Common/include/itkCommonEnums.h +++ b/Modules/Core/Common/include/itkCommonEnums.h @@ -72,6 +72,8 @@ class CommonEnums * refers to the actual storage class associated with either a * SCALAR pixel type or elements of a compound pixel. */ + ITK_CLANG_PRAGMA_PUSH + ITK_CLANG_SUPPRESS_Wduplicate_enum enum class IOComponent : uint8_t { UNKNOWNCOMPONENTTYPE, @@ -99,6 +101,7 @@ class CommonEnums FLOAT32 = FLOAT, FLOAT64 = DOUBLE }; + ITK_CLANG_PRAGMA_POP /** * \ingroup ITKCommon diff --git a/Modules/Core/Common/include/itkMacro.h b/Modules/Core/Common/include/itkMacro.h index 433600a40a0..f2fe5f5314e 100644 --- a/Modules/Core/Common/include/itkMacro.h +++ b/Modules/Core/Common/include/itkMacro.h @@ -121,12 +121,22 @@ namespace itk #if defined(__clang__) && defined(__has_warning) # define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push) # define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop) -# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \ - ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant") +# if __has_warning("-Wzero-as-null-pointer-constant") +# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \ + ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant") +# else +# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant +# endif +# if __has_warning("-Wduplicate-enum") +# define ITK_CLANG_SUPPRESS_Wduplicate_enum ITK_PRAGMA(clang diagnostic ignored "-Wduplicate-enum") +# else +# define ITK_CLANG_SUPPRESS_Wduplicate_enum +# endif #else # define ITK_CLANG_PRAGMA_PUSH # define ITK_CLANG_PRAGMA_POP # define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant +# define ITK_CLANG_SUPPRESS_Wduplicate_enum #endif // These were not intended as public API, but some code was nevertheless using them.