mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
; Update from Gnulib
* configure.ac: * src/conf_post.h: Remove workarounds now rendered redundant by Gnulib.
This commit is contained in:
parent
a13eef1fae
commit
1a13c5e63e
57 changed files with 2048 additions and 925 deletions
|
|
@ -1,5 +1,5 @@
|
|||
# gnulib-common.m4
|
||||
# serial 95
|
||||
# serial 103
|
||||
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
|
|
@ -21,10 +21,22 @@ AC_DEFUN([gl_COMMON_BODY], [
|
|||
#define _GL_CONFIG_H_INCLUDED 1
|
||||
])
|
||||
AH_VERBATIM([_GL_GNUC_PREREQ],
|
||||
[/* True if the compiler says it groks GNU C version MAJOR.MINOR. */
|
||||
#if defined __GNUC__ && defined __GNUC_MINOR__
|
||||
[/* True if the compiler says it groks GNU C version MAJOR.MINOR.
|
||||
Except that
|
||||
- clang groks GNU C 4.2, even on Windows, where it does not define
|
||||
__GNUC__.
|
||||
- The OpenMandriva-modified clang compiler pretends that it groks
|
||||
GNU C version 13.1, but it doesn't: It does not support
|
||||
__attribute__ ((__malloc__ (f, i))), nor does it support
|
||||
__attribute__ ((__warning__ (message))) on a function redeclaration.
|
||||
- Users can make clang lie as well, through the -fgnuc-version option. */
|
||||
#if defined __GNUC__ && defined __GNUC_MINOR__ && !defined __clang__
|
||||
# define _GL_GNUC_PREREQ(major, minor) \
|
||||
((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__))
|
||||
#elif defined __clang__
|
||||
/* clang really only groks GNU C 4.2. */
|
||||
# define _GL_GNUC_PREREQ(major, minor) \
|
||||
((major) < 4 + ((minor) <= 2))
|
||||
#else
|
||||
# define _GL_GNUC_PREREQ(major, minor) 0
|
||||
#endif
|
||||
|
|
@ -133,6 +145,23 @@ AC_DEFUN([gl_COMMON_BODY], [
|
|||
# define _GL_HAVE___HAS_C_ATTRIBUTE 0
|
||||
#endif
|
||||
|
||||
/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
|
||||
syntax, in function declarations. There are two problems here.
|
||||
(Last tested with gcc/g++ 14 and clang/clang++ 18.)
|
||||
|
||||
1) We want that the _GL_ATTRIBUTE_* can be cumulated on the same declaration
|
||||
in any order.
|
||||
=========================== foo.c = foo.cc ===========================
|
||||
__attribute__ ((__deprecated__)) [[__nodiscard__]] int bar1 (int);
|
||||
[[__nodiscard__]] __attribute__ ((__deprecated__)) int bar2 (int);
|
||||
======================================================================
|
||||
This gives a syntax error
|
||||
- in C mode with gcc
|
||||
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796>, and
|
||||
- in C++ mode with clang++ version < 16, and
|
||||
- in C++ mode, inside extern "C" {}, still in newer clang++ versions
|
||||
<https://github.com/llvm/llvm-project/issues/101990>.
|
||||
*/
|
||||
/* Define if, in a function declaration, the attributes in bracket syntax
|
||||
[[...]] must come before the attributes in __attribute__((...)) syntax.
|
||||
If this is defined, it is best to avoid the bracket syntax, so that the
|
||||
|
|
@ -147,6 +176,176 @@ AC_DEFUN([gl_COMMON_BODY], [
|
|||
# define _GL_BRACKET_BEFORE_ATTRIBUTE 1
|
||||
# endif
|
||||
#endif
|
||||
/*
|
||||
2) We want that the _GL_ATTRIBUTE_* can be placed in a declaration
|
||||
- without 'extern', in C as well as in C++,
|
||||
- with 'extern', in C,
|
||||
- with 'extern "C"', in C++
|
||||
in the same position. That is, we don't want to be forced to use a
|
||||
macro which arranges for the attribute to come before 'extern' in
|
||||
one case and after 'extern' in the other case, because such a macro
|
||||
would make the source code of .h files pretty ugly.
|
||||
=========================== foo.c = foo.cc ===========================
|
||||
#ifdef __cplusplus
|
||||
# define CC "C"
|
||||
#else
|
||||
# define CC
|
||||
#endif
|
||||
|
||||
#define ND [[__nodiscard__]]
|
||||
#define WUR __attribute__((__warn_unused_result__))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// gcc clang g++ clang++
|
||||
|
||||
ND int foo (int);
|
||||
int ND foo (int); // warn error warn error
|
||||
int foo ND (int);
|
||||
int foo (int) ND; // warn error warn error
|
||||
|
||||
WUR int foo (int);
|
||||
int WUR foo (int);
|
||||
int fo1 WUR (int); // error error error error
|
||||
int foo (int) WUR;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// gcc clang g++ clang++
|
||||
|
||||
ND extern CC int foo (int); // error error
|
||||
extern CC ND int foo (int); // error error
|
||||
extern CC int ND foo (int); // warn error warn error
|
||||
extern CC int foo ND (int);
|
||||
extern CC int foo (int) ND; // warn error warn error
|
||||
|
||||
WUR extern CC int foo (int); // warn
|
||||
extern CC WUR int foo (int);
|
||||
extern CC int WUR foo (int);
|
||||
extern CC int foo WUR (int); // error error error error
|
||||
extern CC int foo (int) WUR;
|
||||
|
||||
ND EXTERN_C_FUNC int foo (int); // error error
|
||||
EXTERN_C_FUNC ND int foo (int);
|
||||
EXTERN_C_FUNC int ND foo (int); // warn error warn error
|
||||
EXTERN_C_FUNC int foo ND (int);
|
||||
EXTERN_C_FUNC int foo (int) ND; // warn error warn error
|
||||
|
||||
WUR EXTERN_C_FUNC int foo (int); // warn
|
||||
EXTERN_C_FUNC WUR int foo (int);
|
||||
EXTERN_C_FUNC int WUR foo (int);
|
||||
EXTERN_C_FUNC int fo2 WUR (int); // error error error error
|
||||
EXTERN_C_FUNC int foo (int) WUR;
|
||||
======================================================================
|
||||
So, if we insist on using the 'extern' keyword ('extern CC' idiom):
|
||||
* If _GL_ATTRIBUTE_* expands to bracket syntax [[...]]
|
||||
in both C and C++, there is one available position:
|
||||
- between the function name and the parameter list.
|
||||
* If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax
|
||||
in both C and C++, there are several available positions:
|
||||
- before the return type,
|
||||
- between return type and function name,
|
||||
- at the end of the declaration.
|
||||
* If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to
|
||||
__attribute__((...)) syntax in C++, there is no available position:
|
||||
it would need to come before 'extern' in C but after 'extern "C"'
|
||||
in C++.
|
||||
* If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and
|
||||
to bracket syntax [[...]] in C++, there is one available position:
|
||||
- before the return type.
|
||||
Whereas, if we use the 'EXTERN_C_FUNC' idiom, which conditionally
|
||||
omits the 'extern' keyword:
|
||||
* If _GL_ATTRIBUTE_* expands to bracket syntax [[...]]
|
||||
in both C and C++, there are two available positions:
|
||||
- before the return type,
|
||||
- between the function name and the parameter list.
|
||||
* If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax
|
||||
in both C and C++, there are several available positions:
|
||||
- before the return type,
|
||||
- between return type and function name,
|
||||
- at the end of the declaration.
|
||||
* If _GL_ATTRIBUTE_* expands to bracket syntax [[...]] in C and to
|
||||
__attribute__((...)) syntax in C++, there is one available position:
|
||||
- before the return type.
|
||||
* If _GL_ATTRIBUTE_* expands to __attribute__((...)) syntax in C and
|
||||
to bracket syntax [[...]] in C++, there is one available position:
|
||||
- before the return type.
|
||||
The best choice is therefore to use the 'EXTERN_C_FUNC' idiom and
|
||||
put the attributes before the return type. This works regardless
|
||||
to what the _GL_ATTRIBUTE_* macros expand.
|
||||
*/
|
||||
|
||||
/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
|
||||
syntax, in static/inline function definitions.
|
||||
|
||||
There are similar constraints as for function declarations. However, here,
|
||||
we cannot omit the storage-class specifier. Therefore, the following rule
|
||||
applies:
|
||||
* The macros
|
||||
_GL_ATTRIBUTE_CONST
|
||||
_GL_ATTRIBUTE_DEPRECATED
|
||||
_GL_ATTRIBUTE_MAYBE_UNUSED
|
||||
_GL_ATTRIBUTE_NODISCARD
|
||||
_GL_ATTRIBUTE_PURE
|
||||
_GL_ATTRIBUTE_REPRODUCIBLE
|
||||
_GL_ATTRIBUTE_UNSEQUENCED
|
||||
which may expand to bracket syntax [[...]], must come first, before the
|
||||
storage-class specifier.
|
||||
* Other _GL_ATTRIBUTE_* macros, that expand to __attribute__((...)) syntax,
|
||||
are better placed between the storage-class specifier and the return
|
||||
type.
|
||||
*/
|
||||
|
||||
/* Attributes in bracket syntax [[...]] vs. attributes in __attribute__((...))
|
||||
syntax, in variable declarations.
|
||||
|
||||
At which position can they be placed?
|
||||
(Last tested with gcc/g++ 14 and clang/clang++ 18.)
|
||||
|
||||
=========================== foo.c = foo.cc ===========================
|
||||
#ifdef __cplusplus
|
||||
# define CC "C"
|
||||
#else
|
||||
# define CC
|
||||
#endif
|
||||
|
||||
#define BD [[__deprecated__]]
|
||||
#define AD __attribute__ ((__deprecated__))
|
||||
|
||||
// gcc clang g++ clang++
|
||||
|
||||
BD extern CC int var; // error error
|
||||
extern CC BD int var; // error error
|
||||
extern CC int BD var; // warn error warn error
|
||||
extern CC int var BD;
|
||||
|
||||
AD extern CC int var; // warn
|
||||
extern CC AD int var;
|
||||
extern CC int AD var;
|
||||
extern CC int var AD;
|
||||
|
||||
BD extern CC int z[]; // error error
|
||||
extern CC BD int z[]; // error error
|
||||
extern CC int BD z[]; // warn error warn error
|
||||
extern CC int z1 BD [];
|
||||
extern CC int z[] BD; // warn error error
|
||||
|
||||
AD extern CC int z[]; // warn
|
||||
extern CC AD int z[];
|
||||
extern CC int AD z[];
|
||||
extern CC int z2 AD []; // error error error error
|
||||
extern CC int z[] AD;
|
||||
======================================================================
|
||||
|
||||
* For non-array variables, the only good position is after the variable name,
|
||||
that is, at the end of the declaration.
|
||||
* For array variables, you will need to distinguish C and C++:
|
||||
- In C, before the 'extern' keyword.
|
||||
- In C++, between the 'extern "C"' and the variable's type.
|
||||
*/
|
||||
]dnl There is no _GL_ATTRIBUTE_ALIGNED; use stdalign's alignas instead.
|
||||
[
|
||||
/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function
|
||||
|
|
@ -488,7 +687,7 @@ AC_DEFUN([gl_COMMON_BODY], [
|
|||
other attributes. */
|
||||
#ifndef _GL_ATTRIBUTE_NOTHROW
|
||||
# if defined __cplusplus
|
||||
# if _GL_GNUC_PREREQ (2, 8) || __clang_major >= 4
|
||||
# if _GL_GNUC_PREREQ (2, 8) || __clang_major__ >= 4
|
||||
# if __cplusplus >= 201103L
|
||||
# define _GL_ATTRIBUTE_NOTHROW noexcept (true)
|
||||
# else
|
||||
|
|
@ -1156,7 +1355,7 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
|
|||
dnl -Wno-unused-parameter >= 3 >= 3.9
|
||||
dnl
|
||||
cat > conftest.c <<\EOF
|
||||
#if __GNUC__ >= 3 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
#if (__GNUC__ >= 3 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
-Wno-cast-qual
|
||||
-Wno-conversion
|
||||
-Wno-float-equal
|
||||
|
|
@ -1165,23 +1364,23 @@ AC_DEFUN([gl_CC_GNULIB_WARNINGS],
|
|||
-Wno-unused-function
|
||||
-Wno-unused-parameter
|
||||
#endif
|
||||
#if __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
#if (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
-Wno-float-conversion
|
||||
#endif
|
||||
#if __GNUC__ >= 7 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
#if (__GNUC__ >= 7 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
-Wimplicit-fallthrough
|
||||
#endif
|
||||
#if __GNUC__ + (__GNUC_MINOR__ >= 8) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
#if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
-Wno-pedantic
|
||||
#endif
|
||||
#if 3 < __clang_major__ + (9 <= __clang_minor__)
|
||||
-Wno-tautological-constant-out-of-range-compare
|
||||
#endif
|
||||
#if __GNUC__ + (__GNUC_MINOR__ >= 3) > 4 || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
#if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 4 && !defined __clang__) || (__clang_major__ + (__clang_minor__ >= 9) > 3)
|
||||
-Wno-sign-conversion
|
||||
-Wno-type-limits
|
||||
#endif
|
||||
#if __GNUC__ + (__GNUC_MINOR__ >= 5) > 4
|
||||
#if (__GNUC__ + (__GNUC_MINOR__ >= 5) > 4 && !defined __clang__)
|
||||
-Wno-unsuffixed-float-constants
|
||||
#endif
|
||||
EOF
|
||||
|
|
@ -1364,7 +1563,7 @@ dnl
|
|||
dnl This macro sets two variables:
|
||||
dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
|
||||
dnl - ac_cv_func_<func> to yes / no / no
|
||||
dnl The first variable allows distinguishing all three cases.
|
||||
dnl The first variable allows to distinguish all three cases.
|
||||
dnl The second variable is set, so that an invocation
|
||||
dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
|
||||
dnl can be used as a drop-in replacement for
|
||||
|
|
@ -1417,7 +1616,7 @@ dnl
|
|||
dnl This macro sets two variables:
|
||||
dnl - gl_cv_onwards_func_<func> to yes / no / "future OS version"
|
||||
dnl - ac_cv_func_<func> to yes / no / no
|
||||
dnl The first variable allows distinguishing all three cases.
|
||||
dnl The first variable allows to distinguish all three cases.
|
||||
dnl The second variable is set, so that an invocation
|
||||
dnl gl_CHECK_FUNCS_MACOS([func], [[#include <foo.h>]])
|
||||
dnl can be used as a drop-in replacement for
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue