Skip to content

Commit

Permalink
Fix clang warning
Browse files Browse the repository at this point in the history
  • Loading branch information
P-p-H-d committed May 15, 2024
1 parent 1ae904d commit 66d2aa2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
18 changes: 18 additions & 0 deletions m-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@

#endif

/* Warnings disabled for CLANG in C mode:
Due to the genericity of the _Generic generation,
we cannot avoid generating both T and const T in the generic association. */
#if defined(__clang__) && __clang_major__ >= 15
#define M_G3N_BEGIN_PROTECTED_CODE \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code-generic-assoc\"")

#define M_G3N_END_PROTECTED_CODE \
_Pragma("clang diagnostic pop")

#else

#define M_G3N_BEGIN_PROTECTED_CODE
#define M_G3N_END_PROTECTED_CODE

#endif


/* Autodetect if Address sanitizer is run */
#if defined(__has_feature)
Expand Down
18 changes: 0 additions & 18 deletions m-generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,6 @@
#define m_typeof(x) typeof(x)
#endif

/* Warnings disabled for CLANG in C mode:
Due to the genericity of the _Generic generation,
we cannot avoid generating both T and const T in the generic association. */
#if defined(__clang__) && __clang_major__ >= 15
#define M_G3N_BEGIN_PROTECTED_CODE \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wunreachable-code-generic-assoc\"")

#define M_G3N_END_PROTECTED_CODE \
_Pragma("clang diagnostic pop")

#else

#define M_G3N_BEGIN_PROTECTED_CODE
#define M_G3N_END_PROTECTED_CODE

#endif

// Instead of using expensive M_SEQ(1,50), precompute it:
#define M_G3N_SEQ_INT \
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, \
Expand Down
4 changes: 3 additions & 1 deletion m-variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,11 @@ M_INLINE void \
#define M_VAR1ANT_INIT_WITH(oplist, dest, src) \
M_VAR1ANT_INIT_WITH_B(M_GET_NAME oplist, M_GET_SIZE oplist, dest, src)
#define M_VAR1ANT_INIT_WITH_B(name, num, dest, src) \
M_G3N_BEGIN_PROTECTED_CODE \
_Generic( (src), \
M_MAP2(M_VAR1ANT_INIT_WITH_FUNC, (name,dest,src), M_SEQ(1, num)) \
struct m_var1ant_dummy_s *: abort() )
struct m_var1ant_dummy_s *: /* cannot happen */ (void)0 ) \
M_G3N_END_PROTECTED_CODE
#define M_VAR1ANT_INIT_WITH_FUNC(triplet, num) \
M_VAR1ANT_INIT_WITH_FUNC_EXPAND(M_TRIPLE_1 triplet, M_TRIPLE_2 triplet, M_TRIPLE_3 triplet, num)
#define M_VAR1ANT_INIT_WITH_FUNC_EXPAND(name, dest, src, num) \
Expand Down

0 comments on commit 66d2aa2

Please sign in to comment.