[Ada] Fix bug in inherited user-defined-literal aspects for tagged types
Pierre-Marie de Rodat
derodat@adacore.com
Fri Oct 1 06:14:26 GMT 2021
In some cases, an integer literal of a tagged type whose Integer_Literal
aspect is inherited from an ancestor type was not handled correctly by
the compiler. In particular, Ada RM 13.1(15.5) was not correctly
implemented, resulting in the incorrect rejection of legal uses of
integer literals with (incorrect) semantic error messages about illegal
downward conversions. The same problem also affected the other two
user-defined literal aspects, Real_Literal and String_Literal. These
bugs are corrected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_res.adb (Resolve): Two separate fixes. In the case where
Find_Aspect for a literal aspect returns the aspect for a
different (ancestor) type, call Corresponding_Primitive_Op to
get the right callee. In the case where a downward tagged type
conversion appears to be needed, generate a null extension
aggregate instead, as per Ada RM 3.4(27).
* sem_util.ads, sem_util.adb: Add new Corresponding_Primitive_Op
function. It maps a primitive op of a tagged type and a
descendant type of that tagged type to the corresponding
primitive op of the descendant type. The body of this function
was written by Javier Miranda.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 6152 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211001/7d9ed3df/attachment.bin>
More information about the Gcc-patches
mailing list