aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@gcc.gnu.org>2020-07-02 10:26:49 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2020-07-02 10:29:34 +0200
commit6153cfd7a342f131d347de1aea87f352f3ccd4e7 (patch)
tree9c095d99c19e7bf2cd573a9ada4be774d39422c5 /gcc/ada/gcc-interface/decl.c
parentece21ff6ea9d969d3b6aae82136622a7126eefc1 (diff)
downloadgcc-6153cfd7a342f131d347de1aea87f352f3ccd4e7.zip
gcc-6153cfd7a342f131d347de1aea87f352f3ccd4e7.tar.gz
gcc-6153cfd7a342f131d347de1aea87f352f3ccd4e7.tar.bz2
Reject components in extensions overlapping with the parent
Such problematic components can be specified by means of a component clause but they cannot be fully supported by the type system. They had initially been forbidden, then we decided to accept them by working around the type system, but this is very fragile and, for example, any static aggregate is guaranteed to trigger an ICE with the current implementation. We now reject them again, except if the -gnatd.K switch is passed. gcc/ada/ChangeLog: * debug.adb (d.K): Document new usage. * fe.h (Debug_Flag_Dot_KK): Declare. * gcc-interface/decl.c (gnat_to_gnu_field): Give an error when the component overlaps with the parent subtype, except with -gnatd.K.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index cad06a4..025714b 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7234,12 +7234,12 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
{
Entity_Id gnat_parent = Parent_Subtype (gnat_record_type);
- /* Ensure the position does not overlap with the parent subtype, if there
- is one. This test is omitted if the parent of the tagged type has a
- full rep clause since, in this case, component clauses are allowed to
- overlay the space allocated for the parent type and the front-end has
- checked that there are no overlapping components. */
- if (Present (gnat_parent) && !Is_Fully_Repped_Tagged_Type (gnat_parent))
+ /* Ensure the position doesn't overlap with the parent subtype if there
+ is one. It would be impossible to build CONSTRUCTORs and accessing
+ the parent could clobber the component in the extension if directly
+ done. We accept it with -gnatd.K for the sake of compatibility. */
+ if (Present (gnat_parent)
+ && !(Debug_Flag_Dot_KK && Is_Fully_Repped_Tagged_Type (gnat_parent)))
{
tree gnu_parent = gnat_to_gnu_type (gnat_parent);