From: Timo Sirainen Date: Sun, 24 Feb 2013 06:46:28 +0000 (+0200) Subject: Fixed "duplicate const" warnings with new clang. X-Git-Tag: 2.2.rc1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d803d271cbc63ae3733824dfd96c75d65068fa1;p=thirdparty%2Fdovecot%2Fcore.git Fixed "duplicate const" warnings with new clang. --- diff --git a/src/lib/hash-decl.h b/src/lib/hash-decl.h index 60fb4e1b73..51bd2d10b9 100644 --- a/src/lib/hash-decl.h +++ b/src/lib/hash-decl.h @@ -5,7 +5,6 @@ struct hash_table *_table; \ key_type _key; \ key_type *_keyp; \ - const key_type _const_key; \ value_type _value; \ value_type *_valuep; \ } diff --git a/src/lib/hash.h b/src/lib/hash.h index f0ccb67de1..e6960e069e 100644 --- a/src/lib/hash.h +++ b/src/lib/hash.h @@ -27,16 +27,6 @@ void hash_table_create(struct hash_table **table_r, pool_t node_pool, ({(void)COMPILE_ERROR_IF_TRUE( \ sizeof((*table)._key) != sizeof(void *) || \ sizeof((*table)._value) != sizeof(void *)); \ - (void)COMPILE_ERROR_IF_TRUE( \ - !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ - int (*)(typeof((*table)._key), typeof((*table)._key))) && \ - !__builtin_types_compatible_p(typeof(&key_cmp_cb), \ - int (*)(typeof((*table)._const_key), typeof((*table)._const_key)))); \ - (void)COMPILE_ERROR_IF_TRUE( \ - !__builtin_types_compatible_p(typeof(&hash_cb), \ - unsigned int (*)(typeof((*table)._key))) && \ - !__builtin_types_compatible_p(typeof(&hash_cb), \ - unsigned int (*)(typeof((*table)._const_key)))); \ hash_table_create(&(*table)._table, pool, size, \ (hash_callback_t *)hash_cb, \ (hash_cmp_callback_t *)key_cmp_cb);}) @@ -77,14 +67,14 @@ void hash_table_clear(struct hash_table *table, bool free_collisions); void *hash_table_lookup(const struct hash_table *table, const void *key) ATTR_PURE; #define hash_table_lookup(table, key) \ HASH_VALUE_CAST(table)hash_table_lookup((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._key, (table)._const_key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) bool hash_table_lookup_full(const struct hash_table *table, const void *lookup_key, void **orig_key_r, void **value_r); #define hash_table_lookup_full(table, lookup_key, orig_key_r, value_r) \ hash_table_lookup_full((table)._table, \ - (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, lookup_key)), \ + (void *)((const char *)(lookup_key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, lookup_key)), \ (void **)(void *)((orig_key_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._keyp, orig_key_r) + \ COMPILE_ERROR_IF_TRUE(sizeof(*orig_key_r) != sizeof(void *))), \ (void **)(void *)((value_r) + COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE((table)._valuep, value_r) + \ @@ -106,7 +96,7 @@ void hash_table_update(struct hash_table *table, void *key, void *value); void hash_table_remove(struct hash_table *table, const void *key); #define hash_table_remove(table, key) \ hash_table_remove((table)._table, \ - (const void *)((const char *)(key) + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE((table)._const_key, (table)._key, key))) + (const void *)((const char *)(key) + COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE((table)._key, key))) unsigned int hash_table_count(const struct hash_table *table) ATTR_PURE; #define hash_table_count(table) \ hash_table_count((table)._table) diff --git a/src/lib/macros.h b/src/lib/macros.h index 9a507db657..2c739a4d29 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -160,10 +160,13 @@ COMPILE_ERROR_IF_TRUE( \ !__builtin_types_compatible_p(typeof(_a1), typeof(_b)) && \ !__builtin_types_compatible_p(typeof(_a2), typeof(_b))) +#define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) \ + COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a, typeof(const typeof(*_a) *), _b) #else # define COMPILE_ERROR_IF_TRUE(condition) 0 # define COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(_a, _b) 0 # define COMPILE_ERROR_IF_TYPES2_NOT_COMPATIBLE(_a1, _a2, _b) 0 +# define COMPILE_ERROR_IF_CONST_TYPES_NOT_COMPATIBLE(_a, _b) 0 #endif #if __GNUC__ > 2