Commit 22efcab7 by Arnaud Charlet

[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
parent 17ce1f52
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.
2015-02-20 Eric Botcazou <ebotcazou@adacore.com> 2015-02-20 Eric Botcazou <ebotcazou@adacore.com>
* sinfo.ads: Add comment. * sinfo.ads: Add comment.
......
...@@ -3783,7 +3783,7 @@ package body Exp_Ch6 is ...@@ -3783,7 +3783,7 @@ package body Exp_Ch6 is
-- Front end expansion of simple functions returning unconstrained -- Front end expansion of simple functions returning unconstrained
-- types (see Check_And_Split_Unconstrained_Function) and simple -- types (see Check_And_Split_Unconstrained_Function) and simple
-- renamings inlined by the front end (see Build_Renamed_Entity). -- renamings inlined by the front end (see Build_Renamed_Body).
else else
Expand_Inlined_Call (Call_Node, Subp, Orig_Subp); Expand_Inlined_Call (Call_Node, Subp, Orig_Subp);
......
...@@ -1637,6 +1637,10 @@ package body Sem_Attr is ...@@ -1637,6 +1637,10 @@ package body Sem_Attr is
-- dereference we have to check wrong uses of incomplete types -- dereference we have to check wrong uses of incomplete types
-- (other wrong uses are checked at their freezing point). -- (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 -- Example 1: Limited-with
-- limited with Pkg; -- limited with Pkg;
...@@ -1668,35 +1672,64 @@ package body Sem_Attr is ...@@ -1668,35 +1672,64 @@ package body Sem_Attr is
Error_Attr_P Error_Attr_P
("prefix of % attribute cannot be an incomplete type"); ("prefix of % attribute cannot be an incomplete type");
else -- If the prefix is an access type check the designated type
if Is_Access_Type (Typ) then
Typ := Directly_Designated_Type (Typ);
end if;
if Is_Class_Wide_Type (Typ) then elsif Is_Access_Type (Typ)
Typ := Root_Type (Typ); and then Nkind (P) = N_Explicit_Dereference
end if; then
Typ := Directly_Designated_Type (Typ);
end if;
-- A legal use of a shadow entity occurs only when the unit if Is_Class_Wide_Type (Typ) then
-- where the non-limited view resides is imported via a regular Typ := Root_Type (Typ);
-- with clause in the current body. Such references to shadow end if;
-- entities may occur in subprogram formals.
if Is_Incomplete_Type (Typ) -- A legal use of a shadow entity occurs only when the unit where
and then From_Limited_With (Typ) -- the non-limited view resides is imported via a regular with
and then Present (Non_Limited_View (Typ)) -- clause in the current body. Such references to shadow entities
and then Is_Legal_Shadow_Entity_In_Body (Typ) -- 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 then
Typ := Non_Limited_View (Typ); Error_Attr_P
end if; ("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 elsif From_Limited_With (Typ)
and then No (Full_View (Typ)) and then
(No (Non_Limited_View (Typ))
or else Is_Incomplete_Type (Non_Limited_View (Typ)))
then then
Error_Attr_P Error_Attr_P
("prefix of % attribute cannot be an incomplete type"); ("prefix of % attribute cannot be an incomplete type");
end if; end if;
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; end if;
if not Is_Entity_Name (P) if not Is_Entity_Name (P)
...@@ -2615,6 +2648,7 @@ package body Sem_Attr is ...@@ -2615,6 +2648,7 @@ package body Sem_Attr is
when Attribute_Access => when Attribute_Access =>
Analyze_Access_Attribute; Analyze_Access_Attribute;
Check_Not_Incomplete_Type;
------------- -------------
-- Address -- -- Address --
...@@ -2623,6 +2657,7 @@ package body Sem_Attr is ...@@ -2623,6 +2657,7 @@ package body Sem_Attr is
when Attribute_Address => when Attribute_Address =>
Check_E0; Check_E0;
Address_Checks; Address_Checks;
Check_Not_Incomplete_Type;
Set_Etype (N, RTE (RE_Address)); Set_Etype (N, RTE (RE_Address));
------------------ ------------------
...@@ -6019,6 +6054,7 @@ package body Sem_Attr is ...@@ -6019,6 +6054,7 @@ package body Sem_Attr is
end if; end if;
Analyze_Access_Attribute; Analyze_Access_Attribute;
Check_Not_Incomplete_Type;
------------------------- -------------------------
-- Unconstrained_Array -- -- Unconstrained_Array --
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2001-2014, Free Software Foundation, Inc. -- -- Copyright (C) 2001-2015, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -229,17 +229,6 @@ package body Switch.C is ...@@ -229,17 +229,6 @@ package body Switch.C is
new String'(Switch_Chars (Ptr + 4 .. Max)); new String'(Switch_Chars (Ptr + 4 .. Max));
end if; end if;
-- Check that this is the first time --RTS is specified
-- or if it is not the first time, the same path has been
-- specified.
if RTS_Specified = null then
RTS_Specified := Runtime_Dir;
elsif RTS_Specified.all /= Runtime_Dir.all then
Osint.Fail ("--RTS cannot be specified multiple times");
end if;
-- Valid --RTS switch -- Valid --RTS switch
Opt.No_Stdinc := True; Opt.No_Stdinc := True;
...@@ -251,13 +240,23 @@ package body Switch.C is ...@@ -251,13 +240,23 @@ package body Switch.C is
RTS_Lib_Path_Name := RTS_Lib_Path_Name :=
Get_RTS_Search_Dir (Runtime_Dir.all, Objects); Get_RTS_Search_Dir (Runtime_Dir.all, Objects);
if RTS_Src_Path_Name /= null if RTS_Specified /= null then
if RTS_Src_Path_Name = null
or else RTS_Lib_Path_Name = null
or else RTS_Specified.all /= RTS_Lib_Path_Name.all
then
Osint.Fail
("--RTS cannot be specified multiple times");
end if;
elsif RTS_Src_Path_Name /= null
and then RTS_Lib_Path_Name /= null and then RTS_Lib_Path_Name /= null
then then
-- Store the -fRTS switch (Note: Store_Compilation_Switch -- Store the -fRTS switch (Note: Store_Compilation_Switch
-- changes -fRTS back into --RTS for the actual output). -- changes -fRTS back into --RTS for the actual output).
Store_Compilation_Switch (Switch_Chars); Store_Compilation_Switch (Switch_Chars);
RTS_Specified := new String'(RTS_Lib_Path_Name.all);
elsif RTS_Src_Path_Name = null elsif RTS_Src_Path_Name = null
and then RTS_Lib_Path_Name = null and then RTS_Lib_Path_Name = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment