+2010-10-07 Robert Dewar <dewar@adacore.com>
+
+ * sem_attr.adb: Minor reformatting.
+ * einfo.ads, einfo.adb (Is_Ada_2012_Only): New flag
+ * itypes.adb (Create_Null_Excluding_Itype): Set Is_Ada_2012_Only flag
+ properly.
+ * lib-xref.adb (Generate_Reference): Warn on use of Ada 2012 entity in
+ non-Ada 2012 mode.
+ * opt.ads (Warn_On_Ada_2012_Compatibility): New flag
+ * sem_ch3.adb (Analye_Subtype_Declaration): Inherit Is_Ada_2012_Only
+ * sem_ch7.adb (Preserve_Full_Attributes): Preserve Is_Ada_2012_Only
+ flag.
+ * sem_prag.adb (Analyze_Pragma, case Ada_12/Ada_2012): Allow form with
+ argument.
+ * sem_type.adb (Disambiguate): Deal with Is_Ada_2012_Only.
+ * sem_warn.adb (Warn_On_Ada_2012_Compatibility): New flag, treated
+ same as 2005 flag.
+
+2010-10-07 Javier Miranda <miranda@adacore.com>
+
+ * a-tags.ads: Use new support for pragma Ada_2012 with function
+ Type_Is_Abstract.
+
2010-10-07 Ed Schonberg <schonberg@adacore.com>
* par-ch5.adb (P_Sequence_Of_Statements): In Ada2012 a label can end a
pragma Ada_05 (Interface_Ancestor_Tags);
function Type_Is_Abstract (T : Tag) return Boolean;
- pragma Ada_05 (Type_Is_Abstract);
+ pragma Ada_2012 (Type_Is_Abstract);
Tag_Error : exception;
-- Was_Hidden Flag196
-- Is_Limited_Interface Flag197
-- Has_Pragma_Ordered Flag198
+ -- Is_Ada_2012_Only Flag199
-- Has_Anon_Block_Suffix Flag201
-- Itype_Printed Flag202
-- Is_Underlying_Record_View Flag246
-- OK_To_Rename Flag247
- -- (unused) Flag199
-- (unused) Flag200
-----------------------
return Flag185 (Id);
end Is_Ada_2005_Only;
+ function Is_Ada_2012_Only (Id : E) return B is
+ begin
+ return Flag199 (Id);
+ end Is_Ada_2012_Only;
+
function Is_Aliased (Id : E) return B is
begin
pragma Assert (Nkind (Id) in N_Entity);
Set_Flag185 (Id, V);
end Set_Is_Ada_2005_Only;
+ procedure Set_Is_Ada_2012_Only (Id : E; V : B := True) is
+ begin
+ Set_Flag199 (Id, V);
+ end Set_Is_Ada_2012_Only;
+
procedure Set_Is_Aliased (Id : E; V : B := True) is
begin
pragma Assert (Nkind (Id) in N_Entity);
W ("Is_Local_Anonymous_Access", Flag194 (Id));
W ("Is_Access_Constant", Flag69 (Id));
W ("Is_Ada_2005_Only", Flag185 (Id));
+ W ("Is_Ada_2012_Only", Flag199 (Id));
W ("Is_Aliased", Flag15 (Id));
W ("Is_Asynchronous", Flag81 (Id));
W ("Is_Atomic", Flag85 (Id));
-- Applies to all entities, true for access types and subtypes
-- Is_Ada_2005_Only (Flag185)
--- Present in all entities, true if a valid pragma Ada_05 applies to the
--- entity which specifically names the entity, indicating that the entity
--- is Ada 2005 only. Note that this flag is not set if the entity is part
--- of a unit compiled with the normal no-argument form of pragma Ada_05.
+-- Present in all entities, true if a valid pragma Ada_05 or Ada_2005
+-- applies to the entity which specifically names the entity, indicating
+-- that the entity is Ada 2005 only. Note that this flag is not set if
+-- the entity is part of a unit compiled with the normal no-argument form
+-- of pragma Ada_05 or Ada_2005.
+
+-- Is_Ada_2012_Only (Flag199)
+-- Present in all entities, true if a valid pragma Ada_12 or Ada_2012
+-- applies to the entity which specifically names the entity, indicating
+-- that the entity is Ada 2012 only. Note that this flag is not set if
+-- the entity is part of a unit compiled with the normal no-argument form
+-- of pragma Ada_12 or Ada_2012.
-- Is_Aliased (Flag15)
-- Present in objects whose declarations carry the keyword aliased,
-- Has_Xref_Entry (Flag182)
-- In_Private_Part (Flag45)
-- Is_Ada_2005_Only (Flag185)
+ -- Is_Ada_2012_Only (Flag199)
-- Is_Bit_Packed_Array (Flag122) (base type only)
-- Is_Character_Type (Flag63)
-- Is_Child_Unit (Flag73)
function Is_Abstract_Type (Id : E) return B;
function Is_Access_Constant (Id : E) return B;
function Is_Ada_2005_Only (Id : E) return B;
+ function Is_Ada_2012_Only (Id : E) return B;
function Is_Aliased (Id : E) return B;
function Is_Asynchronous (Id : E) return B;
function Is_Atomic (Id : E) return B;
procedure Set_Is_Abstract_Type (Id : E; V : B := True);
procedure Set_Is_Access_Constant (Id : E; V : B := True);
procedure Set_Is_Ada_2005_Only (Id : E; V : B := True);
+ procedure Set_Is_Ada_2012_Only (Id : E; V : B := True);
procedure Set_Is_Aliased (Id : E; V : B := True);
procedure Set_Is_Asynchronous (Id : E; V : B := True);
procedure Set_Is_Atomic (Id : E; V : B := True);
pragma Inline (Is_Abstract_Type);
pragma Inline (Is_Access_Constant);
pragma Inline (Is_Ada_2005_Only);
+ pragma Inline (Is_Ada_2012_Only);
pragma Inline (Is_Access_Type);
pragma Inline (Is_Access_Protected_Subprogram_Type);
pragma Inline (Is_Access_Subprogram_Type);
pragma Inline (Set_Is_Abstract_Type);
pragma Inline (Set_Is_Access_Constant);
pragma Inline (Set_Is_Ada_2005_Only);
+ pragma Inline (Set_Is_Ada_2012_Only);
pragma Inline (Set_Is_Aliased);
pragma Inline (Set_Is_Asynchronous);
pragma Inline (Set_Is_Atomic);
Set_Treat_As_Volatile (I_Typ, Treat_As_Volatile (T));
Set_Is_Atomic (I_Typ, Is_Atomic (T));
Set_Is_Ada_2005_Only (I_Typ, Is_Ada_2005_Only (T));
+ Set_Is_Ada_2012_Only (I_Typ, Is_Ada_2012_Only (T));
Set_Can_Never_Be_Null (I_Typ);
return I_Typ;
Error_Msg_NE ("& is only defined in Ada 2005?", N, E);
end if;
+ -- Warn if reference to Ada 2012 entity not in Ada 2012 mode. We only
+ -- detect real explicit references (modifications and references).
+
+ if Comes_From_Source (N)
+ and then Is_Ada_2012_Only (E)
+ and then Ada_Version < Ada_12
+ and then Warn_On_Ada_2012_Compatibility
+ and then (Typ = 'm' or else Typ = 'r')
+ then
+ Error_Msg_NE ("& is only defined in Ada 2012?", N, E);
+ end if;
+
-- Never collect references if not in main source unit. However, we omit
-- this test if Typ is 'e' or 'k', since these entries are structural,
-- and it is useful to have them in units that reference packages as
-- including warnings on Ada 2005 obsolescent features used in Ada 2005
-- mode. Set False by -gnatwY.
+ Warn_On_Ada_2012_Compatibility : Boolean := True;
+ -- GNAT
+ -- Set to True to generate all warnings on Ada 2012 compatibility issues,
+ -- including warnings on Ada 2012 obsolescent features used in Ada 2012
+ -- mode. Set False by -gnatwY.
+
Warn_On_Parameter_Order : Boolean := False;
-- GNAT
-- Set to True to generate warnings for cases where the argument list for
-- These pragmas must be processed at parse time, since we want to set
-- the Ada version properly at parse time to recognize the appropriate
- -- Ada version syntax.
+ -- Ada version syntax. However, it is only the zero argument form that
+ -- must be processed at parse time.
when Pragma_Ada_12 | Pragma_Ada_2012 =>
- Ada_Version := Ada_12;
- Ada_Version_Explicit := Ada_12;
+ if Arg_Count = 0 then
+ Ada_Version := Ada_12;
+ Ada_Version_Explicit := Ada_12;
+ end if;
-----------
-- Debug --
-- that generic unit. This includes any such attribute that
-- occurs within the body of a generic unit that is a child
-- of the generic unit where the subprogram is declared.
+
-- The rule also prohibits applying the attribute when the
-- access type is a generic formal access type (since the
-- level of the actual type is not known). This restriction
Set_Treat_As_Volatile (Id, Treat_As_Volatile (T));
Set_Is_Atomic (Id, Is_Atomic (T));
Set_Is_Ada_2005_Only (Id, Is_Ada_2005_Only (T));
+ Set_Is_Ada_2012_Only (Id, Is_Ada_2012_Only (T));
Set_Convention (Id, Convention (T));
-- In the case where there is no constraint given in the subtype
Set_Is_Volatile (Priv, Is_Volatile (Full));
Set_Treat_As_Volatile (Priv, Treat_As_Volatile (Full));
Set_Is_Ada_2005_Only (Priv, Is_Ada_2005_Only (Full));
+ Set_Is_Ada_2012_Only (Priv, Is_Ada_2012_Only (Full));
Set_Has_Pragma_Unmodified (Priv, Has_Pragma_Unmodified (Full));
Set_Has_Pragma_Unreferenced (Priv, Has_Pragma_Unreferenced (Full));
Set_Has_Pragma_Unreferenced_Objects
-- pragma Ada_2005;
-- pragma Ada_2005 (LOCAL_NAME):
- -- Note: these pragma also have some specific processing in Par.Prag
+ -- Note: these pragmas also have some specific processing in Par.Prag
-- because we want to set the Ada 2005 version mode during parsing.
when Pragma_Ada_05 | Pragma_Ada_2005 => declare
---------------------
-- pragma Ada_12;
+ -- pragma Ada_12 (LOCAL_NAME);
+
-- pragma Ada_2012;
+ -- pragma Ada_2012 (LOCAL_NAME):
- -- Note: these pragma also have some specific processing in Par.Prag
+ -- Note: these pragmas also have some specific processing in Par.Prag
-- because we want to set the Ada 2012 version mode during parsing.
- when Pragma_Ada_12 | Pragma_Ada_2012 =>
+ when Pragma_Ada_12 | Pragma_Ada_2012 => declare
+ E_Id : Node_Id;
+
+ begin
GNAT_Pragma;
- Check_Arg_Count (0);
- -- For Ada_2012 we unconditionally enforce the documented
- -- configuration pragma placement, since we do not want to
- -- tolerate mixed modes in a unit involving Ada 2012. That would
- -- cause real difficulties for those cases where there are
- -- incompatibilities between Ada 95 and Ada 2005/Ada 2012.
+ if Arg_Count = 1 then
+ Check_Arg_Is_Local_Name (Arg1);
+ E_Id := Expression (Arg1);
- Check_Valid_Configuration_Pragma;
+ if Etype (E_Id) = Any_Type then
+ return;
+ end if;
- -- Now set Ada 2012 mode
+ Set_Is_Ada_2012_Only (Entity (E_Id));
- Ada_Version := Ada_12;
- Ada_Version_Explicit := Ada_12;
+ else
+ Check_Arg_Count (0);
+
+ -- For Ada_2012 we unconditionally enforce the documented
+ -- configuration pragma placement, since we do not want to
+ -- tolerate mixed modes in a unit involving Ada 2012. That
+ -- would cause real difficulties for those cases where there
+ -- are incompatibilities between Ada 95 and Ada 2012. We could
+ -- allow mixing of Ada 2005 and Ada 2012 but it's not worth it.
+
+ Check_Valid_Configuration_Pragma;
+
+ -- Now set Ada 2012 mode
+
+ Ada_Version := Ada_12;
+ Ada_Version_Explicit := Ada_12;
+ end if;
+ end;
----------------------
-- All_Calls_Remote --
It2 := It;
Nam2 := It.Nam;
+ -- Check whether one of the entities is an Ada 2005/2012 and we are
+ -- operating in an earlier mode, in which case we discard the Ada
+ -- 2005/2012 entity, so that we get proper Ada 95 overload resolution.
+
if Ada_Version < Ada_05 then
+ if Is_Ada_2005_Only (Nam1) or else Is_Ada_2012_Only (Nam1) then
+ return It2;
+ elsif Is_Ada_2005_Only (Nam2) or else Is_Ada_2012_Only (Nam1) then
+ return It1;
+ end if;
+ end if;
- -- Check whether one of the entities is an Ada 2005 entity and we are
- -- operating in an earlier mode, in which case we discard the Ada
- -- 2005 entity, so that we get proper Ada 95 overload resolution.
+ -- Check whether one of the entities is an Ada 2012 entity and we are
+ -- operating in Ada 2005 mode, in which case we discard the Ada 2012
+ -- entity, so that we get proper Ada 2005 overload resolution.
- if Is_Ada_2005_Only (Nam1) then
+ if Ada_Version = Ada_05 then
+ if Is_Ada_2012_Only (Nam1) then
return It2;
- elsif Is_Ada_2005_Only (Nam2) then
+ elsif Is_Ada_2012_Only (Nam2) then
return It1;
end if;
end if;
Implementation_Unit_Warnings := True;
Ineffective_Inline_Warnings := True;
Warn_On_Ada_2005_Compatibility := True;
+ Warn_On_Ada_2012_Compatibility := True;
Warn_On_All_Unread_Out_Parameters := True;
Warn_On_Assertion_Failure := True;
Warn_On_Assumed_Low_Bound := True;
Implementation_Unit_Warnings := False;
Ineffective_Inline_Warnings := True;
Warn_On_Ada_2005_Compatibility := True;
+ Warn_On_Ada_2012_Compatibility := True;
Warn_On_All_Unread_Out_Parameters := False;
Warn_On_Assertion_Failure := True;
Warn_On_Assumed_Low_Bound := True;
Implementation_Unit_Warnings := True;
Ineffective_Inline_Warnings := True;
Warn_On_Ada_2005_Compatibility := True;
+ Warn_On_Ada_2012_Compatibility := True;
Warn_On_Assertion_Failure := True;
Warn_On_Assumed_Low_Bound := True;
Warn_On_Bad_Fixed_Value := True;
Implementation_Unit_Warnings := False;
Ineffective_Inline_Warnings := False;
Warn_On_Ada_2005_Compatibility := False;
+ Warn_On_Ada_2012_Compatibility := False;
Warn_On_All_Unread_Out_Parameters := False;
Warn_On_Assertion_Failure := False;
Warn_On_Assumed_Low_Bound := False;
when 'y' =>
Warn_On_Ada_2005_Compatibility := True;
+ Warn_On_Ada_2012_Compatibility := True;
when 'Y' =>
Warn_On_Ada_2005_Compatibility := False;
+ Warn_On_Ada_2012_Compatibility := False;
when 'z' =>
Warn_On_Unchecked_Conversion := True;