diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-05 16:22:16 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-05 16:22:16 +0000 |
commit | 5b2c679881ab32bd87f30f8df2130dcdabb94a3d (patch) | |
tree | 9e62d25cb4781804834463a8fd123bbf1c17f2bf /gcc/testsuite/gnat.dg | |
parent | 48054c997e9c50f1a39e7159808ccf0b56b245cf (diff) | |
download | gcc-5b2c679881ab32bd87f30f8df2130dcdabb94a3d.tar.gz |
PR ada/48844
* gcc-interface/gigi.h (get_variant_part): Declare.
* gcc-interface/decl.c (get_variant_part): Make global.
* gcc-interface/utils2.c (find_common_type): Do not return T1 if the
types have the same constant size, are record types and T1 has a
variant part while T2 doesn't.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gnat.dg')
-rw-r--r-- | gcc/testsuite/gnat.dg/discr29.adb | 8 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/discr29.ads | 27 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/discr30.adb | 50 |
3 files changed, 85 insertions, 0 deletions
diff --git a/gcc/testsuite/gnat.dg/discr29.adb b/gcc/testsuite/gnat.dg/discr29.adb new file mode 100644 index 00000000000..56047c9cf6e --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr29.adb @@ -0,0 +1,8 @@ +package body Discr29 is + + procedure Proc (R : out Rec3) is + begin + R := (False, Tmp); + end; + +end Discr29; diff --git a/gcc/testsuite/gnat.dg/discr29.ads b/gcc/testsuite/gnat.dg/discr29.ads new file mode 100644 index 00000000000..a205bc1e0dd --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr29.ads @@ -0,0 +1,27 @@ +-- { dg-do compile } + +package Discr29 is + + type Rec1 is record + I1 : Integer; + I2 : Integer; + I3 : Integer; + end record; + + type Rec2 is tagged record + I1 : Integer; + I2 : Integer; + end record; + + type Rec3 (D : Boolean) is record + case D is + when True => A : Rec1; + when False => B : Rec2; + end case; + end record; + + procedure Proc (R : out Rec3); + + Tmp : Rec2; + +end Discr29; diff --git a/gcc/testsuite/gnat.dg/discr30.adb b/gcc/testsuite/gnat.dg/discr30.adb new file mode 100644 index 00000000000..b3bf10013b6 --- /dev/null +++ b/gcc/testsuite/gnat.dg/discr30.adb @@ -0,0 +1,50 @@ +-- PR ada/48844 +-- Reported by Georg Bauhaus <bauhaus@futureapps.de> */ + +-- { dg-do compile } + +procedure Discr30 is + + generic + type Source is private; + type Target is private; + function Conversion (S : Source) return Target; + + function Conversion (S : Source) return Target is + type Source_Wrapper is tagged record + S : Source; + end record; + type Target_Wrapper is tagged record + T : Target; + end record; + + type Selector is (Source_Field, Target_Field); + type Magic (Sel : Selector := Target_Field) is record + case Sel is + when Source_Field => S : Source_Wrapper; + when Target_Field => T : Target_Wrapper; + end case; + end record; + + M : Magic; + + function Convert (T : Target_Wrapper) return Target is + begin + M := (Sel => Source_Field, S => (S => S)); + return T.T; + end Convert; + + begin + return Convert (M.T); + end Conversion; + + type Integer_Access is access all Integer; + + I : aliased Integer; + I_Access : Integer_Access := I'Access; + + function Convert is new Conversion (Integer_Access, Integer); + +begin + I := Convert (I_Access); +end; |