On 06/19/15 12:23, Bruce Evans wrote:
On Fri, 19 Jun 2015, Dimitry Andric wrote:

On 19 Jun 2015, at 17:02, Pedro Giffuni <p...@freebsd.org> wrote:

On 19/06/2015 05:16 a.m., David Chisnall wrote:
I only just caught this (having seen the fallout from NetBSD doing the same thing in a shipping release and the pain that it’s caused):

__weak is a reserved keyword in Objective-C, please pick another name for this. This in cdefs.h makes it impossible to include any FreeBSD standard headers in Objective-C programs (of which we have a couple of hundred in ports) if they use any of the modern Objective-C language modes.
...
Closely related to this, we are redefining _Noreturn, which is a reserved keyword in C11.

No, sys/cdefs.h has:

  254  /*
  255   * Keywords added in C11.
  256   */
  257
258 #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint)
[...]
  284  #if defined(__cplusplus) && __cplusplus >= 201103L
  285  #define _Noreturn               [[noreturn]]
  286  #else
  287  #define _Noreturn               __dead2
  288  #endif
[...]
  320  #endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */

So the whole block redefining all the _Xxx identifiers is skipped for
C11 and higher.

I probably pointed this out incorrectly to Pedro.

All uses of _Noreturn are still broken, and also ugly.  __dead2 is the
gcc-2 compatible version of the gcc-1 compatible macro __dead.  It is
syntactically different from __dead and _Noreturn.  It must be placed
after the function parameter list instead of in the function type
declarator because old versions of gcc only accept attributes there.
__dead and presumably _Noreturn must be placed in the function type
declarator.  This is incompatible, and also uglier.

I was thinking that _Noreturn can be fixed for older compilers
less disruptively.

I haven't tested the attached patch the idea is to resurrect
__dead and use it for _Noreturn.

Correct version with ugly declarations:

__dead void
    foo(void) __dead2;


With the patch we would use:

__Noreturn void
   foo(void) _dead2;

Which is still ugly but C11-ish.

Pedro.
Index: sys/sys/cdefs.h
===================================================================
--- sys/sys/cdefs.h	(revision 284643)
+++ sys/sys/cdefs.h	(working copy)
@@ -207,6 +207,7 @@
  * a feature that we cannot live without.
  */
 #ifdef lint
+#define	__dead
 #define	__dead2
 #define	__pure2
 #define	__unused
@@ -217,11 +218,13 @@
 #else
 #define	__weak		__attribute__((__weak__))
 #if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
+#define	__dead		__volatile
 #define	__dead2
 #define	__pure2
 #define	__unused
 #endif
 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
+#define	__dead		__attribute__((__noreturn__))
 #define	__dead2		__attribute__((__noreturn__))
 #define	__pure2		__attribute__((__const__))
 #define	__unused
@@ -284,7 +287,7 @@
 #if defined(__cplusplus) && __cplusplus >= 201103L
 #define	_Noreturn		[[noreturn]]
 #else
-#define	_Noreturn		__dead2
+#define	_Noreturn		__dead
 #endif
 
 #if !__has_extension(c_static_assert)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to