Blame gnulib-tests/test-ignore-value.c

Packit 709fb3
/* Test the "ignore-value" module.
Packit 709fb3
Packit 709fb3
   Copyright (C) 2011-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software: you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3 of the License, or
Packit 709fb3
   (at your option) any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
/* Written by Eric Blake.  */
Packit 709fb3
Packit 709fb3
#include <config.h>
Packit 709fb3
Packit 709fb3
#include "ignore-value.h"
Packit 709fb3
Packit 709fb3
#include <stdio.h>
Packit 709fb3
Packit 709fb3
#ifndef _GL_ATTRIBUTE_RETURN_CHECK
Packit 709fb3
# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
Packit 709fb3
#  define _GL_ATTRIBUTE_RETURN_CHECK
Packit 709fb3
# else
Packit 709fb3
#  define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
struct s { int i; };
Packit 709fb3
static char doChar (void) _GL_ATTRIBUTE_RETURN_CHECK;
Packit 709fb3
static int doInt (void) _GL_ATTRIBUTE_RETURN_CHECK;
Packit 709fb3
static off_t doOff (void) _GL_ATTRIBUTE_RETURN_CHECK;
Packit 709fb3
static void *doPtr (void) _GL_ATTRIBUTE_RETURN_CHECK;
Packit 709fb3
static struct s doStruct (void) _GL_ATTRIBUTE_RETURN_CHECK;
Packit 709fb3
Packit 709fb3
static char
Packit 709fb3
doChar (void)
Packit 709fb3
{
Packit 709fb3
  return 0;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
static int
Packit 709fb3
doInt (void)
Packit 709fb3
{
Packit 709fb3
  return 0;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
static off_t
Packit 709fb3
doOff (void)
Packit 709fb3
{
Packit 709fb3
  return 0;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
static void *
Packit 709fb3
doPtr (void)
Packit 709fb3
{
Packit 709fb3
  return NULL;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
static struct s
Packit 709fb3
doStruct (void)
Packit 709fb3
{
Packit 709fb3
  static struct s s1;
Packit 709fb3
  return s1;
Packit 709fb3
}
Packit 709fb3
Packit 709fb3
int
Packit 709fb3
main (void)
Packit 709fb3
{
Packit 709fb3
  /* If this test can compile with -Werror and the same warnings as
Packit 709fb3
     the rest of the project, then we are properly silencing warnings
Packit 709fb3
     about ignored return values.  */
Packit 709fb3
  ignore_value (doChar ());
Packit 709fb3
  ignore_value (doInt ());
Packit 709fb3
  ignore_value (doOff ());
Packit 709fb3
  ignore_value (doPtr ());
Packit 709fb3
  ignore_value (doStruct ());
Packit 709fb3
  return 0;
Packit 709fb3
}