+ PR middle-end/49494 + * ipa-inline-analysis.c (remap_predicate): Add bounds check.
authorJan Hubicka <jh@suse.cz>
Fri, 5 Aug 2011 20:56:05 +0000 (22:56 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 5 Aug 2011 20:56:05 +0000 (20:56 +0000)
+  PR middle-end/49494
+  * ipa-inline-analysis.c (remap_predicate): Add bounds check.
+  * gfortran.dg/pr49494.f90: New testcase.

From-SVN: r177484

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

index c28baac1f4a1fb9219a8bae65a61c0f0283a3384..8ec9d41392cd3ebf7793703cc49171618fee8dec 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-05  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/49494
+       * ipa-inline-analysis.c (remap_predicate): Add bounds check.
+
 2011-08-05  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/49500
index b008f05c97207ebe9df9ca5c632c0817694ca0fb..1055d523fd21f35da60970ef3725dcb2dac35732 100644 (file)
@@ -1873,6 +1873,7 @@ remap_predicate (struct inline_summary *info, struct inline_summary *callee_info
                 /* See if we can remap condition operand to caller's operand.
                    Otherwise give up.  */
                 if (!operand_map
+                    || VEC_length (int, operand_map) <= c->operand_num
                     || VEC_index (int, operand_map, c->operand_num) == -1)
                   cond_predicate = true_predicate ();
                 else
index 4739dbc9f952f564934f9d5b9536ecf48b0be46f..93bf7f92f0668fbb8fba98c8df66b73237126f06 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-05  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/49494
+       * gfortran.dg/pr49494.f90: New testcase.
+
 2011-08-05  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/49735
diff --git a/gcc/testsuite/gfortran.dg/pr49494.f90 b/gcc/testsuite/gfortran.dg/pr49494.f90
new file mode 100644 (file)
index 0000000..b3a35cf
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-O -findirect-inlining -fno-guess-branch-probability -finline-functions -finline-small-functions" }
+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