stdlib: support non-GCC __attribute__
[gnulib.git] / m4 / attribute.m4
1 # Test for GCC-style __attribute__ support.
2
3 dnl Copyright (C) 2011 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl from Paul Eggert
9
10 # Currently only __attribute__ ((__noreturn__)) is done,
11 # but other macros can be added to this file as needed.
12
13 # Test whether __attribute__ ((__noreturn__)) works.
14 AC_DEFUN([gl_ATTRIBUTE_NORETURN], [
15   AC_CACHE_CHECK([for  __attribute__ ((__noreturn__))],
16     [gl_cv_attribute_noreturn],
17     [gl_save_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
18      ac_[]_AC_LANG_ABBREV[]_werror_flag=yes
19      AC_COMPILE_IFELSE(
20        [AC_LANG_PROGRAM(
21           [[void never_come_back (int) __attribute__ ((__noreturn__));]])],
22        [gl_cv_attribute_noreturn=yes],
23        [gl_cv_attribute_noreturn=no])
24      ac_[]_AC_LANG_ABBREV[]_werror_flag=$gl_save_werror_flag])
25   if test $gl_cv_attribute_noreturn = no; then
26     HAVE_ATTRIBUTE_NORETURN=0
27   fi
28   AC_SUBST([HAVE_ATTRIBUTE_NORETURN])
29 ])