+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.
-- 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;
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)
when Attribute_Access =>
Analyze_Access_Attribute;
+ Check_Not_Incomplete_Type;
-------------
-- Address --
when Attribute_Address =>
Check_E0;
Address_Checks;
+ Check_Not_Incomplete_Type;
Set_Etype (N, RTE (RE_Address));
------------------
end if;
Analyze_Access_Attribute;
+ Check_Not_Incomplete_Type;
-------------------------
-- Unconstrained_Array --
-- --
-- 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- --
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;
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