changeset 14341:b8a7de52bf47

stdlib: don't get in the way of non-GCC __attribute__
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 12 Feb 2011 22:16:44 -0800
parents 80ac14ef4e0b
children e57341609cfb
files ChangeLog lib/stdlib.in.h m4/_Exit.m4 m4/attribute.m4 m4/stdlib_h.m4 modules/_Exit modules/stdlib
diffstat 7 files changed, 20 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Feb 13 03:41:41 2011 +0100
+++ b/ChangeLog	Sat Feb 12 22:16:44 2011 -0800
@@ -1,3 +1,14 @@
+2011-02-12  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdlib: don't get in the way of non-GCC __attribute__
+	See thread starting at
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00161.html>.
+	Revert previous stdlib change, installing the following instead:
+	* lib/stdin.in.h (__attribute__): Remove.  We do not want
+	to get in the way of a non-GCC compiler that supports __attribute__.
+	(_GL_ATTRIBUTE_RETURN): New macro.
+	(_Exit): Use it instead of __attribute__.
+
 2011-02-12  Bruno Haible  <bruno@clisp.org>
 
 	quotearg test: Avoid test failure on mingw.
--- a/lib/stdlib.in.h	Sun Feb 13 03:41:41 2011 +0100
+++ b/lib/stdlib.in.h	Sat Feb 12 22:16:44 2011 -0800
@@ -88,6 +88,12 @@
 # include <unistd.h>
 #endif
 
+#if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
+# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#else
+# define _GL_ATTRIBUTE_NORETURN
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -113,12 +119,7 @@
 /* Terminate the current process with the given return code, without running
    the 'atexit' handlers.  */
 # if !@HAVE__EXIT@
-#  if @HAVE_ATTRIBUTE_NORETURN@
-#   define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#  else
-#   define _GL_ATTRIBUTE_NORETURN
-#  endif
-_GL_FUNCDECL_SYS (_Exit, void, (int status)) _GL_ATTRIBUTE_NORETURN;
+_GL_FUNCDECL_SYS (_Exit, void, (int status) _GL_ATTRIBUTE_NORETURN);
 # endif
 _GL_CXXALIAS_SYS (_Exit, void, (int status));
 _GL_CXXALIASWARN (_Exit);
--- a/m4/_Exit.m4	Sun Feb 13 03:41:41 2011 +0100
+++ b/m4/_Exit.m4	Sat Feb 12 22:16:44 2011 -0800
@@ -1,4 +1,4 @@
-# _Exit.m4 serial 2
+# _Exit.m4 serial 1
 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,8 +7,6 @@
 AC_DEFUN([gl_FUNC__EXIT],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
-  AC_REQUIRE([gl_ATTRIBUTE_NORETURN])
-
   AC_CHECK_FUNCS([_Exit])
   if test $ac_cv_func__Exit = no; then
     HAVE__EXIT=0
--- a/m4/attribute.m4	Sun Feb 13 03:41:41 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-# Test for GCC-style __attribute__ support.
-
-dnl Copyright (C) 2011 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 from Paul Eggert
-
-# Currently only __attribute__ ((__noreturn__)) is done,
-# but other macros can be added to this file as needed.
-
-# Test whether __attribute__ ((__noreturn__)) works.
-AC_DEFUN([gl_ATTRIBUTE_NORETURN], [
-  AC_CACHE_CHECK([for  __attribute__ ((__noreturn__))],
-    [gl_cv_attribute_noreturn],
-    [gl_save_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
-     ac_[]_AC_LANG_ABBREV[]_werror_flag=yes
-     AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[void never_come_back (int) __attribute__ ((__noreturn__));]])],
-       [gl_cv_attribute_noreturn=yes],
-       [gl_cv_attribute_noreturn=no])
-     ac_[]_AC_LANG_ABBREV[]_werror_flag=$gl_save_werror_flag])
-  if test $gl_cv_attribute_noreturn = no; then
-    HAVE_ATTRIBUTE_NORETURN=0
-  fi
-  AC_SUBST([HAVE_ATTRIBUTE_NORETURN])
-])
--- a/m4/stdlib_h.m4	Sun Feb 13 03:41:41 2011 +0100
+++ b/m4/stdlib_h.m4	Sat Feb 12 22:16:44 2011 -0800
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 37
+# stdlib_h.m4 serial 36
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -65,7 +65,6 @@
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE__EXIT=1;              AC_SUBST([HAVE__EXIT])
   HAVE_ATOLL=1;              AC_SUBST([HAVE_ATOLL])
-  HAVE_ATTRIBUTE_NORETURN=1; AC_SUBST([HAVE_ATTRIBUTE_NORETURN])
   HAVE_CANONICALIZE_FILE_NAME=1;  AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
   HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
   HAVE_GETSUBOPT=1;          AC_SUBST([HAVE_GETSUBOPT])
--- a/modules/_Exit	Sun Feb 13 03:41:41 2011 +0100
+++ b/modules/_Exit	Sat Feb 12 22:16:44 2011 -0800
@@ -4,7 +4,6 @@
 Files:
 lib/_Exit.c
 m4/_Exit.m4
-m4/attribute.m4
 
 Depends-on:
 stdlib
--- a/modules/stdlib	Sun Feb 13 03:41:41 2011 +0100
+++ b/modules/stdlib	Sat Feb 12 22:16:44 2011 -0800
@@ -57,7 +57,6 @@
 	      < $(srcdir)/stdlib.in.h | \
 	  sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
 	      -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
-	      -e 's|@''HAVE_ATTRIBUTE_NORETURN''@|$(HAVE_ATTRIBUTE_NORETURN)|g' \
 	      -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
 	      -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \