diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-11-12 11:49:07 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-11-12 11:49:07 +0100 |
commit | 81501d2b45d990aaab9c0c3b85a13b4315ed567e (patch) | |
tree | 5880809a3b63cbdcf8b9c08e4e12e0e0ba4df858 /gcc/ada/exp_ch6.adb | |
parent | 0fe797c5849ca33b50a69995ce5aaccb1476ec8a (diff) | |
download | gcc-81501d2b45d990aaab9c0c3b85a13b4315ed567e.zip gcc-81501d2b45d990aaab9c0c3b85a13b4315ed567e.tar.gz gcc-81501d2b45d990aaab9c0c3b85a13b4315ed567e.tar.bz2 |
[multiple changes]
2015-11-12 Emmanuel Briot <briot@adacore.com>
* s-os_lib.ads: Documentation update.
2015-11-12 Arnaud Charlet <charlet@adacore.com>
* s-taprop-vxworks.adb, s-osinte-vxworks.ads: Use a single import of
taskDelay to avoid confusion.
2015-11-12 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Expand_Simple_Function_Return): If the return
type is class-wide and the expression is a view conversion,
remove the conversion to prevent overriding of the tag, which
must be that of the object being returned.
2015-11-12 Tristan Gingold <gingold@adacore.com>
* bindgen.adb (Gen_Adainit): Code cleanup.
2015-11-12 Hristian Kirtchev <kirtchev@adacore.com>
* s-stalib.ads: Code cleanup.
2015-11-12 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Incomplete_Type_Decl): small optimization.
(Analyze_Subtype_Declaration): For floating point types,
inherit dimensions.
(OK_For_Limited_Init_In_05): Handle properly a conditional
expression whose condition is static, and is rewritten as the
branch that will be executed.
2015-11-12 Ed Schonberg <schonberg@adacore.com>
* sem_attr.adb (Resolve_Attribute, case 'Access): If the context
type is an access constant type, do not mark the attribute
reference as a possible modification of the prefix.
From-SVN: r230226
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 517143b..6aaeb87 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5980,7 +5980,7 @@ package body Exp_Ch6 is Utyp : constant Entity_Id := Underlying_Type (R_Type); - Exp : constant Node_Id := Expression (N); + Exp : Node_Id := Expression (N); pragma Assert (Present (Exp)); Exptyp : constant Entity_Id := Etype (Exp); @@ -5996,11 +5996,24 @@ package body Exp_Ch6 is begin if Is_Class_Wide_Type (R_Type) - and then not Is_Class_Wide_Type (Etype (Exp)) + and then not Is_Class_Wide_Type (Exptyp) + and then Nkind (Exp) /= N_Type_Conversion then - Subtype_Ind := New_Occurrence_Of (Etype (Exp), Loc); + Subtype_Ind := New_Occurrence_Of (Exptyp, Loc); else Subtype_Ind := New_Occurrence_Of (R_Type, Loc); + + -- If the result type is class-wide and the expression is a view + -- conversion, the conversion plays no role in the expansion because + -- it does not modify the tag of the object. Remove the conversion + -- altogether to prevent tag overwriting. + + if Is_Class_Wide_Type (R_Type) + and then not Is_Class_Wide_Type (Exptyp) + and then Nkind (Exp) = N_Type_Conversion + then + Exp := Expression (Exp); + end if; end if; -- For the case of a simple return that does not come from an extended |