This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
When determining the accessibility level of a function call, the compiler was
using the level of the subprogram itself, instead of the level of the call's
innermost enclosing master. This could result in the creation of dangling
references, such as when selecting an access discriminant from a call and
assigning it to an access object declared at a level not as deep as the call.
When compiling for Ada 2005, we now determine the level of a call by locating
the level of the innermost enclosing dynamic scope. This can't be done by
simply using the level of the current scope, because cases involving renamings
of function calls (or selections thereof) may result in indirect references
to calls at a different level than where the renaming is referenced.
The compiler must report the following error when compiling the test given
below with -gnat05:
call_accessibility_bug.adb:37:24: cannot convert access discriminant to non-local access type
procedure Call_Accessibility_Bug is
type Element_Handle (D: access Integer) is tagged limited null record;
Aliased_Int : aliased Integer;
function Handle return Element_Handle is
begin
return Element_Handle'(D => Aliased_Int'Access);
end Handle;
EH_0 : Element_Handle (Aliased_Int'Access);
EH_1 : Element_Handle := Handle;
EH_2 : Element_Handle renames Handle;
Acc_Int : access Integer;
begin
declare
EH_Renames_Outer_Object : Element_Handle renames EH_0;
EH_Renames_Outer_Call_Renaming : Element_Handle renames EH_2;
begin
Acc_Int := EH_Renames_Outer_Object.D; -- OK
Acc_Int := EH_Renames_Outer_Call_Renaming.D; -- OK
Acc_Int := EH_0.D; -- OK
Acc_Int := EH_1.D; -- OK
Acc_Int := EH_2.D; -- OK
Acc_Int := Handle.D; -- ERROR
end;
end Call_Accessibility_Bug;
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-06-18 Gary Dismukes <dismukes@adacore.com>
* sem_util.adb (Object_Access_Level): For Ada 2005, determine the
accessibility level of a function call from the level of the innermost
enclosing dynamic scope.
(Innermost_Master_Scope_Depth): New function to find the depth of the
nearest dynamic scope enclosing a node.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |