This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 10180


This patch fixes a regression in -Winline.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-04-28  Mark Mitchell  <mark at codesourcery dot 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  Mark Mitchell  <mark at codesourcery dot com>

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

Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.38.2.6
diff -c -5 -p -r1.38.2.6 tree-inline.c
*** tree-inline.c	10 Apr 2003 14:44:27 -0000	1.38.2.6
--- tree-inline.c	29 Apr 2003 03:11:08 -0000
*************** expand_call_inline (tp, walk_subtrees, d
*** 1123,1132 ****
--- 1123,1145 ----
        return NULL_TREE;
  #else /* INLINER_FOR_JAVA */
        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
         them should not be expanded.  This can happen if the type is a
         dynamic array type, for example.  */
*************** expand_call_inline (tp, walk_subtrees, d
*** 1155,1165 ****
      fn = DECL_ABSTRACT_ORIGIN (fn);
  
    /* Don't try to inline functions that are not well-suited to
       inlining.  */
    if (!inlinable_function_p (fn, id))
!     return NULL_TREE;
  
    if (! (*lang_hooks.tree_inlining.start_inlining) (fn))
      return NULL_TREE;
  
    /* Set the current filename and line number to the function we are
--- 1168,1185 ----
      fn = DECL_ABSTRACT_ORIGIN (fn);
  
    /* Don't try to inline functions that are not well-suited to
       inlining.  */
    if (!inlinable_function_p (fn, id))
!     {
!       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;
  
    /* Set the current filename and line number to the function we are
Index: testsuite/g++.dg/warn/Winline-1.C
===================================================================
RCS file: testsuite/g++.dg/warn/Winline-1.C
diff -N testsuite/g++.dg/warn/Winline-1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Winline-1.C	29 Apr 2003 03:11:42 -0000
***************
*** 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]