Our <sys/cdefs.h> only defines these if when __STRICT_ANSI__ isn't
defined.  As a result, functions like exit(3) are not properly marked
as "noreturn".  This in turn makes compilers complain that other
"noreturn" functions actually may return.

This is most visible in various llvm projects that tend to be compiled
with -std=c++11 or -std=c++14 and therefore are compiled with
__STRICT_ANSI__ defined.  It looks like the !defined(__STRICT_ANSI__)
condition was inherited from the pre-gcc-2.5 case, where warnings
would be generated in "strict" mode.  But that doesn't happen with the
post-gcc-2.5 case, so the __STRICT_ANSI__ check isn't necessary.

Alternatively we could gut the pre-gcc-2.5 case completely and simply
change this into:

#if __GNUC_PREREQ__(2, 5)
#define __dead          __attribute__((__noreturn__))
#define __pure          __attribute__((__const__))
#else
#define __dead
#define __pure
#endif

Thoughts?  ok?  Should this wait a bit to get better testing in ports?


Index: sys/cdefs.h
===================================================================
RCS file: /cvs/src/sys/sys/cdefs.h,v
retrieving revision 1.40
diff -u -p -r1.40 cdefs.h
--- sys/cdefs.h 6 Jan 2017 14:22:30 -0000       1.40
+++ sys/cdefs.h 4 Apr 2017 21:47:13 -0000
@@ -102,7 +102,7 @@
 #define        __dead          __volatile
 #define        __pure          __const
 #endif
-#elif !defined(__STRICT_ANSI__)
+#else
 #define __dead         __attribute__((__noreturn__))
 #define __pure         __attribute__((__const__))
 #endif

Reply via email to