re PR tree-optimization/17697 (ICE: Statement marked for throw, but doesn't - verify_...
authorJakub Jelinek <jakub@redhat.com>
Wed, 29 Sep 2004 09:04:21 +0000 (11:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 29 Sep 2004 09:04:21 +0000 (11:04 +0200)
PR tree-optimization/17697
* tree-ssa-ccp.c (execute_fold_all_builtins): Update eh and cleanup
cfg if needed.

* g++.dg/opt/pr17697-1.C: New test.
* g++.dg/opt/pr17697-2.C: New test.
* g++.dg/opt/pr17697-3.C: New test.

From-SVN: r88277

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr17697-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/pr17697-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/opt/pr17697-3.C [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 95c7d04800777da17c06b481de49b28258c5297b..96721daab1cdd10e2597a139b93b57664c1289c7 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/17697
+       * tree-ssa-ccp.c (execute_fold_all_builtins): Update eh and cleanup
+       cfg if needed.
+
 2004-09-28  Per Bothner  <per@bothner.com>
 
        * profile.c (branch_prob): Pass correct value to output_location,
index 1b59e73d1ac48152a3579612d9cfd876de4e26b8..dd80cf5832982054b158c9f4d0493176351ab835 100644 (file)
@@ -1,3 +1,10 @@
+2004-09-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/17697
+       * g++.dg/opt/pr17697-1.C: New test.
+       * g++.dg/opt/pr17697-2.C: New test.
+       * g++.dg/opt/pr17697-3.C: New test.
+
 2004-09-28  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        PR c/16409
diff --git a/gcc/testsuite/g++.dg/opt/pr17697-1.C b/gcc/testsuite/g++.dg/opt/pr17697-1.C
new file mode 100644 (file)
index 0000000..0e2f671
--- /dev/null
@@ -0,0 +1,32 @@
+// PR tree-optimization/17697
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C"
+{
+  extern int strcmp (const char *s, const char *t) throw ()
+    __attribute__ ((pure));
+}
+
+namespace A
+{
+  extern int strcmp (const char *s, const char *t);
+}
+
+inline int
+A::strcmp (const char *s, const char *t)
+{
+  return ::strcmp (s, t);
+}
+
+int
+foo (char *x) throw ()
+{
+  return A::strcmp ("", x);
+}
+
+int
+main ()
+{
+  return foo ("") != 0 || foo ("a") == 0;
+}
diff --git a/gcc/testsuite/g++.dg/opt/pr17697-2.C b/gcc/testsuite/g++.dg/opt/pr17697-2.C
new file mode 100644 (file)
index 0000000..11def66
--- /dev/null
@@ -0,0 +1,32 @@
+// PR tree-optimization/17697
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C"
+{
+  extern int strcmp (const char *s, const char *t) throw ()
+    __attribute__ ((pure));
+}
+
+namespace A
+{
+  extern int strcmp (const char *s, const char *t) throw ();
+}
+
+inline int
+A::strcmp (const char *s, const char *t) throw ()
+{
+  return ::strcmp (s, t);
+}
+
+int
+foo (char *x) throw ()
+{
+  return A::strcmp ("", x);
+}
+
+int
+main ()
+{
+  return foo ("") != 0 || foo ("a") == 0;
+}
diff --git a/gcc/testsuite/g++.dg/opt/pr17697-3.C b/gcc/testsuite/g++.dg/opt/pr17697-3.C
new file mode 100644 (file)
index 0000000..b1369d1
--- /dev/null
@@ -0,0 +1,28 @@
+// PR tree-optimization/17697
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C" extern int strcmp (const char *s, const char *t);
+
+namespace A
+{
+  extern int strcmp (const char *s, const char *t);
+}
+
+inline int
+A::strcmp (const char *s, const char *t)
+{
+  return ::strcmp (s, t);
+}
+
+int
+foo (char *x)
+{
+  return A::strcmp ("", x);
+}
+
+int
+main ()
+{
+  return foo ("") != 0 || foo ("a") == 0;
+}
index d3ad9563a6b8894addc92a037a32eb175c815e15..3e8fa7b5a1cb02f9f59da8680f11cfbfbcc4e528 100644 (file)
@@ -2143,6 +2143,7 @@ convert_to_gimple_builtin (block_stmt_iterator *si_p, tree expr)
 static void
 execute_fold_all_builtins (void)
 {
+  bool cfg_changed = false;
   basic_block bb;
   FOR_EACH_BB (bb)
     {
@@ -2187,6 +2188,9 @@ execute_fold_all_builtins (void)
                abort ();
            }
          modify_stmt (*stmtp);
+         if (maybe_clean_eh_stmt (*stmtp)
+             && tree_purge_dead_eh_edges (bb))
+           cfg_changed = true;
 
          if (dump_file && (dump_flags & TDF_DETAILS))
            {
@@ -2196,6 +2200,10 @@ execute_fold_all_builtins (void)
            }
        }
     }
+
+  /* Delete unreachable blocks.  */
+  if (cfg_changed)
+    cleanup_tree_cfg ();
 }