summaryrefslogtreecommitdiffstats
path: root/gl/warn-on-use.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/warn-on-use.h')
-rw-r--r--gl/warn-on-use.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/gl/warn-on-use.h b/gl/warn-on-use.h
index 30756034..c0072412 100644
--- a/gl/warn-on-use.h
+++ b/gl/warn-on-use.h
@@ -1,5 +1,5 @@
1/* A C macro for emitting warnings if a function is used. 1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010-2023 Free Software Foundation, Inc. 2 Copyright (C) 2010-2025 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU Lesser General Public License as published 5 under the terms of the GNU Lesser General Public License as published
@@ -32,6 +32,10 @@
32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 32 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
33 linkage. 33 linkage.
34 34
35 _GL_WARN_ON_USE should not be used more than once for a given function
36 in a given compilation unit (because this may generate a warning even
37 if the function is never called).
38
35 However, one of the reasons that a function is a portability trap is 39 However, one of the reasons that a function is a portability trap is
36 if it has the wrong signature. Declaring FUNCTION with a different 40 if it has the wrong signature. Declaring FUNCTION with a different
37 signature in C is a compilation error, so this macro must use the 41 signature in C is a compilation error, so this macro must use the
@@ -81,7 +85,7 @@
81 */ 85 */
82#ifndef _GL_WARN_ON_USE 86#ifndef _GL_WARN_ON_USE
83 87
84# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 88# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
85/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 89/* A compiler attribute is available in gcc versions 4.3.0 and later. */
86# define _GL_WARN_ON_USE(function, message) \ 90# define _GL_WARN_ON_USE(function, message) \
87_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message))) 91_GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
@@ -94,7 +98,7 @@ _GL_WARN_EXTERN_C __typeof__ (function) function \
94 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 98 __attribute__ ((__diagnose_if__ (1, message, "warning")))
95# define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 99# define _GL_WARN_ON_USE_ATTRIBUTE(message) \
96 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 100 __attribute__ ((__diagnose_if__ (1, message, "warning")))
97# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 101# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
98/* Verify the existence of the function. */ 102/* Verify the existence of the function. */
99# define _GL_WARN_ON_USE(function, message) \ 103# define _GL_WARN_ON_USE(function, message) \
100_GL_WARN_EXTERN_C __typeof__ (function) function 104_GL_WARN_EXTERN_C __typeof__ (function) function
@@ -117,7 +121,7 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
117# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 121# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
118 _GL_WARN_ON_USE (function, msg) 122 _GL_WARN_ON_USE (function, msg)
119# else 123# else
120# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 124# if (4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)) && !defined __clang__
121/* A compiler attribute is available in gcc versions 4.3.0 and later. */ 125/* A compiler attribute is available in gcc versions 4.3.0 and later. */
122# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 126# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
123extern rettype_gcc function parameters_and_attributes \ 127extern rettype_gcc function parameters_and_attributes \
@@ -127,7 +131,7 @@ extern rettype_gcc function parameters_and_attributes \
127# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 131# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
128extern rettype_clang function parameters_and_attributes \ 132extern rettype_clang function parameters_and_attributes \
129 __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 133 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
130# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 134# elif (__GNUC__ >= 3 || defined __clang__) && GNULIB_STRICT_CHECKING
131/* Verify the existence of the function. */ 135/* Verify the existence of the function. */
132# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 136# define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
133extern rettype_gcc function parameters_and_attributes 137extern rettype_gcc function parameters_and_attributes