]> granicus.if.org Git - check/commitdiff
Add noreturn attribute to select functions and added -Wmissing-noreturn
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 23 Sep 2013 17:58:09 +0000 (17:58 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 23 Sep 2013 17:58:09 +0000 (17:58 +0000)
Added the gcc attribute noreturn to a few functions that could use it
(but only if the compiler is gcc 2.5 >=),  and added the warning to
point out when a function should use noreturn.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@791 64e312b2-a51f-0410-8e61-82d0ca0eb02a

configure.ac
lib/libcompat.h
src/check.h.in
src/check_error.h

index c7ea3e9e9f94b49b462443ca0b25a9ca07d1260d..08a19ac54ce4de10c766b8f6822ff13c7381f2ef 100644 (file)
@@ -123,7 +123,7 @@ AX_CFLAGS_ADD([-Winit-self])
 AX_CFLAGS_ADD([-Wmissing-include-dirs])
 AX_CFLAGS_ADD([-Wswitch-default])
 AX_CFLAGS_ADD([-Wunknown-pragmas])
-
+AX_CFLAGS_ADD([-Wmissing-noreturn])
 
 AC_CHECK_PROGS(GCOV, gcov, false)
 AC_CHECK_PROGS(LCOV, lcov, false)
index 12b4a0f9842ab1d0aeb5221bd931d9a2deb6d615..453253b74a9119c9fbdd30724550976493b0d35b 100644 (file)
 #define CK_ATTRIBUTE_UNUSED              
 #endif /* GCC 2.95 */
 
+#if GCC_VERSION_AT_LEAST(2,5)
+#define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#else
+#define CK_ATTRIBUTE_NORETURN
+#endif /* GCC 2.5 */
+
 /* defines size_t */
 #include <sys/types.h>
 
@@ -188,6 +194,6 @@ int rpl_asprintf(char **, const char *, ...);
 #endif /* HAVE_STDARG_H */
 
 /* silence warnings about an empty library */
-void ck_do_nothing (void);
+void ck_do_nothing (void) CK_ATTRIBUTE_NORETURN;
 
 #endif /* !LIBCOMPAT_H */
index 016f36079f30f83196d13eed1908eb547cb23027..4c437da8e724f576cb72309404e204601feebbcb 100644 (file)
@@ -105,6 +105,12 @@ CK_CPPSTART
 #define CK_ATTRIBUTE_UNUSED              
 #endif /* GCC 2.95 */
 
+#if GCC_VERSION_AT_LEAST(2,5)
+#define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn))
+#else
+#define CK_ATTRIBUTE_NORETURN
+#endif /* GCC 2.5 */
+
 #include <sys/types.h>
 
 /* Used to create the linker script for hiding lib-local symbols. Shall
@@ -487,7 +493,7 @@ void CK_EXPORT srunner_set_fork_status (SRunner *sr, enum fork_status fstat);
 pid_t CK_EXPORT check_fork(void);
 
 /* Wait for the pid and exit. If pid is zero, just exit. */
-void CK_EXPORT check_waitpid_and_exit(pid_t pid);
+void CK_EXPORT check_waitpid_and_exit(pid_t pid) CK_ATTRIBUTE_NORETURN;
 
 #ifdef __cplusplus 
 CK_CPPEND
index 75be45db7b7c883ae886e272502d16177453bd33..8d1f6a381771dcce7152a21e168e9a01766cf0d7 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef ERROR_H
 #define ERROR_H
 
+#include "../lib/libcompat.h"
 #include <setjmp.h>
 
 extern jmp_buf error_jmp_buffer;
@@ -29,7 +30,7 @@ extern jmp_buf error_jmp_buffer;
 
 /* Print error message and die
    If fmt ends in colon, include system error information */
-void eprintf (const char *fmt, const char *file, int line,...);
+void eprintf (const char *fmt, const char *file, int line,...) CK_ATTRIBUTE_NORETURN;
 /* malloc or die */
 void *emalloc(size_t n);
 void *erealloc(void *, size_t n);