exp_ch2.adb: Remove "with" and "use" clauses for Namet and Snames.

2007-04-20  Hristian Kirtchev  <kirtchev@adacore.com>
	    Robert Dewar  <dewar@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>
	    Gary Dismukes  <dismukes@adacore.com>

	* exp_ch2.adb: Remove "with" and "use" clauses for Namet and Snames.
	Add "with" and "use" clauses for Sem_Attr.
	(Expand_Current_Value): Do not replace occurences of attribute
	references where the prefix must be a simple name.

	* sem_attr.ads, sem_attr.adb: Remove "with" and "use" clauses for
	Namet. Add new arrays Attribute_Name_Modifies_Prefix and
	Attribute_Requires_Simple_Name_Prefix.
	(Name_Modifies_Prefix): Body of new function.
	(Requires_Simple_Name_Prefix): Body of new function.
	(Resolve_Attribute, case Access): Improve error message for case of
	mismatched conventions.
	(Analyze_Attribute, case 'Tag): The prefix the attribute cannot be of an
	incomplete type.
	(Analyze_Attribute, case 'Access): If the type of the prefix is a
	constrained subtype for a nominal unconstrained type, use its base type
	to check for conformance with the context.
	(Resolve_Attribute): Remove test of the access type being associated
	with a return statement from condition for performing accessibility
	checks on access attributes, since this case is now captured by
	Is_Local_Anonymous_Access.
	(Analyze_Access_Attribute): Set Address_Taken on entity
	(Analyze_Attribute, case Address): Set Address_Taken on entity
	(OK_Self_Reference): Traverse tree to locate enclosing aggregate when
	validating an access attribute whose prefix is a current instance.
	(Resolve_Attribute): In case of attributes 'Code_Address and 'Address
	applied to dispatching operations, if freezing is required then we set
	the attribute Has_Delayed_Freeze in the prefix's entity.
	(Check_Local_Access): Set flag Suppress_Value_Tracking_On_Call in
	current scope if access of local subprogram taken
	(Analyze_Access_Attribute): Check legality of self-reference even if the
	expression comes from source, as when a single component association in
	an aggregate has a box association.
	(Resolve_Attribute, case 'Access): Do not apply accessibility checks to
	the prefix if it is a protected operation and the attribute is
	Unrestricted_Access.
	(Resolve_Attribute, case 'Access): Set the Etype of the attribute
	reference to the base type of the context, to force a constraint check
	when the context is an access subtype with an explicit constraint.
	(Analyze_Attribute, case 'Class): If the prefix is an interface and the
	node is rewritten as an interface conversion. leave unanalyzed after
	resolution, to ensure that type checking against the context will take
	place.

From-SVN: r125395
This commit is contained in:
Hristian Kirtchev 2007-06-06 12:24:40 +02:00 committed by Arnaud Charlet
parent 33160237cb
commit 822033ebf3
3 changed files with 355 additions and 210 deletions

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -35,12 +35,12 @@ with Exp_VFpt; use Exp_VFpt;
with Nmake; use Nmake;
with Opt; use Opt;
with Sem; use Sem;
with Sem_Attr; use Sem_Attr;
with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Tbuild; use Tbuild;
with Uintp; use Uintp;
@ -156,13 +156,12 @@ package body Exp_Ch2 is
and then Nkind (Parent (N)) /= N_Pragma_Argument_Association
-- Same for Asm_Input and Asm_Output attribute references
-- Same for attribute references that require a simple name prefix
and then not (Nkind (Parent (N)) = N_Attribute_Reference
and then
(Attribute_Name (Parent (N)) = Name_Asm_Input
or else
Attribute_Name (Parent (N)) = Name_Asm_Output))
and then Requires_Simple_Name_Prefix (
Attribute_Name (Parent (N))))
then
-- Case of Current_Value is a compile time known value

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -32,6 +32,7 @@
-- This spec also documents all GNAT implementation defined pragmas
with Exp_Tss; use Exp_Tss;
with Namet; use Namet;
with Snames; use Snames;
with Types; use Types;
@ -541,6 +542,19 @@ package Sem_Attr is
-- in appropriate contexts (i.e. in subtype marks, or as prefixes for
-- other attributes).
function Name_Modifies_Prefix (Nam : Name_Id) return Boolean;
-- Determine whether the name of an attribute reference modifies the
-- contents of its prefix. "Read" is such an attribute.
function Requires_Simple_Name_Prefix (Nam : Name_Id) return Boolean;
-- Determine whether the name of an attribute reference requires a simple
-- name rather than a value as its prefix. Such prefixes do not need to be
-- optimized. For instance in the following example:
-- I : constant Integer := 5;
-- S : constant Integer := I'Size;
-- "Size" requires a simple name prefix since "5'Size" does not make
-- sense.
procedure Resolve_Attribute (N : Node_Id; Typ : Entity_Id);
-- Performs type resolution of attribute. If the attribute yields a
-- universal value, mark its type as that of the context. On the other