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]

[PATCH] Fix PR39732


We still inline non-SSA form, so if building addresses, the inliner
needs to mark the underlying decl as TREE_ADDRESSABLE.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-04-11  Richard Guenther  <rguenther@suse.de>

	PR middle-end/39732
	* tree-inline.c (declare_return_variable): Mark DECL_BY_REFERENCE
	return variables as TREE_ADDRESSABLE.

	* g++.dg/torture/pr39732.C: New testcase.

Index: gcc/tree-inline.c
===================================================================
*** gcc/tree-inline.c	(revision 145949)
--- gcc/tree-inline.c	(working copy)
*************** declare_return_variable (copy_body_data 
*** 2386,2392 ****
    STRIP_USELESS_TYPE_CONVERSION (use);
  
    if (DECL_BY_REFERENCE (result))
!     var = build_fold_addr_expr (var);
  
   done:
    /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
--- 2386,2395 ----
    STRIP_USELESS_TYPE_CONVERSION (use);
  
    if (DECL_BY_REFERENCE (result))
!     {
!       TREE_ADDRESSABLE (var) = 1;
!       var = build_fold_addr_expr (var);
!     }
  
   done:
    /* Register the VAR_DECL as the equivalent for the RESULT_DECL; that
Index: gcc/testsuite/g++.dg/torture/pr39732.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr39732.C	(revision 0)
--- gcc/testsuite/g++.dg/torture/pr39732.C	(revision 0)
***************
*** 0 ****
--- 1,29 ----
+ /* { dg-do compile } */
+ /* { dg-options "-fprofile-generate" } */
+ 
+ template<class _CharT>     struct char_traits;
+ template<typename _OI>
+ _OI __copy_move_a2(_OI __result);
+ template<typename _OI>     inline _OI
+ copy(_OI __result)
+ {
+   return __copy_move_a2 (__result);
+ }
+ template<typename _CharT, typename _Traits>
+ class basic_ostream     { };
+ template<typename _Tp, typename _CharT = char, typename _Traits = char_traits<_CharT> >
+ class ostream_iterator      {
+     typedef basic_ostream<_CharT, _Traits> ostream_type;
+     ostream_type* _M_stream;
+     const _CharT* _M_string;
+ public:
+     ostream_iterator(ostream_type& __s, const _CharT* __c)
+ 	: _M_stream(&__s), _M_string(__c) { }
+     ostream_iterator(const ostream_iterator& __obj)
+ 	: _M_stream(__obj._M_stream), _M_string(__obj._M_string) { }
+ };
+ int f(void)
+ {
+   basic_ostream<char, char_traits<char> > os;
+   copy(ostream_iterator<const int>(os, ","));
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]