Fixed assertion failure when geting block index for a function param.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Mon, 16 Aug 2010 00:06:21 +0000 (20:06 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Mon, 16 Aug 2010 00:06:21 +0000 (20:06 -0400)
src/aop-pc-assign.c

index e73aa30716ad9da77834ae22d5e14f508832e726..69bb34568fd5fb1e5fb9c4e9f29b0005dda4a888 100644 (file)
@@ -475,7 +475,6 @@ aop_capture_lhs_var_scope (struct aop_joinpoint *jp)
 {
   tree lhs;
   tree function_block;
-  int var_index = 0;
   lhs = get_lhs_var (jp);
 
   if (lhs != NULL_TREE)
@@ -493,11 +492,21 @@ aop_capture_lhs_var_scope (struct aop_joinpoint *jp)
        }
       else if (TREE_CODE (DECL_CONTEXT (lhs)) == FUNCTION_DECL)
        {
-         function_block = DECL_INITIAL (current_function_decl);
-         bool retval = false;
-         retval = find_lexical_block (lhs, function_block, &var_index);
+         bool retval;
+         int var_index = 0;
+
+         if (TREE_CODE (lhs) == PARM_DECL)
+           {
+             /* Function parameters get block index 0.*/
+             var_index = 0;
+           }
+         else
+           {
+             function_block = DECL_INITIAL (current_function_decl);
+             retval = find_lexical_block (lhs, function_block, &var_index);
+             aop_assert (retval == true);
+           }
 
-         aop_assert (retval == true);
          return var_index;
        }
       else