diff options
author | Jim Meyering <meyering@redhat.com> | 2010-03-23 09:35:45 +0100 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-03-23 09:35:45 +0100 |
commit | ce050df795d2dd825e866d368423b886d6eac4ef (patch) | |
tree | 46f119433c727dde474f2711a76962d51e0a1d86 | |
parent | 8a3a47de77958ec2781b94068919083d8abde388 (diff) | |
download | grep-ce050df795d2dd825e866d368423b886d6eac4ef.tar.gz |
build: avoid warnings: tell gcc and clang that dfaerror never returns
* src/dfa.h (__attribute__): Define.
(dfaerror): Declare with the "noreturn" attribute.
* src/dfasearch.c (dfaerror): Add an unreachable use of abort.
-rw-r--r-- | src/dfa.h | 6 | ||||
-rw-r--r-- | src/dfasearch.c | 4 |
2 files changed, 9 insertions, 1 deletions
@@ -39,6 +39,10 @@ /* Number of ints required to hold a bit for every character. */ #define CHARCLASS_INTS ((NOTCHAR + INTBITS - 1) / INTBITS) +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__ +# define __attribute__(x) +#endif + /* Sets of unsigned characters are stored as bit vectors in arrays of ints. */ typedef int charclass[CHARCLASS_INTS]; @@ -429,4 +433,4 @@ extern void dfastate (int, struct dfa *, int []); /* dfaerror() is called by the regexp routines whenever an error occurs. It takes a single argument, a NUL-terminated string describing the error. The user must supply a dfaerror. */ -extern void dfaerror (const char *); +extern void dfaerror (const char *) __attribute__ ((noreturn)); diff --git a/src/dfasearch.c b/src/dfasearch.c index 996effdb..a43f822a 100644 --- a/src/dfasearch.c +++ b/src/dfasearch.c @@ -49,6 +49,10 @@ void dfaerror (char const *mesg) { error (EXIT_TROUBLE, 0, "%s", mesg); + + /* notreached */ + /* Tell static analyzers that this function does not return. */ + abort (); } /* Number of compiled fixed strings known to exactly match the regexp. |