]> Savannah Git Hosting - gnulib.git/commitdiff
eealloc, pagealign_alloc, xalloc: avoid clang warnings
authorPádraig Brady <P@draigBrady.com>
Tue, 28 Apr 2015 21:24:45 +0000 (22:24 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 28 Apr 2015 21:54:08 +0000 (22:54 +0100)
Avoid [-Wunknown-attributes] warnings like:
warning: unknown attribute '__alloc_size__' ignored

* lib/xalloc.h: Don't use the __alloc_size__  attribute
with clang, as support has been fully removed as of clang 3.5:
https://github.com/llvm-mirror/clang/commit/c047507a
* lib/eealloc.h: Likewise.
* lib/pagealign_alloc.h: Likewise.

ChangeLog
lib/eealloc.h
lib/pagealign_alloc.h
lib/xalloc.h

index fcc638311ed0b9a1c156dd857affb676ef35dce2..6d9ba2c38fabab6824e69c1d8c1090c36e39ce78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2015-04-28  Pádraig Brady  <P@draigBrady.com>
+
+       eealloc, pagealign_alloc, xalloc: avoid clang warnings
+       Avoid [-Wunknown-attributes] warnings like:
+       warning: unknown attribute '__alloc_size__' ignored
+       * lib/xalloc.h: Don't use the __alloc_size__  attribute
+       with clang, as support has been fully removed as of clang 3.5:
+       https://github.com/llvm-mirror/clang/commit/c047507a
+       * lib/eealloc.h: Likewise.
+       * lib/pagealign_alloc.h: Likewise.
+
 2015-04-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        tests: pacify GCC 5.1's stricter printf checking
index ab2faa05ee9f858da78edc89bd6d4e810a4602f8..1029014dcf3f2517e48af51ba92005af32f29f15 100644 (file)
@@ -39,17 +39,24 @@ _GL_INLINE_HEADER_BEGIN
 # define EEALLOC_INLINE _GL_INLINE
 #endif
 
+#if __GNUC__ >= 3
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC
+#endif
+
+#if ! defined __clang__ && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+#else
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
+#endif
+
 #if MALLOC_0_IS_NONNULL
 # define eemalloc malloc
 #else
-# if __GNUC__ >= 3
 EEALLOC_INLINE void *eemalloc (size_t n)
-     __attribute__ ((__malloc__))
-#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-     __attribute__ ((__alloc_size__ (1)))
-#  endif
-  ;
-# endif
+     _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 EEALLOC_INLINE void *
 eemalloc (size_t n)
 {
@@ -63,10 +70,8 @@ eemalloc (size_t n)
 #if REALLOC_0_IS_NONNULL
 # define eerealloc realloc
 #else
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
 EEALLOC_INLINE void *eerealloc (void *p, size_t n)
-     __attribute__ ((__alloc_size__ (2)));
-# endif
+     _GL_ATTRIBUTE_ALLOC_SIZE ((2));
 EEALLOC_INLINE void *
 eerealloc (void *p, size_t n)
 {
index 1fbbf0810847a262b6598546a525a8f18d70b133..acdadc4076038e9bb85a9f429dc3f3e82533c137 100644 (file)
 
 # include <stddef.h>
 
+#if __GNUC__ >= 3
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC
+#endif
+
+#if ! defined __clang__ && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+#else
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
+#endif
+
 /* Allocate a block of memory of SIZE bytes, aligned on a system page
    boundary.
    If SIZE is not a multiple of the system page size, it will be rounded up
    Return a pointer to the start of the memory block. Upon allocation failure,
    return NULL and set errno.  */
 extern void *pagealign_alloc (size_t size)
-# if __GNUC__ >= 3
-     __attribute__ ((__malloc__))
-#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-     __attribute__ ((__alloc_size__ (1)))
-#  endif
-# endif
-     ;
+     _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 
 /* Like pagealign_alloc, except it exits the program if the allocation
    fails.  */
 extern void *pagealign_xalloc (size_t size)
-# if __GNUC__ >= 3
-     __attribute__ ((__malloc__))
-#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-     __attribute__ ((__alloc_size__ (1)))
-#  endif
-# endif
-     ;
+     _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 
 /* Free a memory block.
    PTR must be a non-NULL pointer returned by pagealign_alloc or
index 68f847a2c4ee877948d3584b23c7f83193245bdb..81ef680a3a7aabd036529cf35b6a976f2c13f945 100644 (file)
@@ -41,7 +41,8 @@ extern "C" {
 # define _GL_ATTRIBUTE_MALLOC
 #endif
 
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#if ! defined __clang__ && \
+    (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
 #else
 # define _GL_ATTRIBUTE_ALLOC_SIZE(args)