From fbb1c7d4a061ae0f57d52b37ddf37933da859945 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 22 May 2017 09:38:09 +0000 Subject: [PATCH] decl.c (gnat_to_gnu_entity): Skip regular processing for Itypes that are E_Access_Subtype. * gcc-interface/decl.c (gnat_to_gnu_entity): Skip regular processing for Itypes that are E_Access_Subtype. : Use the DECL of the base type directly. From-SVN: r248323 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/gcc-interface/decl.c | 11 ++++++----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/specs/not_null1.ads | 11 +++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/specs/not_null1.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 945218bae91..702ac99cd87 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2017-05-22 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity): Skip regular processing + for Itypes that are E_Access_Subtype. + : Use the DECL of the base type directly. + 2017-05-22 Ed Schonberg Eric Botcazou diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 91a03cd631b..eab244e910c 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -310,11 +310,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Contains the list of attributes directly attached to the entity. */ struct attrib *attr_list = NULL; - /* Since a use of an Itype is a definition, process it as such if it - is not in a with'ed unit. */ + /* Since a use of an Itype is a definition, process it as such if it is in + the main unit, except for E_Access_Subtype because it's actually a use + of its base type, see below. */ if (!definition && is_type && Is_Itype (gnat_entity) + && Ekind (gnat_entity) != E_Access_Subtype && !present_gnu_tree (gnat_entity) && In_Extended_Main_Code_Unit (gnat_entity)) { @@ -3823,7 +3825,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) case E_Access_Subtype: /* We treat this as identical to its base type; any constraint is meaningful only to the front-end. */ - gnu_type = gnat_to_gnu_type (Etype (gnat_entity)); + gnu_decl = gnat_to_gnu_entity (Etype (gnat_entity), NULL_TREE, false); + saved = true; /* The designated subtype must be elaborated as well, if it does not have its own freeze node. But designated subtypes created @@ -3855,8 +3858,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnat_to_gnu_entity (Directly_Designated_Type (gnat_entity), NULL_TREE, false); } - - maybe_present = true; break; /* Subprogram Entities diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b058621f0e4..b23bdeb81b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-05-22 Pierre-Marie de Rodat + + * gnat.dg/specs/not_null1.ads: New test. + 2017-05-22 Eric Botcazou * gnat.dg/limited_with5.ad[sb]: New test. diff --git a/gcc/testsuite/gnat.dg/specs/not_null1.ads b/gcc/testsuite/gnat.dg/specs/not_null1.ads new file mode 100644 index 00000000000..ccf55e56904 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/not_null1.ads @@ -0,0 +1,11 @@ +-- { dg-do compile } + +package Not_Null1 is + type T is null record; + type T_Access is access all T; + + procedure Proc (This : in not null T_Access) is null; + + type Proc_Access is access procedure (This : in not null T_Access); + PA : Proc_Access := Proc'Access; +end Not_Null1; -- 2.30.2