Do not use __attribute__((__noreturn__)) if it produces a compilation error

This commit is contained in:
James Youngman 2007-05-24 08:13:46 +00:00
parent b7de52aa72
commit 6506f06158
4 changed files with 47 additions and 2 deletions

View File

@ -1,6 +1,13 @@
2007-05-24 James Youngman <jay@gnu.org>
* m4/noreturn.m4: New file, testing for support of __attribute__
((__noreturn__)). Defines jy_AC_ATTRIBUTE_NORETURN and sets
HAVE_ATTRIBUTE_NORETURN.
* configure.in: Call jy_AC_ATTRIBUTE_NORETURN.
* find/defs.h (ATTRIBUTE_NORETURN): Define to nothing if
HAVE_ATTRIBUTE_NORETURN is not set in config.h. This should fix a
compilation error with non-GCC compilers.
* configure.in (FINDLIBS): Update FINDLIBS to link against -lm for
modf. This fixed a link error on HP-UX.
* find/Makefile.am (LDADD): Use @FINDLIBS@

View File

@ -215,6 +215,7 @@ AC_CHECK_MEMBER(struct dirent.d_type,,,[
#include <sys/types.h>
#include <dirent.h>])
jy_AC_ATTRIBUTE_NORETURN
dnl internationalization macros
AM_GNU_GETTEXT([external])

View File

@ -58,7 +58,11 @@ typedef bool boolean;
#define PARAMS(Args) Args
#ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# if HAVE_ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# else
# define ATTRIBUTE_NORETURN /* nothing */
# endif
#endif
int optionl_stat PARAMS((const char *name, struct stat *p));

33
m4/noreturn.m4 Normal file
View File

@ -0,0 +1,33 @@
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
dnl This file can can be used in projects which are not available under
dnl the GNU General Public License or the GNU Library General Public
dnl License but which still want to provide support for the GNU gettext
dnl functionality.
dnl Please note that the actual code of the GNU gettext library is covered
dnl by the GNU Library General Public License, and the rest of the GNU
dnl gettext package package is covered by the GNU General Public License.
dnl They are *not* in the public domain.
dnl Authors:
dnl James Youngman <jay@gnu.org>, 2007.
AC_DEFUN([jy_AC_ATTRIBUTE_NORETURN],
[AC_CACHE_CHECK([for __attribute__ ((__noreturn__)) support],
[jy_cv_cc_attribute_noreturn],
[AC_COMPILE_IFELSE(
[void report_fatal_error(void) __attribute__ ((__noreturn__));]
[jy_cv_cc_attribute_noreturn=yes],
[jy_cv_cc_attribute_noreturn=no])])
if test $jy_cv_cc_attribute_noreturn = yes; then
HAVE_ATTRIBUTE_NORETURN=1
else
HAVE_ATTRIBUTE_NORETURN=0
fi
AC_SUBST([HAVE_ATTRIBUTE_NORETURN])
AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_NORETURN],[$HAVE_ATTRIBUTE_NORETURN],
[Define to 1 if the compiler supports __attribute__ ((__noreturn__))])
])