From ef9d76e06ca4a31f8c8aaf484321a6dacf7745f8 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 27 Feb 2019 11:36:49 -0500 Subject: Prevent a warning with old GCC GCC 4.8 seems to dislike returns_nonnull attribute, GCC 5 is ok. --- src/lib/utils/compiler.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/utils/compiler.h b/src/lib/utils/compiler.h index 3e41daed0..9348909e8 100644 --- a/src/lib/utils/compiler.h +++ b/src/lib/utils/compiler.h @@ -47,7 +47,7 @@ /* * Define BOTAN_GCC_VERSION */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) #define BOTAN_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__) #else #define BOTAN_GCC_VERSION 0 @@ -56,7 +56,7 @@ /* * Define BOTAN_CLANG_VERSION */ -#ifdef __clang__ +#if defined(__clang__) #define BOTAN_CLANG_VERSION (__clang_major__ * 10 + __clang_minor__) #else #define BOTAN_CLANG_VERSION 0 @@ -83,8 +83,10 @@ /* * Define BOTAN_MALLOC_FN */ -#if defined(__GNUG__) || defined(__clang__) +#if defined(__clang__) || (BOTAN_GCC_VERSION >= 500) #define BOTAN_MALLOC_FN __attribute__ ((malloc, returns_nonnull, alloc_size(1,2))) +#elif defined(__GNUG__) + #define BOTAN_MALLOC_FN __attribute__ ((malloc, alloc_size(1,2))) #elif defined(_MSC_VER) #define BOTAN_MALLOC_FN __declspec(restrict) #else @@ -142,7 +144,6 @@ /* * Define BOTAN_IF_CONSTEXPR */ - #if !defined(BOTAN_IF_CONSTEXPR) #if __cplusplus > 201402 #define BOTAN_IF_CONSTEXPR if constexpr -- cgit v1.2.3