http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60469

--- Comment #4 from Igor Zamyatin <izamyatin at gmail dot com> ---
Following works for me and shows no new errors in regtesting. Not sure it is a
good idea though...

diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 6a5631c..d7c6772 100644
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -284,6 +284,7 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree
*new_var)
     {
       an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                   integer_type_node);
+      DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl;
       an_loop_info[ii].ind_init =
     build_modify_expr (location, an_loop_info[ii].var,
                TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -783,6 +784,7 @@ build_array_notation_expr (location_t location, tree lhs,
tree lhs_origtype,
       {
     lhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                            integer_type_node);
+    DECL_CONTEXT (lhs_an_loop_info[ii].var) = current_function_decl;
     lhs_an_loop_info[ii].ind_init = build_modify_expr
       (location, lhs_an_loop_info[ii].var,
        TREE_TYPE (lhs_an_loop_info[ii].var), NOP_EXPR,
@@ -795,6 +797,7 @@ build_array_notation_expr (location_t location, tree lhs,
tree lhs_origtype,
      integer.  */
       rhs_an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                          integer_type_node);
+      DECL_CONTEXT (rhs_an_loop_info[ii].var) = current_function_decl;
       rhs_an_loop_info[ii].ind_init = build_modify_expr
     (location, rhs_an_loop_info[ii].var,
      TREE_TYPE (rhs_an_loop_info[ii].var), NOP_EXPR,
@@ -972,6 +975,7 @@ fix_conditional_array_notations_1 (tree stmt)
     {
       an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                      integer_type_node);
+      DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl;
       an_loop_info[ii].ind_init =
     build_modify_expr (location, an_loop_info[ii].var,
                TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -1069,6 +1073,7 @@ fix_array_notation_expr (location_t location, enum
tree_code code,
     {
       an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                      integer_type_node);
+      DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl;
       an_loop_info[ii].ind_init =
     build_modify_expr (location, an_loop_info[ii].var,
                TREE_TYPE (an_loop_info[ii].var), NOP_EXPR,
@@ -1165,6 +1170,7 @@ fix_array_notation_call_expr (tree arg)
     {
       an_loop_info[ii].var = build_decl (location, VAR_DECL, NULL_TREE,
                      integer_type_node);
+      DECL_CONTEXT (an_loop_info[ii].var) = current_function_decl;
       an_loop_info[ii].ind_init =
     build_modify_expr (location, an_loop_info[ii].var,
                TREE_TYPE (an_loop_info[ii].var), NOP_EXPR, location,
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 7441784..b61a995 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1732,6 +1732,7 @@ gimplify_var_or_parm_decl (tree *expr_p)
      be really nice if the front end wouldn't leak these at all.
      Currently the only known culprit is C++ destructors, as seen
      in g++.old-deja/g++.jason/binding.C.  */
+#if 0
   if (TREE_CODE (decl) == VAR_DECL
       && !DECL_SEEN_IN_BIND_EXPR_P (decl)
       && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl)
@@ -1740,6 +1741,7 @@ gimplify_var_or_parm_decl (tree *expr_p)
       gcc_assert (seen_error ());
       return GS_ERROR;
     }
+#endif

   /* When within an OpenMP context, notice uses of variables.  */
   if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl,
true))

Reply via email to