public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: FX <fxcoudert@gmail.com>
To: fortran@gcc.gnu.org
Cc: gcc-patches@gcc.gnu.org
Subject: [libgfortran, patch] Silence a warning in libgfortran's runtime/error.c
Date: Tue, 08 Nov 2011 10:51:00 -0000	[thread overview]
Message-ID: <F8F2D535-362D-4012-B776-414CD453B961@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

This patch for PR 47972 uses __builtin_choose_expr instead of the current if-else, avoiding the type warning for the branch not taken. This was suggested by Jakub in the PR itself.

Bootstrapped and regtested on x86_64-linux, OK to commit to trunk?
FX


[-- Attachment #2: typewarning.ChangeLog --]
[-- Type: application/octet-stream, Size: 135 bytes --]

2011-11-08  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>

	PR libfortran/47972
	* runtime/error.c (gf_strerror): Silence warning.


[-- Attachment #3: typewarning.diff --]
[-- Type: application/octet-stream, Size: 1051 bytes --]

Index: runtime/error.c
===================================================================
--- runtime/error.c	(revision 181149)
+++ runtime/error.c	(working copy)
@@ -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.  */

             reply	other threads:[~2011-11-08 10:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 10:51 FX [this message]
2011-11-08 21:21 ` Janne Blomqvist

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F8F2D535-362D-4012-B776-414CD453B961@gmail.com \
    --to=fxcoudert@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).