From d4ee8943cf24b460e938e903c0bfaaaf25706fe9 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 11 Jun 2010 09:50:29 +0200 Subject: [PATCH] tests: avoid compilation warnings in argmatch and exclude tests... in packages that define ARGMATCH_DIE_DECL, like coreutils. * tests/test-exclude.c [ARGMATCH_DIE_DECL]: Also declare the function. Since it always exits, declare with the "noreturn" attribute. * tests/test-argmatch.c: Likewise. --- ChangeLog | 6 ++++++ tests/test-argmatch.c | 11 +++++++++++ tests/test-exclude.c | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5b037a4cc..d96f7fe99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-06-11 Jim Meyering + tests: avoid compilation warnings in argmatch and exclude tests... + in packages that define ARGMATCH_DIE_DECL, like coreutils. + * tests/test-exclude.c [ARGMATCH_DIE_DECL]: Also declare the function. + Since it always exits, declare with the "noreturn" attribute. + * tests/test-argmatch.c: Likewise. + tests: avoid 'const' discard warnings in mbsstr tests * tests/test-mbsstr1.c (main): Add "const" to avoid trivial warning. * tests/test-mbsstr2.c (main): Likewise. diff --git a/tests/test-argmatch.c b/tests/test-argmatch.c index 807970e2c..bf4a22f92 100644 --- a/tests/test-argmatch.c +++ b/tests/test-argmatch.c @@ -29,6 +29,17 @@ /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in , and thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(x) /* empty */ +# endif +#endif + +#ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#endif + +ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } #endif diff --git a/tests/test-exclude.c b/tests/test-exclude.c index bffc62d20..0b8f9534e 100644 --- a/tests/test-exclude.c +++ b/tests/test-exclude.c @@ -63,6 +63,17 @@ ARGMATCH_VERIFY (exclude_keywords, exclude_flags); /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in , and thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(x) /* empty */ +# endif +#endif + +#ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#endif + +ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } #endif -- 2.11.0