re PR lto/42401 (wrong-code with -flto)

2009-12-19  Richard Guenther  <rguenther@suse.de>

	PR lto/42401
	* lto-streamer-out.c (tree_is_indexable): Local statics
	are indexable.
	(lto_output_tree_ref): Adjust assert.

	* g++.dg/lto/20091219_0.C: New testcase.

From-SVN: r155361
This commit is contained in:
Richard Guenther 2009-12-19 11:41:14 +00:00 committed by Richard Biener
parent d0ca0bcb2c
commit b0ce048a3f
4 changed files with 33 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2009-12-19 Richard Guenther <rguenther@suse.de>
PR lto/42401
* lto-streamer-out.c (tree_is_indexable): Local statics
are indexable.
(lto_output_tree_ref): Adjust assert.
2009-12-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42108

View File

@ -638,7 +638,8 @@ tree_is_indexable (tree t)
{
if (TREE_CODE (t) == PARM_DECL)
return false;
else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t))
else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t)
&& !TREE_STATIC (t))
return false;
else
return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
@ -694,7 +695,8 @@ lto_output_tree_ref (struct output_block *ob, tree expr)
case VAR_DECL:
case DEBUG_EXPR_DECL:
gcc_assert (decl_function_context (expr) == NULL);
gcc_assert (decl_function_context (expr) == NULL
|| TREE_STATIC (expr));
output_record_start (ob, LTO_global_decl_ref);
lto_output_var_decl_index (ob->decl_state, ob->main_stream, expr);
break;

View File

@ -1,3 +1,8 @@
2009-12-19 Richard Guenther <rguenther@suse.de>
PR lto/42401
* g++.dg/lto/20091219_0.C: New testcase.
2009-12-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42108

View File

@ -0,0 +1,17 @@
// { dg-lto-do run }
// { dg-lto-options {{-O3 -flto}} }
#include <string>
#include <map>
int main ()
{
typedef std::map<int, std::string> Map;
static Map m;
Map::const_iterator it = m.find(0);
if (it != m.end())
std::string s = it->second;
return 0;
}