This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] Fix non-GIMPLE out of tree-nested.c
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 17 Oct 2009 18:19:06 +0200
- Subject: [Patch] Fix non-GIMPLE out of tree-nested.c
Hi,
the tree-nested.c pass can generate non-GIMPLE when a reference to a variable
in a GIMPLE_COND statement is rewritten. For the attached testcase:
p.adb:27:4: error: invalid operands in gimple comparison
if (CHAIN.5->index != 0)
Fixed by handling GIMPLE_COND specially when rewriting references.
Tested on i586-suse-linux, OK for mainline?
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
* tree-nested.c (convert_nonlocal_reference_stmt) <GIMPLE_COND>: New
case. Force using values to replace references within the statement.
(convert_local_reference_stmt): Likewise
2009-10-17 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/nested_proc2.adb: New test.
--
Eric Botcazou
Index: tree-nested.c
===================================================================
--- tree-nested.c (revision 152797)
+++ tree-nested.c (working copy)
@@ -1307,6 +1307,11 @@ convert_nonlocal_reference_stmt (gimple_
*handled_ops_p = false;
return NULL_TREE;
+ case GIMPLE_COND:
+ wi->val_only = true;
+ *handled_ops_p = false;
+ return NULL_TREE;
+
default:
/* For every other statement that we are not interested in
handling here, let the walker traverse the operands. */
@@ -1707,6 +1712,11 @@ convert_local_reference_stmt (gimple_stm
info, gimple_omp_body (stmt));
break;
+ case GIMPLE_COND:
+ wi->val_only = true;
+ *handled_ops_p = false;
+ return NULL_TREE;
+
default:
/* For every other statement that we are not interested in
handling here, let the walker traverse the operands. */
-- { dg-do compile }
-- { dg-options "-gnatws" }
procedure Nested_Proc2 is
type Arr is array(1..2) of Integer;
type Rec is record
Data : Arr;
end record;
From : Rec;
Index : Integer;
function F (X : Arr) return Integer is
begin
return 0;
end;
procedure Test is
begin
Index := F (From.Data);
If Index /= 0 then
raise Program_Error;
end if;
end;
begin
Test;
end;