aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-10-21 10:20:06 +0000
committerEric Botcazou <ebotcazou@adacore.com>2009-10-21 10:20:06 +0000
commit86c67698125508426a8ceb9af52a4df632445a55 (patch)
tree6335004f876cd0c17ec3b49656a9db78f4e4860f
parenta93de64aaf358dc15fc35474db3f3e4cb2ee332e (diff)
* gcc-interfaces/decl.c (build_subst_list): Convert the expression of
the constraint to the type of the discriminant. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153054 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/discr22.adb23
4 files changed, 42 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 5d69cee0594..e4761d82e1f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interfaces/decl.c (build_subst_list): Convert the expression of
+ the constraint to the type of the discriminant.
+
+2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interfaces/decl.c (gnat_to_gnu_entity): Do not create a new
TYPE_DECL when a type is padded if there is already one and reset
TYPE_STUB_DECL in this case.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 70ced844fb6..d0b52f2e745 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7374,12 +7374,16 @@ build_subst_list (Entity_Id gnat_subtype, Entity_Id gnat_type, bool definition)
gnat_value = Next_Elmt (gnat_value))
/* Ignore access discriminants. */
if (!Is_Access_Type (Etype (Node (gnat_value))))
- gnu_list = tree_cons (gnat_to_gnu_field_decl (gnat_discrim),
- elaborate_expression
- (Node (gnat_value), gnat_subtype,
- get_entity_name (gnat_discrim), definition,
- true, false),
- gnu_list);
+ {
+ tree gnu_field = gnat_to_gnu_field_decl (gnat_discrim);
+ gnu_list = tree_cons (gnu_field,
+ convert (TREE_TYPE (gnu_field),
+ elaborate_expression
+ (Node (gnat_value), gnat_subtype,
+ get_entity_name (gnat_discrim),
+ definition, true, false)),
+ gnu_list);
+ }
return gnu_list;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ae7687def70..e827cc9eec7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
+ * gnat.dg/discr22.adb: New test.
+
+2009-10-21 Eric Botcazou <ebotcazou@adacore.com>
+
* gnat.dg/loop_optimization7.ad[sb]: New test.
* gnat.dg/loop_optimization7_pkg.ads: New helper.
diff --git a/gcc/testsuite/gnat.dg/discr22.adb b/gcc/testsuite/gnat.dg/discr22.adb
new file mode 100644
index 00000000000..af4f9ab7899
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/discr22.adb
@@ -0,0 +1,23 @@
+-- { dg-do compile }
+-- { dg-options "-gnatws" }
+
+procedure Discr22 is
+
+ subtype Precision is Integer range 1 .. 5;
+
+ type Rec(D1 : Precision; D2 : Integer) is record
+ case D1 is
+ when 1 => I : Integer;
+ when others => null;
+ end case;
+ end record;
+ for Rec use record
+ D1 at 0 range 0 .. 7;
+ end record;
+
+ P : Precision;
+ X : Rec(P, 0);
+
+begin
+ null;
+end;