aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog20
-rw-r--r--gcc/ada/exp_ch6.adb2
-rw-r--r--gcc/ada/sem_attr.adb74
-rw-r--r--gcc/ada/switch-c.adb25
4 files changed, 88 insertions, 33 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 27f4cd0..72d2a65 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,23 @@
+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>
* sinfo.ads: Add comment.
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index 0195b74..870e5f8 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -3783,7 +3783,7 @@ package body Exp_Ch6 is
-- Front end expansion of simple functions returning unconstrained
-- 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
Expand_Inlined_Call (Call_Node, Subp, Orig_Subp);
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 --
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb
index 46939c6..c3b5733 100644
--- a/gcc/ada/switch-c.adb
+++ b/gcc/ada/switch-c.adb
@@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -229,17 +229,6 @@ package body Switch.C is
new String'(Switch_Chars (Ptr + 4 .. Max));
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
Opt.No_Stdinc := True;
@@ -251,13 +240,23 @@ package body Switch.C is
RTS_Lib_Path_Name :=
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
then
-- Store the -fRTS switch (Note: Store_Compilation_Switch
-- changes -fRTS back into --RTS for the actual output).
Store_Compilation_Switch (Switch_Chars);
+ RTS_Specified := new String'(RTS_Lib_Path_Name.all);
elsif RTS_Src_Path_Name = null
and then RTS_Lib_Path_Name = null