re PR middle-end/48893 (ICE in evaulate_conditions_for_edge at ipa-inline-analysis...
authorJan Hubicka <jh@suse.cz>
Sat, 4 Jun 2011 18:00:47 +0000 (20:00 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 4 Jun 2011 18:00:47 +0000 (18:00 +0000)
PR tree-optimization/48893
PR tree-optimization/49091
PR tree-optimization/49179
* ipa-inline-analysis.c (evaluate_conditions_for_known_args):
Bounds check.

* gfortran.dg/pr49179.f90: New testcase

From-SVN: r174648

gcc/ChangeLog
gcc/ipa-inline-analysis.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr49179.f90 [new file with mode: 0644]

index 5fdd07ca2cfa636d8f557b48ea74372d5c166367..3082d711c8ca4943c54a742a57129add79c0b3da 100644 (file)
@@ -1,3 +1,11 @@
+2011-06-04  Jan Hubicka  <jh@suse.cz>
+
+       PR tree-optimization/48893
+       PR tree-optimization/49091
+       PR tree-optimization/49179
+       * ipa-inline-analysis.c (evaluate_conditions_for_known_args):
+       Bounds check.
+
 2011-06-04  Jan Hubicka  <jh@suse.cz>
 
        PR lto/48954
index 45bfeb6f4717c90cac371f13f4379e3baff88571..ccda67de4627543675cf0960617d2ec31af3e7d1 100644 (file)
@@ -555,9 +555,17 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
 
   for (i = 0; VEC_iterate (condition, info->conds, i, c); i++)
     {
-      tree val = VEC_index (tree, known_vals, c->operand_num);
+      tree val;
       tree res;
 
+      /* We allow call stmt to have fewer arguments than the callee
+        function (especially for K&R style programs).  So bound
+        check here.  */
+      if (c->operand_num < (int)VEC_length (tree, known_vals))
+        val = VEC_index (tree, known_vals, c->operand_num);
+      else
+       val = NULL;
+
       if (!val)
        {
          clause |= 1 << (i + predicate_first_dynamic_condition);
index b88637cbddc6dc818326246c6baa91940258fc90..c4080ff293051ee74d5c2ded1c9223423c866e44 100644 (file)
@@ -1,3 +1,10 @@
+2011-06-04  Jan Hubicka  <jh@suse.cz>
+
+       PR tree-optimization/48893
+       PR tree-optimization/49091
+       PR tree-optimization/49179
+       * gfortran.dg/pr49179.f90: New testcase
+
 2011-06-04  Jan Hubicka  <jh@suse.cz>
 
        PR lto/48954
diff --git a/gcc/testsuite/gfortran.dg/pr49179.f90 b/gcc/testsuite/gfortran.dg/pr49179.f90
new file mode 100644 (file)
index 0000000..0a86e9e
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-options " -O -findirect-inlining" }
+function more_OK (fcn)
+  character(*) more_OK
+  character (*), external :: fcn
+  more_OK = fcn ()
+end function more_OK
+  character(4) :: answer
+  character(4), external :: is_OK, more_OK
+  answer = more_OK (is_OK)
+contains
+END