]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/10180 (gcc fails to warn about non-inlined function)
authorMark Mitchell <mark@codesourcery.com>
Tue, 29 Apr 2003 03:24:27 +0000 (03:24 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 29 Apr 2003 03:24:27 +0000 (03:24 +0000)
PR c++/10180
* tree-inline.c (expand_call_inline): Call push_srcloc when
encountering EXPR_WITH_FILE_LOCATION.  Honor warn_inline.

PR c++/10180
* g++.dg/warn/Winline-1.C: New test.

From-SVN: r66202

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Winline-1.C [new file with mode: 0644]
gcc/tree-inline.c

index 679c0be91eb58e283ba937c5cbaeaaca2bd20ec4..c848eba880d93731d7a366326ae8f5e4439b6cd7 100644 (file)
@@ -1,3 +1,9 @@
+2003-04-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10180
+       * tree-inline.c (expand_call_inline): Call push_srcloc when
+       encountering EXPR_WITH_FILE_LOCATION.  Honor warn_inline.
+
 2003-04-28  Mike Stump  <mrs@apple.com>
 
        * gdbinit.in: Update to reflect new identifier structure.
index ccd7e529dfc5ac5b984e1a5e3fdf7596a0dfc19a..b0d8e7587e9c6d3ba2aabe3575e3c0ad597bb4d5 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-28  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/10180
+       * g++.dg/warn/Winline-1.C: New test.
+
 2003-04-28  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/execute/string-opt-19.c: New test.
diff --git a/gcc/testsuite/g++.dg/warn/Winline-1.C b/gcc/testsuite/g++.dg/warn/Winline-1.C
new file mode 100644 (file)
index 0000000..2f8b39c
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-Winline -O2" }
+
+static inline int foo(int x); // { dg-warning "" }
+
+int main()
+{
+  return(foo(17)); // { dg-warning "" }
+}
+
+inline int foo(int x) {  return(x);  }
index 22298a017970f4668c2f18c00b55be813155fc71..3a8adc51e2ee8a0aa0a33603ceb1f0280ed6f17e 100644 (file)
@@ -1139,6 +1139,19 @@ expand_call_inline (tp, walk_subtrees, data)
       abort ();
 #endif /* INLINER_FOR_JAVA */
     }
+  else if (TREE_CODE (t) == EXPR_WITH_FILE_LOCATION)
+    {
+      /* We're walking the subtree directly.  */
+      *walk_subtrees = 0;
+      /* Update the source position.  */
+      push_srcloc (EXPR_WFL_FILENAME (t), EXPR_WFL_LINENO (t));
+      walk_tree (&EXPR_WFL_NODE (t), expand_call_inline, data, 
+                id->tree_pruner);
+      /* Restore the original source position.  */
+      pop_srcloc ();
+
+      return NULL_TREE;
+    }
 
   if (TYPE_P (t))
     /* Because types were not copied in copy_body, CALL_EXPRs beneath
@@ -1173,7 +1186,14 @@ expand_call_inline (tp, walk_subtrees, data)
   if ((!flag_unit_at_a_time || !DECL_SAVED_TREE (fn)
        || !cgraph_global_info (fn)->inline_once)
       && !inlinable_function_p (fn, id, 0))
-    return NULL_TREE;
+    {
+      if (warn_inline && DECL_INLINE (fn))
+       {
+         warning_with_decl (fn, "inlining failed in call to `%s'");
+         warning ("called from here");
+       }
+      return NULL_TREE;
+    }
 
   if (! (*lang_hooks.tree_inlining.start_inlining) (fn))
     return NULL_TREE;