aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2022-04-01 22:12:05 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-18 08:41:05 +0000
commitddb82555b422eb175471a3f4df40b27f872ce9bf (patch)
treea90e319e3ac0acb470992971f8a3f1c4cb0d523e /gcc/ada/sem_res.adb
parent337c80a6bcf248f021e9731bba7543fb5bfb3553 (diff)
downloadgcc-ddb82555b422eb175471a3f4df40b27f872ce9bf.zip
gcc-ddb82555b422eb175471a3f4df40b27f872ce9bf.tar.gz
gcc-ddb82555b422eb175471a3f4df40b27f872ce9bf.tar.bz2
[Ada] Crash building VSS with compiler built with assertions
When a tagged type T has aspect String_Literal, a derived type defines a null extension T2, and the context to resolve the use of an object of type T2 where the string literal is applicable is a class-wide type the frontend crashes trying to evaluate if the object is a null extension. This problem does not reproduce when the compiler is built with assertions disabled. gcc/ada/ * sem_ch6.adb (Find_Corresponding_Spec): Avoid calling Is_Null_Extension with a class-wide type entity. (Overrides_Visible_Function): Handle alias entities. * sem_res.adb (Has_Applicable_User_Defined_Literal): Conversion not needed if the result type of the call is class-wide or if the result type matches the context type. * sem_util.ads (Is_Null_Extension): Adding documentation. (Is_Null_Extension_Of): Adding documentation. * sem_util.adb (Is_Null_Extension): Adding assertion. (Is_Null_Extension_Of): Adding assertions.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 33f445d..060fcfc 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -559,7 +559,12 @@ package body Sem_Res is
Set_Etype (Call, Etype (Callee));
- if Base_Type (Etype (Call)) /= Base_Type (Typ) then
+ -- Conversion not needed if the result type of the call is class-wide
+ -- or if the result type matches the context type.
+
+ if not Is_Class_Wide_Type (Typ)
+ and then Base_Type (Etype (Call)) /= Base_Type (Typ)
+ then
-- Conversion may be needed in case of an inherited
-- aspect of a derived type. For a null extension, we
-- use a null extension aggregate instead because the