Skip to content

Commit

Permalink
Langkit_Support: remove the last anonymous access return types
Browse files Browse the repository at this point in the history
Some versions of GNAT are known to complain about these and anyway they
are almost never correct: they are supposed to return an allocation
whose lifetime is bound to the caller's whereas we generally return
allocations whose lifetime is not statically known.

Just replace these anonymous access types with named access types,
creating some if needed. Behavior should not change.

For GitHub issue #235
  • Loading branch information
pmderodat committed Nov 12, 2019
1 parent 60b9409 commit b55ba1a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion langkit/support/langkit_support-adalog-eq_same.ads
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ package Langkit_Support.Adalog.Eq_Same is
Eq_Data : Equals_Data;
Sloc_Info : String_Access := null) return Relation
is
(Relation (Impl.Equals (L, R, Data, Eq_Data, Sloc_Info)));
(Impl.Equals (L, R, Data, Eq_Data, Sloc_Info));

end Raw_Custom_Bind;

Expand Down
4 changes: 2 additions & 2 deletions langkit/support/langkit_support-adalog-unify.ads
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ package Langkit_Support.Adalog.Unify is
R_Data : Right_C_Data := No_R_Data;
Eq_Data : Equals_Data := No_Equals_Data;
Sloc_Info : String_Access := null)
return access Base_Relation'Class
return Relation
is
(Unify_Left.Create (L, R, R_Data, Eq_Data, Sloc_Info))
with Inline;
Expand All @@ -151,7 +151,7 @@ package Langkit_Support.Adalog.Unify is
L_Data : Left_C_Data := No_L_Data;
Eq_Data : Equals_Data := No_Equals_Data;
Sloc_Info : String_Access := null)
return access Base_Relation'Class
return Relation
is
(Unify_Right.Create (R, L, L_Data, Eq_Data, Sloc_Info))
with Inline;
Expand Down
4 changes: 1 addition & 3 deletions langkit/support/langkit_support-bump_ptr.adb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ package body Langkit_Support.Bump_Ptr is

package body Tagged_Alloc is

type Element_Access is access all Element_T;

T : aliased Element_T;

package Gen_Alloc is new
Expand All @@ -169,7 +167,7 @@ package body Langkit_Support.Bump_Ptr is
function Dirty_Conv is new
Ada.Unchecked_Conversion (Element_Access, Address_Access);

function Alloc (Pool : Bump_Ptr_Pool) return access Element_T is
function Alloc (Pool : Bump_Ptr_Pool) return Element_Access is
-- This bit of code is actually quite funny. It is born out of the
-- conflation of several unfortunate design choices in Ada:

Expand Down
3 changes: 2 additions & 1 deletion langkit/support/langkit_support-bump_ptr.ads
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ package Langkit_Support.Bump_Ptr is

generic
type Element_T is tagged private;
type Element_Access is access all Element_T;
package Tagged_Alloc is
function Alloc (Pool : Bump_Ptr_Pool) return access Element_T
function Alloc (Pool : Bump_Ptr_Pool) return Element_Access
with Inline;
end Tagged_Alloc;
-- This generic allocation package can be used to allocate an object of
Expand Down

0 comments on commit b55ba1a

Please sign in to comment.