From 5544dbeb1cedb43b8cc9c81e70228cabdfbd26bb Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 9 Dec 2019 00:22:45 +0100 Subject: [PATCH] cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast msg to (const char *) in conditional... * cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast msg to (const char *) in conditional expressions. Formatting fixes. From-SVN: r279101 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/cvt.c | 26 ++++++++++++++------------ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5cb63da5a88..a3fe71e222d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-12-08 Jakub Jelinek + + * cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast + msg to (const char *) in conditional expressions. Formatting fixes. + 2019-12-07 Jason Merrill Jakub Jelinek diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index cde3760886a..e922e4d9b89 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1044,12 +1044,13 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) tree args = TREE_VALUE (attr); if (args) msg.escape (TREE_STRING_POINTER (TREE_VALUE (args))); - const char* format = (msg ? - G_("ignoring return value of %qD, " - "declared with attribute %: %<%s%>") : - G_("ignoring return value of %qD, " - "declared with attribute %%s")); - const char* raw_msg = msg ? msg : ""; + const char *format + = (msg + ? G_("ignoring return value of %qD, " + "declared with attribute %: %<%s%>") + : G_("ignoring return value of %qD, " + "declared with attribute %%s")); + const char *raw_msg = msg ? (const char *) msg : ""; auto_diagnostic_group d; if (warning_at (loc, OPT_Wunused_result, format, fn, raw_msg)) inform (DECL_SOURCE_LOCATION (fn), "declared here"); @@ -1061,12 +1062,13 @@ maybe_warn_nodiscard (tree expr, impl_conv_void implicit) tree args = TREE_VALUE (attr); if (args) msg.escape (TREE_STRING_POINTER (TREE_VALUE (args))); - const char* format = msg ? - G_("ignoring returned value of type %qT, " - "declared with attribute %: %<%s%>") : - G_("ignoring returned value of type %qT, " - "declared with attribute %%s"); - const char* raw_msg = msg ? msg : ""; + const char *format + = (msg + ? G_("ignoring returned value of type %qT, " + "declared with attribute %: %<%s%>") + : G_("ignoring returned value of type %qT, " + "declared with attribute %%s")); + const char *raw_msg = msg ? (const char *) msg : ""; auto_diagnostic_group d; if (warning_at (loc, OPT_Wunused_result, format, rettype, raw_msg)) { -- 2.30.2