aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2015-02-20 10:51:22 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2015-02-20 10:51:22 +0100
commit22efcab77ad9a19cae5e828a9bcfd4dba9ea02ec (patch)
tree4245838727a454159664e7cc0f0d5a35592fff1c /gcc/ada/sem_attr.adb
parent17ce1f52fe78bfdc63dfe941a272a1ffdea605a7 (diff)
downloadgcc-22efcab77ad9a19cae5e828a9bcfd4dba9ea02ec.zip
gcc-22efcab77ad9a19cae5e828a9bcfd4dba9ea02ec.tar.gz
gcc-22efcab77ad9a19cae5e828a9bcfd4dba9ea02ec.tar.bz2
[multiple changes]
2015-02-20 Vincent Celier <celier@adacore.com> * switch-c.adb (Scan_Front_End_Switches): Do not fail when --RTS= is specified several times with different values that indicates the same runtime directory. 2015-02-20 Ed Schonberg <schonberg@adacore.com> * sem_attr.adb (Check_Not_Incomplete_Type): Clean up code to handle properly illegal uses of attributes on prefixes on an incomplete type, both when the type of the prefix is locally incomplete, and when it is a limited view of a type whose non-limited view is not available. (Analyze_Attribute): Add calls to Check_Not_Incomplete_Type for 'Address and others. 2015-02-20 Eric Botcazou <ebotcazou@adacore.com> * exp_ch6.adb: Fix minor typo in comment. From-SVN: r220843
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r--gcc/ada/sem_attr.adb74
1 files changed, 55 insertions, 19 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 3ec6e73..36f78d1 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1637,6 +1637,10 @@ package body Sem_Attr is
-- dereference we have to check wrong uses of incomplete types
-- (other wrong uses are checked at their freezing point).
+ -- In Ada 2012, incomplete types can appear in subprogram
+ -- profiles, but formals with incomplete types cannot be the
+ -- prefix of attributes.
+
-- Example 1: Limited-with
-- limited with Pkg;
@@ -1668,35 +1672,64 @@ package body Sem_Attr is
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
- else
- if Is_Access_Type (Typ) then
- Typ := Directly_Designated_Type (Typ);
- end if;
+ -- If the prefix is an access type check the designated type
- if Is_Class_Wide_Type (Typ) then
- Typ := Root_Type (Typ);
- end if;
+ elsif Is_Access_Type (Typ)
+ and then Nkind (P) = N_Explicit_Dereference
+ then
+ Typ := Directly_Designated_Type (Typ);
+ end if;
- -- A legal use of a shadow entity occurs only when the unit
- -- where the non-limited view resides is imported via a regular
- -- with clause in the current body. Such references to shadow
- -- entities may occur in subprogram formals.
+ if Is_Class_Wide_Type (Typ) then
+ Typ := Root_Type (Typ);
+ end if;
- if Is_Incomplete_Type (Typ)
- and then From_Limited_With (Typ)
- and then Present (Non_Limited_View (Typ))
- and then Is_Legal_Shadow_Entity_In_Body (Typ)
+ -- A legal use of a shadow entity occurs only when the unit where
+ -- the non-limited view resides is imported via a regular with
+ -- clause in the current body. Such references to shadow entities
+ -- may occur in subprogram formals.
+
+ if Is_Incomplete_Type (Typ)
+ and then From_Limited_With (Typ)
+ and then Present (Non_Limited_View (Typ))
+ and then Is_Legal_Shadow_Entity_In_Body (Typ)
+ then
+ Typ := Non_Limited_View (Typ);
+ end if;
+
+ -- If still incomplete, it can be a local incomplete type, or a
+ -- limited view whose scope is also a limited view.
+
+ if Ekind (Typ) = E_Incomplete_Type then
+ if not From_Limited_With (Typ)
+ and then No (Full_View (Typ))
then
- Typ := Non_Limited_View (Typ);
- end if;
+ Error_Attr_P
+ ("prefix of % attribute cannot be an incomplete type");
+
+ -- The limited view may be available indirectly through
+ -- an intermediate unit. If the non-limited view is available
+ -- the attribute reference is legal.
- if Ekind (Typ) = E_Incomplete_Type
- and then No (Full_View (Typ))
+ elsif From_Limited_With (Typ)
+ and then
+ (No (Non_Limited_View (Typ))
+ or else Is_Incomplete_Type (Non_Limited_View (Typ)))
then
Error_Attr_P
("prefix of % attribute cannot be an incomplete type");
end if;
end if;
+
+ -- Ada 2012 : formals in bodies may be incomplete, but no attribute
+ -- legally applies.
+
+ elsif Is_Entity_Name (P)
+ and then Is_Formal (Entity (P))
+ and then Is_Incomplete_Type (Etype (Etype (P)))
+ then
+ Error_Attr_P
+ ("prefix of % attribute cannot be an incomplete type");
end if;
if not Is_Entity_Name (P)
@@ -2615,6 +2648,7 @@ package body Sem_Attr is
when Attribute_Access =>
Analyze_Access_Attribute;
+ Check_Not_Incomplete_Type;
-------------
-- Address --
@@ -2623,6 +2657,7 @@ package body Sem_Attr is
when Attribute_Address =>
Check_E0;
Address_Checks;
+ Check_Not_Incomplete_Type;
Set_Etype (N, RTE (RE_Address));
------------------
@@ -6019,6 +6054,7 @@ package body Sem_Attr is
end if;
Analyze_Access_Attribute;
+ Check_Not_Incomplete_Type;
-------------------------
-- Unconstrained_Array --