octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'noreturn' warning in libcruft


From: Michael Goffioul
Subject: Re: 'noreturn' warning in libcruft
Date: Tue, 7 Aug 2012 20:08:11 +0100

On Tue, Aug 7, 2012 at 7:14 PM, John W. Eaton <address@hidden> wrote:
On  7-Aug-2012, Rik wrote:

|
| >
| >
| > I know what you're trying to do and I know why the return statement will
| > never get reached. But I also know that with no-GCC compilers,
| > GCC_ATTR_NORETURN will not be defined and this then may generate a
| > compiler error as the return statement will now be missing.
| >
| > So it's basically a choice between getting rid of a GCC warning and
| > (possibly) introducing a compilation error with other compilers.
| If it is a specific compiler behavior that we are using then why not test
| for it as is already done for the GCC_ATTR_NORETURN macro?  The following
| silences the warning for me and should work with the other compilers that
| want a return statement.
|
| #ifndef __GNUC__
|   F77_RETURN (0)
| #endif

The attached diff is what I had in mind.

jwe


diff --git a/libcruft/misc/f77-fcn.c b/libcruft/misc/f77-fcn.c
--- a/libcruft/misc/f77-fcn.c
+++ b/libcruft/misc/f77-fcn.c
@@ -60,5 +60,5 @@

   octave_jump_to_enclosing_context ();

-  F77_RETURN (0)
+  F77_NORETURN (0)
 }
diff --git a/libcruft/misc/f77-fcn.h b/libcruft/misc/f77-fcn.h
--- a/libcruft/misc/f77-fcn.h
+++ b/libcruft/misc/f77-fcn.h
@@ -108,6 +108,11 @@

 #define F77_RET_T int
 #define F77_RETURN(retval) return retval;
+#if defined (GCC_ATTR_NORETURN)
+#define F77_NORETURN(retval)
+#else
+#define F77_NORETURN(retval) return retval;
+#endif

 /* FIXME -- these should work for SV1 or Y-MP systems but will
    need to be changed for others.  */
@@ -176,7 +181,8 @@
 #define F77_CHAR_ARG_LEN_USE(s, len) len

 #define F77_RET_T void
-#define F77_RETURN(retval)
+#define F77_RETURN(retval) return;
+#define F77_NORETURN(retval)

 #else

@@ -203,6 +209,11 @@

 #define F77_RET_T int
 #define F77_RETURN(retval) return retval;
+#if defined (GCC_ATTR_NORETURN)
+#define F77_NORETURN(retval)
+#else
+#define F77_NORETURN(retval) return retval;
+#endif

 #endif



Won't GCC_ATTR_NORETURN always be defined, to something relevant or the empty string (otherwise you'd get a compilation error)? In that case, the above change won't have the expected result.

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]