* [libgfortran, patch] Silence a warning in libgfortran's runtime/error.c
@ 2011-11-08 10:51 FX
2011-11-08 21:21 ` Janne Blomqvist
0 siblings, 1 reply; 2+ messages in thread
From: FX @ 2011-11-08 10:51 UTC (permalink / raw)
To: fortran; +Cc: gcc-patches
[-- 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. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [libgfortran, patch] Silence a warning in libgfortran's runtime/error.c
2011-11-08 10:51 [libgfortran, patch] Silence a warning in libgfortran's runtime/error.c FX
@ 2011-11-08 21:21 ` Janne Blomqvist
0 siblings, 0 replies; 2+ messages in thread
From: Janne Blomqvist @ 2011-11-08 21:21 UTC (permalink / raw)
To: FX; +Cc: fortran, gcc-patches
On Tue, Nov 8, 2011 at 12:33, FX <fxcoudert@gmail.com> wrote:
> 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
Ok.
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-08 20:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08 10:51 [libgfortran, patch] Silence a warning in libgfortran's runtime/error.c FX
2011-11-08 21:21 ` Janne Blomqvist
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).