https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64272

            Bug ID: 64272
           Summary: useless "called from here" for inline failed
                    error/warning
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org
                CC: schwab at gcc dot gnu.org

Notice here: https://sourceware.org/ml/libc-alpha/2014-12/msg00300.html

It is useless to print the additional "called from here" (which should be an
inform note) if there is no location. Also, in the case of warning, there is no
point in giving the additional note if no warning was emitted.

I would argue that it would be better to print first the location of the call
and then give a note saying "declared here", like we do for other similar
warnings. However, since there may be no location for the call (???!!!), I
guess we can make do with something like the patch below.

I don't actually have a testcase. Andreas, could you extract one from the glibc
sources? Thanks!

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c   (revision 218628)
+++ gcc/tree-inline.c   (working copy)
@@ -4383,13 +4383,15 @@ expand_call_inline (basic_block bb, gimp
              || !optimize
              || cgraph_inline_failed_type (reason) == CIF_FINAL_ERROR)
          /* PR 20090218-1_0.c. Body can be provided by another module. */
          && (reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
        {
+         /* See https://sourceware.org/ml/libc-alpha/2014-12/msg00300.html */
          error ("inlining failed in call to always_inline %q+F: %s", fn,
                 cgraph_inline_failed_string (reason));
-         error ("called from here");
+         if (input_location != UNKNWON_LOCATION)
+           inform (input_location, "called from here");
        }
       else if (warn_inline
               && DECL_DECLARED_INLINE_P (fn)
               && !DECL_NO_INLINE_WARNING_P (fn)
               && !DECL_IN_SYSTEM_HEADER (fn)
@@ -4398,13 +4400,14 @@ expand_call_inline (basic_block bb, gimp
               /* Do not warn about not inlined recursive calls.  */
               && !cg_edge->recursive_p ()
               /* Avoid warnings during early inline pass. */
               && symtab->global_info_ready)
        {
-         warning (OPT_Winline, "inlining failed in call to %q+F: %s",
-                  fn, _(cgraph_inline_failed_string (reason)));
-         warning (OPT_Winline, "called from here");
+         if (warning (OPT_Winline, "inlining failed in call to %q+F: %s",
+                      fn, _(cgraph_inline_failed_string (reason)))
+             && input_location != UNKNWON_LOCATION)
+           inform (input_location, "called from here");
        }
       goto egress;
     }
   fn = cg_edge->callee->decl;
   cg_edge->callee->get_untransformed_body ();

Reply via email to