On 12/7/19 3:50 AM, Jakub Jelinek wrote:
On Fri, Dec 06, 2019 at 06:43:35PM -0800, Andrew Pinski wrote:
Hi all,
   Right now the trunk does not compile with GCC 4.4.7 (the GCC that
comes with CentOS 6; yes I know old) after revision 277200 (October
19).

AFAIK we haven't switched to requiring C++11 at which point we'd need to
bump minimal system GCC requirement to 4.8-ish or so, so currently we
should support building with even GCC 4.1-ish.

The error message is:
../../gcc/gcc/cp/cvt.c:1043: error: operands to ?: have different
types ‘escaped_string’ and ‘const char [1]’
../../gcc/gcc/cp/cvt.c:1060: error: operands to ?: have different
types ‘escaped_string’ and ‘const char [1]’

Indeed.  I think it is r151113 or r151114 that fixed that.

Is it acceptable to put in a workaround for this?

Yes.  I'd suggest to also fix the formatting around (? and : at the end
of lines), so something like this?
I've tested the workaround back to GCC r80000.
Note, not accepting the code as is clearly has been a regression in GCC 3.4
to 4.4, as GCC 3.2 or 3.3 happily accept that.

Ok for trunk if it passes bootstrap/regtest?

OK.

2019-12-07  Jakub Jelinek  <ja...@redhat.com>

        * cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast
        msg to (const char *) in conditional expressions.  Formatting fixes.

--- gcc/cp/cvt.c.jj     2019-12-04 10:26:36.000000000 +0100
+++ gcc/cp/cvt.c        2019-12-07 09:39:58.145990796 +0100
@@ -1044,12 +1044,13 @@ maybe_warn_nodiscard (tree expr, impl_co
        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 %<nodiscard%>: %<%s%>") :
-       G_("ignoring return value of %qD, "
-          "declared with attribute %<nodiscard%>%s"));
-      const char* raw_msg = msg ? msg : "";
+      const char *format
+       = (msg
+          ? G_("ignoring return value of %qD, "
+               "declared with attribute %<nodiscard%>: %<%s%>")
+          : G_("ignoring return value of %qD, "
+               "declared with attribute %<nodiscard%>%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_co
        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 %<nodiscard%>: %<%s%>") :
-       G_("ignoring returned value of type %qT, "
-          "declared with attribute %<nodiscard%>%s");
-      const char* raw_msg = msg ? msg : "";
+      const char *format
+       = (msg
+          ? G_("ignoring returned value of type %qT, "
+               "declared with attribute %<nodiscard%>: %<%s%>")
+          : G_("ignoring returned value of type %qT, "
+               "declared with attribute %<nodiscard%>%s"));
+      const char *raw_msg = msg ? (const char *) msg : "";
        auto_diagnostic_group d;
        if (warning_at (loc, OPT_Wunused_result, format, rettype, raw_msg))
        {


        Jakub


Reply via email to