OSDN Git Service

PR libfortran/47972
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Nov 2011 21:58:47 +0000 (21:58 +0000)
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 8 Nov 2011 21:58:47 +0000 (21:58 +0000)
* runtime/error.c (gf_strerror): Silence warning.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181180 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/runtime/error.c

index becb601..3a2db6d 100644 (file)
@@ -1,5 +1,10 @@
 2011-11-08  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
+       PR libfortran/47972
+       * runtime/error.c (gf_strerror): Silence warning.
+
+2011-11-08  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
        PR libfortran/47970
        * intrinsics/c99_functions.c (round): Move higher in the file.
 
index aa44706..cb06429 100644 (file)
@@ -219,19 +219,13 @@ gf_strerror (int errnum,
             size_t buflen __attribute__((unused)))
 {
 #ifdef HAVE_STRERROR_R
-  /* TODO: How to prevent the compiler warning due to strerror_r of
-     the untaken branch having the wrong return type?  */
-  if (__builtin_classify_type (strerror_r (0, buf, 0)) == 5)
-    {
-      /* GNU strerror_r()  */
-      return strerror_r (errnum, buf, buflen);
-    }
-  else
-    {
-      /* POSIX strerror_r ()  */
-      strerror_r (errnum, buf, buflen);
-      return buf;
-    }
+  return
+    __builtin_choose_expr (__builtin_classify_type (strerror_r (0, buf, 0))
+                          == 5,
+                          /* GNU strerror_r()  */
+                          strerror_r (errnum, buf, buflen),
+                          /* POSIX strerror_r ()  */
+                          (strerror_r (errnum, buf, buflen), buf));
 #else
   /* strerror () is not necessarily thread-safe, but should at least
      be available everywhere.  */