diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index d632819864..bb5a2029af 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -379,14 +379,11 @@ AC_DEFUN([gl_COMMON_BODY], [ the return value, unless the caller uses something like ignore_value. */ /* Applies to: function, enumeration, class. */ #ifndef _GL_ATTRIBUTE_NODISCARD -# if defined __clang__ && defined __cplusplus /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces a warning. */ -# if __clang_major__ >= 1000 -# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] -# endif -# elif defined __has_c_attribute -# if __has_c_attribute (__nodiscard__) +# ifdef __has_c_attribute +# if (__has_c_attribute (__nodiscard__) \ + && ! (defined __clang__ && defined __cplusplus)) # define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] # endif # endif