changeset 15901:871154fc93f2

Fixed "duplicate const" warnings with new clang.
author Timo Sirainen <tss@iki.fi>
date Sun, 24 Feb 2013 08:46:28 +0200
parents 88c325e81c7c
children ecd923186510
files src/lib/hash-decl.h src/lib/hash.h src/lib/macros.h
diffstat 3 files changed, 6 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/hash-decl.h	Sun Feb 24 08:43:34 2013 +0200
+++ b/src/lib/hash-decl.h	Sun Feb 24 08:46:28 2013 +0200
@@ -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; \
 	}
--- a/src/lib/hash.h	Sun Feb 24 08:43:34 2013 +0200
+++ b/src/lib/hash.h	Sun Feb 24 08:46:28 2013 +0200
@@ -27,16 +27,6 @@
 	({(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_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_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)
--- a/src/lib/macros.h	Sun Feb 24 08:43:34 2013 +0200
+++ b/src/lib/macros.h	Sun Feb 24 08:46:28 2013 +0200
@@ -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