Blame m4/dlp_fallthrough.m4

rpm-build 324937
#
rpm-build 324937
# SYNOPSIS
rpm-build 324937
#
rpm-build 324937
#   DLP_FALLTHROUGH
rpm-build 324937
#
rpm-build 324937
# DESCRIPTION
rpm-build 324937
#
rpm-build 324937
#   This macro checks if the compiler supports a fallthrough warning
rpm-build 324937
#   suppression attribute in GCC or CLANG style.
rpm-build 324937
#
rpm-build 324937
#   If a fallthrough warning suppression attribute is supported define
rpm-build 324937
#   HAVE_<STYLE>_ATTRIBUTE_FALLTHROUGH.
rpm-build 324937
#
rpm-build 324937
#   The macro caches its result in ax_cv_have_<style>_attribute_fallthrough
rpm-build 324937
#   variables.
rpm-build 324937
#
rpm-build 324937
# LICENSE
rpm-build 324937
#
rpm-build 324937
#   Copyright (c) 2017 David Tardon <dtardon@redhat.com>
rpm-build 324937
#
rpm-build 324937
#   Copying and distribution of this file, with or without modification, are
rpm-build 324937
#   permitted in any medium without royalty provided the copyright notice
rpm-build 324937
#   and this notice are preserved.  This file is offered as-is, without any
rpm-build 324937
#   warranty.
rpm-build 324937
rpm-build 324937
#serial 1
rpm-build 324937
rpm-build 324937
m4_defun([_DLP_FALLTHROUGH], [
rpm-build 324937
    AS_VAR_PUSHDEF([ac_var], [ax_cv_have_$2_attribute_falltrough])
rpm-build 324937
rpm-build 324937
    AC_CACHE_CHECK([for $1], [ac_var], [
rpm-build 324937
        AC_LINK_IFELSE([AC_LANG_PROGRAM([
rpm-build 324937
                void foo(int &i)
rpm-build 324937
                {
rpm-build 324937
                    switch (i)
rpm-build 324937
                    {
rpm-build 324937
                        case 0:
rpm-build 324937
                            i += 1;
rpm-build 324937
                            $1;
rpm-build 324937
                        default:
rpm-build 324937
                            i += 1;
rpm-build 324937
                    }
rpm-build 324937
                }
rpm-build 324937
            ], [])
rpm-build 324937
            ],
rpm-build 324937
            dnl GCC doesn't exit with an error if an unknown attribute is
rpm-build 324937
            dnl provided but only outputs a warning, so accept the attribute
rpm-build 324937
            dnl only if no warning were issued.
rpm-build 324937
            [AS_IF([test -s conftest.err],
rpm-build 324937
                [AS_VAR_SET([ac_var], [no])],
rpm-build 324937
                [AS_VAR_SET([ac_var], [yes])])],
rpm-build 324937
            [AS_VAR_SET([ac_var], [no])])
rpm-build 324937
    ])
rpm-build 324937
rpm-build 324937
    AS_IF([test yes = AS_VAR_GET([ac_var])],
rpm-build 324937
        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3_ATTRIBUTE_FALLTHROUGH), 1,
rpm-build 324937
            [Define to 1 if the system has the $4-style `fallthrough' attribute])], [])
rpm-build 324937
rpm-build 324937
    AS_VAR_POPDEF([ac_var])
rpm-build 324937
])
rpm-build 324937
rpm-build 324937
AC_DEFUN([DLP_FALLTHROUGH], [
rpm-build 324937
    _DLP_FALLTHROUGH([[__attribute__((fallthrough))]], [gcc], [GCC], [GNU])
rpm-build 324937
    _DLP_FALLTHROUGH([[[[clang:fallthrough]]]], [clang], [CLANG], [clang])
rpm-build 324937
])