re PR c++/36959 (C++ front-end causing a static inline function to be emitted)

PR c++/36959
	* decl2.c (cxx_callgraph_analyze_expr): Don't reference a function
	just because a static variable in it is needed unless -frepo.

From-SVN: r153881
This commit is contained in:
Jason Merrill 2009-11-03 18:49:07 -05:00 committed by Jason Merrill
parent dba7b0d7e6
commit 9259b8526e
4 changed files with 31 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/36959
* decl2.c (cxx_callgraph_analyze_expr): Don't reference a function
just because a static variable in it is needed unless -frepo.
2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/41876

View File

@ -3278,6 +3278,7 @@ cxx_callgraph_analyze_expr (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED)
mark_decl_referenced (vtbl);
}
else if (DECL_CONTEXT (t)
&& flag_use_repository
&& TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
/* If we need a static variable in a function, then we
need the containing function. */

View File

@ -1,3 +1,8 @@
2009-11-03 Jason Merrill <jason@redhat.com>
PR c++/36959
* g++.dg/opt/inline16.C: New.
2009-11-03 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/41917

View File

@ -0,0 +1,19 @@
// PR c++/36959
// We shouldn't have to emit fromSlotB just because we need shuf_BZZZ.
// { dg-options -O }
// { dg-final { scan-assembler-not "_ZL9fromSlotBv" } }
static inline int *fromSlotB(void)
{
static int shuf_BZZZ = 1;
return &shuf_BZZZ;
}
int *p;
int main(void)
{
p = fromSlotB();
return (*p != 1);
}