aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-03 18:02:41 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-11-03 18:02:41 -0500
commit9a6f7249ea868e4c0dea0fb518fcfe187a89f2e4 (patch)
treed6abc525c90e2aebbf0386943c1919f9485ece55 /gcc
parentd809253a56a642cdeb31f3f12e420f092cee0d07 (diff)
downloadgcc-9a6f7249ea868e4c0dea0fb518fcfe187a89f2e4.zip
gcc-9a6f7249ea868e4c0dea0fb518fcfe187a89f2e4.tar.gz
gcc-9a6f7249ea868e4c0dea0fb518fcfe187a89f2e4.tar.bz2
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: r153878
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl2.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/opt/inline16.C19
4 files changed, 29 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 21adec9..2ef626d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +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.
+
PR c++/41876
* parser.c (cp_parser_type_specifier_seq): Rename is_condition to
is_declaration.
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b1fe4b9..dbb9fb4 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3310,6 +3310,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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a499e2..f525db0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-03 Jason Merrill <jason@redhat.com>
+
+ PR c++/36959
+ * g++.dg/opt/inline16.C: New.
+
2009-11-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/stack_check.adb1: New test.
diff --git a/gcc/testsuite/g++.dg/opt/inline16.C b/gcc/testsuite/g++.dg/opt/inline16.C
new file mode 100644
index 0000000..6ee6d76
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/inline16.C
@@ -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);
+}
+