aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/opt/inline9.C29
-rw-r--r--gcc/tree-inline.c7
4 files changed, 44 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6b987df..fee4680 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-15 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR c++/17972
+ * tree-inline.c (expand_call_inline): Set TREE_SIDE_EFFECTS
+ on the STMT_EXPR wrapping up the inlined body.
+
2004-12-15 Vladimir Makarov <vmakarov@redhat.com>
Steven Bosscher <stevenb@suse.de>
PR middle end/17340
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 58d4e78..06dd868 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-12-15 Alan Modra <amodra@bigpond.net.au>
+
+ * g++.dg/opt/inline9.C: New test.
+
2004-12-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/18993
diff --git a/gcc/testsuite/g++.dg/opt/inline9.C b/gcc/testsuite/g++.dg/opt/inline9.C
new file mode 100644
index 0000000..10ccb47
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/inline9.C
@@ -0,0 +1,29 @@
+// PR c++/17972
+// Origin: Michal Ostrowski <mostrows@watson.ibm.com>
+// Testcase by Alan Modra <amodra@bigpond.net.au>
+// { dg-do run }
+// { dg-options "-O" }
+// { dg-options "-O -mtune=i686" { target i?86-*-* } }
+
+struct thread_info
+{
+ short preempt_count;
+} x;
+
+static inline struct thread_info *cti (void) __attribute__ ((const));
+static inline struct thread_info *cti (void)
+{
+ return &x;
+}
+
+void fn (void) __attribute__ ((noinline));
+void fn (void)
+{
+ ++cti()->preempt_count;
+}
+
+int main (void)
+{
+ fn ();
+ return 0;
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index db2b236..61fe66d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1625,8 +1625,11 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
splay_tree_delete (id->decl_map);
id->decl_map = st;
- /* The new expression has side-effects if the old one did. */
- TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (t);
+ /* Although, from the semantic viewpoint, the new expression has
+ side-effects only if the old one did, it is not possible, from
+ the technical viewpoint, to evaluate the body of a function
+ multiple times without serious havoc. */
+ TREE_SIDE_EFFECTS (expr) = 1;
tsi_link_before (&id->tsi, expr, TSI_SAME_STMT);