aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-05 15:51:33 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-05 15:51:33 +0200
commit0da80d7dbbbd8e772cf30f8866b4fdc02cb9c64f (patch)
tree5544d8f20cf86096570992334334c7b367abf57a
parent7324247364df0b8e4be9038eea1d8cfc032de677 (diff)
downloadgcc-0da80d7dbbbd8e772cf30f8866b4fdc02cb9c64f.zip
gcc-0da80d7dbbbd8e772cf30f8866b4fdc02cb9c64f.tar.gz
gcc-0da80d7dbbbd8e772cf30f8866b4fdc02cb9c64f.tar.bz2
[multiple changes]
2011-08-05 Hristian Kirtchev <kirtchev@adacore.com> * exp_ch7.adb (Is_Init_Call): Reimplemented to avoid character comparison and rely on concrete entities instead. 2011-08-05 Ed Schonberg <schonberg@adacore.com> * einfo.ads, einfo.adb (Has_Implicit_Dereference): new flag on types and discriminants, to indicate that the type has an access discriminant that supports implicit dereference. * snames.ads-tmpl: Add names of aspects and attributes related to Ada2012 iterators: constant_indexing, default_iterator, iterator_element, implicit_dereference, variable_indexing. * aspects.ads, aspects.adb: entries for iterator-related aspects. * sem_ch13.adb (Analyze_aspect_specifications): dummy entries for iterator-related aspects. * sem_attr.adb, exp_attr.adb Dummy entries for iterator-related aspects. 2011-08-05 Sergey Rybin <rybin@adacore.com> * gnat_ugn.texi, vms_data.ads: Extend the subsection about coupling metrics in gnatmetric to cover new kinds of coupling mentrics. 2011-08-05 Steve Baird <baird@adacore.com> * bindgen.adb (Gen_CodePeer_Wrapper): Call Ada_Main_Program instead of calling the user-defined main subprogram. (Gen_Main): Declare Ada_Main_Program and (if CodePeer_Mode is set) Call_Main_Subprogram ahead of, as opposed to inside of, Main. (Gen_Output_File_Ada): Remove CodePeer_Mode-conditional generation of a "with" of the user-defined main subprogram. Remove CodePeer_Mode-conditional call to Gen_CodePeer_Wrapper (which is now called from Gen_Main instead). From-SVN: r177436
-rw-r--r--gcc/ada/ChangeLog35
-rwxr-xr-xgcc/ada/aspects.adb5
-rwxr-xr-xgcc/ada/aspects.ads15
-rw-r--r--gcc/ada/bindgen.adb134
-rw-r--r--gcc/ada/einfo.adb14
-rw-r--r--gcc/ada/einfo.ads9
-rw-r--r--gcc/ada/exp_attr.adb8
-rw-r--r--gcc/ada/exp_ch7.adb6
-rw-r--r--gcc/ada/gnat_ugn.texi158
-rw-r--r--gcc/ada/sem_attr.adb16
-rw-r--r--gcc/ada/sem_ch13.adb58
-rw-r--r--gcc/ada/snames.ads-tmpl10
-rw-r--r--gcc/ada/vms_data.ads55
13 files changed, 360 insertions, 163 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ecbcadc..a1ba74c 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,38 @@
+2011-08-05 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * exp_ch7.adb (Is_Init_Call): Reimplemented to avoid character
+ comparison and rely on concrete entities instead.
+
+2011-08-05 Ed Schonberg <schonberg@adacore.com>
+
+ * einfo.ads, einfo.adb (Has_Implicit_Dereference): new flag on types
+ and discriminants, to indicate that the type has an access discriminant
+ that supports implicit dereference.
+ * snames.ads-tmpl: Add names of aspects and attributes related to
+ Ada2012 iterators: constant_indexing, default_iterator,
+ iterator_element, implicit_dereference, variable_indexing.
+ * aspects.ads, aspects.adb: entries for iterator-related aspects.
+ * sem_ch13.adb (Analyze_aspect_specifications): dummy entries for
+ iterator-related aspects.
+ * sem_attr.adb, exp_attr.adb Dummy entries for iterator-related aspects.
+
+2011-08-05 Sergey Rybin <rybin@adacore.com>
+
+ * gnat_ugn.texi, vms_data.ads: Extend the subsection about coupling
+ metrics in gnatmetric to cover new kinds of coupling mentrics.
+
+2011-08-05 Steve Baird <baird@adacore.com>
+
+ * bindgen.adb (Gen_CodePeer_Wrapper): Call Ada_Main_Program instead
+ of calling the user-defined main subprogram.
+ (Gen_Main): Declare Ada_Main_Program and (if CodePeer_Mode
+ is set) Call_Main_Subprogram ahead of, as opposed to
+ inside of, Main.
+ (Gen_Output_File_Ada): Remove CodePeer_Mode-conditional
+ generation of a "with" of the user-defined main subprogram.
+ Remove CodePeer_Mode-conditional call to Gen_CodePeer_Wrapper
+ (which is now called from Gen_Main instead).
+
2011-08-05 Emmanuel Briot <briot@adacore.com>
* projects.texi: Added reference to the Makefile package.
diff --git a/gcc/ada/aspects.adb b/gcc/ada/aspects.adb
index 7495a2d..82649db 100755
--- a/gcc/ada/aspects.adb
+++ b/gcc/ada/aspects.adb
@@ -179,14 +179,18 @@ package body Aspects is
Aspect_Atomic_Components => Aspect_Atomic_Components,
Aspect_Bit_Order => Aspect_Bit_Order,
Aspect_Component_Size => Aspect_Component_Size,
+ Aspect_Constant_Indexing => Aspect_Constant_Indexing,
Aspect_Default_Component_Value => Aspect_Default_Component_Value,
+ Aspect_Default_Iterator => Aspect_Default_Iterator,
Aspect_Default_Value => Aspect_Default_Value,
Aspect_Discard_Names => Aspect_Discard_Names,
Aspect_Dynamic_Predicate => Aspect_Predicate,
Aspect_External_Tag => Aspect_External_Tag,
Aspect_Favor_Top_Level => Aspect_Favor_Top_Level,
+ Aspect_Implicit_Dereference => Aspect_Implicit_Dereference,
Aspect_Inline => Aspect_Inline,
Aspect_Inline_Always => Aspect_Inline,
+ Aspect_Iterator_Element => Aspect_Iterator_Element,
Aspect_All_Calls_Remote => Aspect_All_Calls_Remote,
Aspect_Compiler_Unit => Aspect_Compiler_Unit,
Aspect_Elaborate_Body => Aspect_Elaborate_Body,
@@ -230,6 +234,7 @@ package body Aspects is
Aspect_Unreferenced => Aspect_Unreferenced,
Aspect_Unreferenced_Objects => Aspect_Unreferenced_Objects,
Aspect_Unsuppress => Aspect_Unsuppress,
+ Aspect_Variable_Indexing => Aspect_Variable_Indexing,
Aspect_Value_Size => Aspect_Value_Size,
Aspect_Volatile => Aspect_Volatile,
Aspect_Volatile_Components => Aspect_Volatile_Components,
diff --git a/gcc/ada/aspects.ads b/gcc/ada/aspects.ads
index 4b2d814..af4448f 100755
--- a/gcc/ada/aspects.ads
+++ b/gcc/ada/aspects.ads
@@ -48,12 +48,16 @@ package Aspects is
Aspect_Alignment,
Aspect_Bit_Order,
Aspect_Component_Size,
+ Aspect_Constant_Indexing,
Aspect_Default_Component_Value,
+ Aspect_Default_Iterator,
Aspect_Default_Value,
Aspect_Dynamic_Predicate,
Aspect_External_Tag,
+ Aspect_Implicit_Dereference,
Aspect_Input,
Aspect_Invariant,
+ Aspect_Iterator_Element,
Aspect_Machine_Radix,
Aspect_Object_Size, -- GNAT
Aspect_Output,
@@ -73,6 +77,7 @@ package Aspects is
Aspect_Type_Invariant,
Aspect_Unsuppress,
Aspect_Value_Size, -- GNAT
+ Aspect_Variable_Indexing,
Aspect_Warnings,
Aspect_Write,
@@ -172,12 +177,16 @@ package Aspects is
Aspect_Alignment => Expression,
Aspect_Bit_Order => Expression,
Aspect_Component_Size => Expression,
+ Aspect_Constant_Indexing => Name,
Aspect_Default_Component_Value => Expression,
+ Aspect_Default_Iterator => Name,
Aspect_Default_Value => Expression,
Aspect_Dynamic_Predicate => Expression,
Aspect_External_Tag => Expression,
+ Aspect_Implicit_Dereference => Name,
Aspect_Input => Name,
Aspect_Invariant => Expression,
+ Aspect_Iterator_Element => Name,
Aspect_Machine_Radix => Expression,
Aspect_Object_Size => Expression,
Aspect_Output => Name,
@@ -197,6 +206,7 @@ package Aspects is
Aspect_Type_Invariant => Expression,
Aspect_Unsuppress => Name,
Aspect_Value_Size => Expression,
+ Aspect_Variable_Indexing => Name,
Aspect_Warnings => Name,
Aspect_Write => Name,
@@ -221,6 +231,8 @@ package Aspects is
Aspect_Bit_Order => Name_Bit_Order,
Aspect_Compiler_Unit => Name_Compiler_Unit,
Aspect_Component_Size => Name_Component_Size,
+ Aspect_Constant_Indexing => Name_Constant_Indexing,
+ Aspect_Default_Iterator => Name_Default_Iterator,
Aspect_Default_Value => Name_Default_Value,
Aspect_Default_Component_Value => Name_Default_Component_Value,
Aspect_Discard_Names => Name_Discard_Names,
@@ -228,10 +240,12 @@ package Aspects is
Aspect_Elaborate_Body => Name_Elaborate_Body,
Aspect_External_Tag => Name_External_Tag,
Aspect_Favor_Top_Level => Name_Favor_Top_Level,
+ Aspect_Implicit_Dereference => Name_Implicit_Dereference,
Aspect_Inline => Name_Inline,
Aspect_Inline_Always => Name_Inline_Always,
Aspect_Input => Name_Input,
Aspect_Invariant => Name_Invariant,
+ Aspect_Iterator_Element => Name_Iterator_Element,
Aspect_Machine_Radix => Name_Machine_Radix,
Aspect_No_Return => Name_No_Return,
Aspect_Object_Size => Name_Object_Size,
@@ -271,6 +285,7 @@ package Aspects is
Aspect_Unreferenced_Objects => Name_Unreferenced_Objects,
Aspect_Unsuppress => Name_Unsuppress,
Aspect_Value_Size => Name_Value_Size,
+ Aspect_Variable_Indexing => Name_Variable_Indexing,
Aspect_Volatile => Name_Volatile,
Aspect_Volatile_Components => Name_Volatile_Components,
Aspect_Warnings => Name_Warnings,
diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index 98dc986..856a4de 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -928,28 +928,18 @@ package body Bindgen is
--------------------------
procedure Gen_CodePeer_Wrapper is
+ Callee_Name : constant String := "Ada_Main_Program";
begin
- Get_Name_String (Units.Table (First_Unit_Entry).Uname);
-
- declare
- -- Bypass Ada_Main_Program; its Import pragma confuses CodePeer
-
- Callee_Name : String renames Name_Buffer (1 .. Name_Len - 2);
- -- Strip trailing "%b"
-
- begin
- if ALIs.Table (ALIs.First).Main_Program = Proc then
- WBI (" procedure " & CodePeer_Wrapper_Name & " is ");
- WBI (" begin");
- WBI (" " & Callee_Name & ";");
+ if ALIs.Table (ALIs.First).Main_Program = Proc then
+ WBI (" procedure " & CodePeer_Wrapper_Name & " is ");
+ WBI (" begin");
+ WBI (" " & Callee_Name & ";");
- else
- WBI
- (" function " & CodePeer_Wrapper_Name & " return Integer is");
- WBI (" begin");
- WBI (" return " & Callee_Name & ";");
- end if;
- end;
+ else
+ WBI (" function " & CodePeer_Wrapper_Name & " return Integer is");
+ WBI (" begin");
+ WBI (" return " & Callee_Name & ";");
+ end if;
WBI (" end " & CodePeer_Wrapper_Name & ";");
WBI ("");
@@ -1481,6 +1471,42 @@ package body Bindgen is
procedure Gen_Main is
begin
+ if not No_Main_Subprogram then
+ -- To call the main program, we declare it using a pragma Import
+ -- Ada with the right link name.
+
+ -- It might seem more obvious to "with" the main program, and call
+ -- it in the normal Ada manner. We do not do this for three
+ -- reasons:
+
+ -- 1. It is more efficient not to recompile the main program
+ -- 2. We are not entitled to assume the source is accessible
+ -- 3. We don't know what options to use to compile it
+
+ -- It is really reason 3 that is most critical (indeed we used
+ -- to generate the "with", but several regression tests failed).
+
+ if ALIs.Table (ALIs.First).Main_Program = Func then
+ WBI (" function Ada_Main_Program return Integer;");
+
+ else
+ WBI (" procedure Ada_Main_Program;");
+ end if;
+
+ Set_String (" pragma Import (Ada, Ada_Main_Program, """);
+ Get_Name_String (Units.Table (First_Unit_Entry).Uname);
+ Set_Main_Program_Name;
+ Set_String (""");");
+
+ Write_Statement_Buffer;
+ WBI ("");
+
+ -- For CodePeer, declare a wrapper for the user-defined main program
+ if CodePeer_Mode then
+ Gen_CodePeer_Wrapper;
+ end if;
+ end if;
+
if Exit_Status_Supported_On_Target then
Set_String (" function ");
else
@@ -1551,51 +1577,17 @@ package body Bindgen is
-- Deal with declarations for main program case
if not No_Main_Subprogram then
- if CodePeer_Mode then
- if ALIs.Table (ALIs.First).Main_Program = Func then
- WBI (" Result : Integer;");
- end if;
-
- else
- -- To call the main program, we declare it using a pragma Import
- -- Ada with the right link name.
-
- -- It might seem more obvious to "with" the main program, and call
- -- it in the normal Ada manner. We do not do this for three
- -- reasons:
-
- -- 1. It is more efficient not to recompile the main program
- -- 2. We are not entitled to assume the source is accessible
- -- 3. We don't know what options to use to compile it
-
- -- It is really reason 3 that is most critical (indeed we used
- -- to generate the "with", but several regression tests failed).
-
+ if ALIs.Table (ALIs.First).Main_Program = Func then
+ WBI (" Result : Integer;");
WBI ("");
+ end if;
- if ALIs.Table (ALIs.First).Main_Program = Func then
- WBI (" Result : Integer;");
- WBI ("");
- WBI (" function Ada_Main_Program return Integer;");
-
- else
- WBI (" procedure Ada_Main_Program;");
- end if;
-
- Set_String (" pragma Import (Ada, Ada_Main_Program, """);
- Get_Name_String (Units.Table (First_Unit_Entry).Uname);
- Set_Main_Program_Name;
- Set_String (""");");
-
- Write_Statement_Buffer;
+ if Bind_Main_Program
+ and then not Suppress_Standard_Library_On_Target
+ and then not CodePeer_Mode
+ then
+ WBI (" SEH : aliased array (1 .. 2) of Integer;");
WBI ("");
-
- if Bind_Main_Program
- and then not Suppress_Standard_Library_On_Target
- then
- WBI (" SEH : aliased array (1 .. 2) of Integer;");
- WBI ("");
- end if;
end if;
end if;
@@ -2310,17 +2302,6 @@ package body Bindgen is
WBI ("with Ada.Exceptions;");
end if;
- if CodePeer_Mode then
-
- -- For CodePeer, main program is not called via an Import pragma
-
- Get_Name_String (Units.Table (First_Unit_Entry).Uname);
-
- -- Note: trailing "%b" is stripped.
-
- WBI ("with " & Name_Buffer (1 .. Name_Len - 2) & ";");
- end if;
-
WBI ("");
WBI ("package body " & Ada_Main & " is");
WBI (" pragma Warnings (Off);");
@@ -2379,13 +2360,6 @@ package body Bindgen is
Gen_Adainit;
if Bind_Main_Program and then VM_Target = No_VM then
-
- -- For CodePeer, declare a wrapper for the user-defined main program
-
- if CodePeer_Mode then
- Gen_CodePeer_Wrapper;
- end if;
-
Gen_Main;
end if;
diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb
index a53d07f..b10b426 100644
--- a/gcc/ada/einfo.adb
+++ b/gcc/ada/einfo.adb
@@ -522,8 +522,7 @@ package body Einfo is
-- Is_Processed_Transient Flag252
-- Is_Postcondition_Proc Flag253
- -- (unused) Flag151
- -- (unused) Flag251
+ -- (Has_Implicit_Dereference) Flag251
-- (unused) Flag254
-----------------------
@@ -1308,6 +1307,11 @@ package body Einfo is
return Flag56 (Id);
end Has_Homonym;
+ function Has_Implicit_Dereference (Id : E) return B is
+ begin
+ return Flag251 (Id);
+ end Has_Implicit_Dereference;
+
function Has_Inheritable_Invariants (Id : E) return B is
begin
pragma Assert (Is_Type (Id));
@@ -3795,6 +3799,11 @@ package body Einfo is
Set_Flag56 (Id, V);
end Set_Has_Homonym;
+ procedure Set_Has_Implicit_Dereference (Id : E; V : B := True) is
+ begin
+ Set_Flag251 (Id, V);
+ end Set_Has_Implicit_Dereference;
+
procedure Set_Has_Inheritable_Invariants (Id : E; V : B := True) is
begin
pragma Assert (Is_Type (Id));
@@ -7429,6 +7438,7 @@ package body Einfo is
W ("Has_Fully_Qualified_Name", Flag173 (Id));
W ("Has_Gigi_Rep_Item", Flag82 (Id));
W ("Has_Homonym", Flag56 (Id));
+ W ("Has_Implicit_Dereference", Flag251 (Id));
W ("Has_Inheritable_Invariants", Flag248 (Id));
W ("Has_Initial_Value", Flag219 (Id));
W ("Has_Invariants", Flag232 (Id));
diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index a4ca25d..2b82567 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -1508,6 +1508,11 @@ package Einfo is
-- Present in all entities. Set if an entity has a homonym in the same
-- scope. Used by Gigi to generate unique names for such entities.
+-- Has_Implicit_Dereference (Flag251)
+-- Present in types and discriminants. Set if the type has an aspect
+-- Implicit_Dereference. Set also on the discriminant named in the aspect
+-- clause, to simplify type resolution.
+
-- Has_Initial_Value (Flag219)
-- Present in entities for variables and out parameters. Set if there
-- is an explicit initial value expression in the declaration of the
@@ -6093,6 +6098,7 @@ package Einfo is
function Has_Fully_Qualified_Name (Id : E) return B;
function Has_Gigi_Rep_Item (Id : E) return B;
function Has_Homonym (Id : E) return B;
+ function Has_Implicit_Dereference (Id : E) return B;
function Has_Inheritable_Invariants (Id : E) return B;
function Has_Initial_Value (Id : E) return B;
function Has_Invariants (Id : E) return B;
@@ -6680,6 +6686,7 @@ package Einfo is
procedure Set_Has_Fully_Qualified_Name (Id : E; V : B := True);
procedure Set_Has_Gigi_Rep_Item (Id : E; V : B := True);
procedure Set_Has_Homonym (Id : E; V : B := True);
+ procedure Set_Has_Implicit_Dereference (Id : E; V : B := True);
procedure Set_Has_Inheritable_Invariants (Id : E; V : B := True);
procedure Set_Has_Initial_Value (Id : E; V : B := True);
procedure Set_Has_Invariants (Id : E; V : B := True);
@@ -7376,6 +7383,7 @@ package Einfo is
pragma Inline (Has_Fully_Qualified_Name);
pragma Inline (Has_Gigi_Rep_Item);
pragma Inline (Has_Homonym);
+ pragma Inline (Has_Implicit_Dereference);
pragma Inline (Has_Inheritable_Invariants);
pragma Inline (Has_Initial_Value);
pragma Inline (Has_Invariants);
@@ -7819,6 +7827,7 @@ package Einfo is
pragma Inline (Set_Has_Fully_Qualified_Name);
pragma Inline (Set_Has_Gigi_Rep_Item);
pragma Inline (Set_Has_Homonym);
+ pragma Inline (Set_Has_Implicit_Dereference);
pragma Inline (Set_Has_Inheritable_Invariants);
pragma Inline (Set_Has_Initial_Value);
pragma Inline (Set_Has_Invariants);
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 6131b23..c0129d8 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -678,6 +678,14 @@ package body Exp_Attr is
case Id is
+ -- Attributes related to Ada2012 iterators (Placeholder)
+
+ when Attribute_Constant_Indexing => null;
+ when Attribute_Default_Iterator => null;
+ when Attribute_Implicit_Dereference => null;
+ when Attribute_Iterator_Element => null;
+ when Attribute_Variable_Indexing => null;
+
------------
-- Access --
------------
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index a537e60..1c84e6b 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2289,7 +2289,7 @@ package body Exp_Ch7 is
and then Nkind (Name (N)) = N_Identifier
then
declare
- Call_Nam : constant Name_Id := Chars (Entity (Name (N)));
+ Call_Ent : constant Entity_Id := Entity (Name (N));
Deep_Init : constant Entity_Id :=
TSS (Typ, TSS_Deep_Initialize);
Init : Entity_Id := Empty;
@@ -2304,10 +2304,10 @@ package body Exp_Ch7 is
return
(Present (Deep_Init)
- and then Chars (Deep_Init) = Call_Nam)
+ and then Call_Ent = Deep_Init)
or else
(Present (Init)
- and then Chars (Init) = Call_Nam);
+ and then Call_Ent = Init);
end;
end if;
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index c256b48..2dedf85 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -14106,7 +14106,7 @@ explicitly specified metrics are reported.
* Line Metrics Control::
* Syntax Metrics Control::
* Complexity Metrics Control::
-* Object-Oriented Metrics Control::
+* Coupling Metrics Control::
@end menu
@node Line Metrics Control
@@ -14515,30 +14515,69 @@ Do not report the extra exit points for subprogram bodies
@end table
-@node Object-Oriented Metrics Control
-@subsubsection Object-Oriented Metrics Control
-@cindex Object-Oriented metrics control in @command{gnatmetric}
+@node Coupling Metrics Control
+@subsubsection Coupling Metrics Control
+@cindex Coupling metrics control in @command{gnatmetric}
@noindent
@cindex Coupling metrics (in in @command{gnatmetric})
-Coupling metrics are object-oriented metrics that measure the
-dependencies between a given class (or a group of classes) and the
-``external world'' (that is, the other classes in the program). In this
-subsection the term ``class'' is used in its
-traditional object-oriented programming sense
-(an instantiable module that contains data and/or method members).
-A @emph{category} (of classes)
-is a group of closely related classes that are reused and/or
-modified together.
-
-A class @code{K}'s @emph{efferent coupling} is the number of classes
+Coupling metrics measure the dependencies between a given entity and other
+entities the program consists of. The goal of these metrics is to estimate the
+stability of the whole program considered as the collection of entities
+(modules, classes etc.).
+
+Gnatmetric computes the following coupling metrics:
+
+@itemize @bullet
+
+@item
+@emph{object-oriented coupling} - for classes in traditional object-oriented
+sense;
+
+@item
+emph{unit coupling} - for all the program units making up a program;
+
+@item
+emph{control coupling} - this metric counts dependencies between a unit and
+only those units that define subprograms;
+@end itemize
+
+@noindent
+Two kinds of coupling metrics are computed:
+
+@table @asis
+@item fan-out coupling (efferent coupling)
+@cindex fan-out coupling
+@cindex efferent coupling
+the number of entities the given entity depends upon. It
+estimates in what extent the given entity depends on the changes in
+``external world''
+
+@item fan-in coupling (afferent coupling)
+@cindex fan-in coupling
+@cindex afferent coupling
+the number of entities that depend on a given entity.
+It estimates in what extent the ``external world'' depends on the changes in a
+given entity
+@end table
+
+@noindent
+
+Object-oriented coupling metrics are metrics that measure the dependencies
+between a given class (or a group of classes) and the other classes in the
+program. In this subsection the term ``class'' is used in its traditional
+object-oriented programming sense (an instantiable module that contains data
+and/or method members). A @emph{category} (of classes) is a group of closely
+related classes that are reused and/or modified together.
+
+A class @code{K}'s fan-out coupling is the number of classes
that @code{K} depends upon.
-A category's efferent coupling is the number of classes outside the
+A category's fan-out coupling is the number of classes outside the
category that the classes inside the category depend upon.
-A class @code{K}'s @emph{afferent coupling} is the number of classes
+A class @code{K}'s fan-in coupling is the number of classes
that depend upon @code{K}.
-A category's afferent coupling is the number of classes outside the
+A category's fan-in coupling is the number of classes outside the
category that depend on classes belonging to the category.
Ada's implementation of the object-oriented paradigm does not use the
@@ -14552,13 +14591,36 @@ that define a tagged type or an interface type are
considered to be a class. A category consists of a library package (or
a library generic package) that defines a tagged or an interface type,
together with all its descendant (generic) packages that define tagged
-or interface types. For any package counted as a class,
-its body and subunits (if any) are considered
-together with its spec when counting the dependencies, and coupling
-metrics are reported for spec units only. For dependencies
-between classes, the Ada semantic dependencies are considered.
-For coupling metrics, only dependencies on units that are considered as
-classes, are considered.
+or interface types. That is a
+category is an Ada hierarchy of library-level program units. So class coupling
+in case of Ada is called as tagged coupling, and category coupling - as
+hierarchy coupling.
+
+For any package counted as a class, its body and subunits (if any) are
+considered together with its spec when counting the dependencies, and coupling
+metrics are reported for spec units only. For dependencies between classes,
+the Ada semantic dependencies are considered. For object-oriented coupling
+metrics, only dependencies on units that are considered as classes, are
+considered.
+
+For unit and control coupling also not compilation units but program units are
+counted. That is, for a package, its spec, its body and its subunits (if any)
+are considered as making up one unit, and the dependencies that are counted
+are the dependencies of all these compilation units collected together as
+the dependencies as a (whole) unit. And metrics are reported for spec
+compilation units only (or for a subprogram body unit in case if there is no
+separate spec for the given subprogram).
+
+For unit coupling, dependencies between all kinds of program units are
+considered. For control coupling, for each unit the dependencies of this unit
+upon units that define subprograms are counted, so control fan-out coupling
+is reported for all units, but control fan-in coupling - only for the units
+that define subprograms.
+
+
+
+
+
When computing coupling metrics, @command{gnatmetric} counts only
dependencies between units that are arguments of the gnatmetric call.
@@ -14566,7 +14628,7 @@ Coupling metrics are program-wide (or project-wide) metrics, so to
get a valid result, you should call @command{gnatmetric} for
the whole set of sources that make up your program. It can be done
by calling @command{gnatmetric} from the GNAT driver with @option{-U}
-option (see See @ref{The GNAT Driver and Project Files} for details.
+option (see @ref{The GNAT Driver and Project Files} for details).
By default, all the coupling metrics are disabled. You can use the following
switches to specify the coupling metrics to be computed and reported:
@@ -14574,10 +14636,10 @@ switches to specify the coupling metrics to be computed and reported:
@table @option
@ifclear vms
-@cindex @option{--package@var{x}} (@command{gnatmetric})
-@cindex @option{--no-package@var{x}} (@command{gnatmetric})
-@cindex @option{--category@var{x}} (@command{gnatmetric})
-@cindex @option{--no-category@var{x}} (@command{gnatmetric})
+@cindex @option{--tagged-coupling@var{x}} (@command{gnatmetric})
+@cindex @option{--hierarchy-coupling@var{x}} (@command{gnatmetric})
+@cindex @option{--unit-coupling@var{x}} (@command{gnatmetric})
+@cindex @option{--control-coupling@var{x}} (@command{gnatmetric})
@end ifclear
@ifset vms
@@ -14587,33 +14649,29 @@ switches to specify the coupling metrics to be computed and reported:
@item ^--coupling-all^/COUPLING_METRICS=ALL^
Report all the coupling metrics
-@item ^--no-coupling-all^/COUPLING_METRICS=NONE^
-Do not report any of metrics
-
-@item ^--package-efferent-coupling^/COUPLING_METRICS=PACKAGE_EFFERENT^
-Report package efferent coupling
-
-@item ^--no-package-efferent-coupling^/COUPLING_METRICS=NOPACKAGE_EFFERENT^
-Do not report package efferent coupling
+@item ^--tagged-coupling-out^/COUPLING_METRICS=TAGGED_OUT^
+Report tagged (class) fan-out coupling
-@item ^--package-afferent-coupling^/COUPLING_METRICS=PACKAGE_AFFERENT^
-Report package afferent coupling
+@item ^--tagged-coupling-in^/COUPLING_METRICS=TAGGED_IN^
+Report tagged (class) fan-in coupling
-@item ^--no-package-afferent-coupling^/COUPLING_METRICS=NOPACKAGE_AFFERENT^
-Do not report package afferent coupling
+@item ^--hierarchy-coupling-out^/COUPLING_METRICS=HIERARCHY_OUT^
+Report hierarchy (category) fan-out coupling
-@item ^--category-efferent-coupling^/COUPLING_METRICS=CATEGORY_EFFERENT^
-Report category efferent coupling
+@item ^--hierarchy-coupling-in^/COUPLING_METRICS=HIERARCHY_IN^
+Report hierarchy (category) fan-in coupling
-@item ^--no-category-efferent-coupling^/COUPLING_METRICS=NOCATEGORY_EFFERENT^
-Do not report category efferent coupling
+@item ^--unit-coupling-out^/COUPLING_METRICS=UNIT_OUT^
+Report unit fan-out coupling
-@item ^--category-afferent-coupling^/COUPLING_METRICS=CATEGORY_AFFERENT^
-Report category afferent coupling
+@item ^--unit-coupling-in^/COUPLING_METRICS=UNIT_IN^
+Report unit fan-in coupling
-@item ^--no-category-afferent-coupling^/COUPLING_METRICS=NOCATEGORY_AFFERENT^
-Do not report category afferent coupling
+@item ^--control-coupling-out^/COUPLING_METRICS=CONTROL_OUT^
+Report control fan-out coupling
+@item ^--control-coupling-in^/COUPLING_METRICS=CONTROL_IN^
+Report control fan-in coupling
@end table
@node Other gnatmetric Switches
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 9ee6a5f..b4b0f20 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -2110,6 +2110,14 @@ package body Sem_Attr is
case Attr_Id is
+ -- Attributes related to Ada2012 iterators (Placeholder).
+
+ when Attribute_Constant_Indexing => null;
+ when Attribute_Default_Iterator => null;
+ when Attribute_Implicit_Dereference => null;
+ when Attribute_Iterator_Element => null;
+ when Attribute_Variable_Indexing => null;
+
------------------
-- Abort_Signal --
------------------
@@ -5969,6 +5977,14 @@ package body Sem_Attr is
case Id is
+ -- Attributes related to Ada2012 iterators (Placeholder).
+
+ when Attribute_Constant_Indexing => null;
+ when Attribute_Default_Iterator => null;
+ when Attribute_Implicit_Dereference => null;
+ when Attribute_Iterator_Element => null;
+ when Attribute_Variable_Indexing => null;
+
--------------
-- Adjacent --
--------------
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 50d2954..15ae766 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -946,6 +946,50 @@ package body Sem_Ch13 is
Delay_Required := False;
+ -- Aspects related to container iterators.
+
+ when Aspect_Constant_Indexing |
+ Aspect_Default_Iterator |
+ Aspect_Iterator_Element |
+ Aspect_Variable_Indexing =>
+ null;
+
+ when Aspect_Implicit_Dereference =>
+
+ if not Is_Type (E)
+ or else not Has_Discriminants (E)
+ then
+ Error_Msg_N
+ ("Aspect must apply to a type with discriminants", N);
+ goto Continue;
+
+ else
+ declare
+ Disc : Entity_Id;
+
+ begin
+ Disc := First_Discriminant (E);
+ while Present (Disc) loop
+ if Chars (Expr) = Chars (Disc)
+ and then Ekind (Etype (Disc)) =
+ E_Anonymous_Access_Type
+ then
+ Set_Has_Implicit_Dereference (E);
+ Set_Has_Implicit_Dereference (Disc);
+ goto Continue;
+ end if;
+ Next_Discriminant (Disc);
+ end loop;
+
+ -- Error if no proper access discriminant.
+
+ Error_Msg_NE
+ ("not an access discriminant of&", Expr, E);
+ end;
+
+ goto Continue;
+ end if;
+
-- Aspects corresponding to attribute definition clauses
when Aspect_Address |
@@ -2263,6 +2307,13 @@ package body Sem_Ch13 is
end if;
end External_Tag;
+ --------------------------
+ -- Implicit_Dereference --
+ --------------------------
+ when Attribute_Implicit_Dereference =>
+ -- Legality checks already performed above.
+ null; -- TBD
+
-----------
-- Input --
-----------
@@ -5431,6 +5482,13 @@ package body Sem_Ch13 is
Aspect_Value_Size =>
T := Any_Integer;
+ when Aspect_Constant_Indexing |
+ Aspect_Default_Iterator |
+ Aspect_Iterator_Element |
+ Aspect_Implicit_Dereference |
+ Aspect_Variable_Indexing =>
+ null;
+
-- Stream attribute. Special case, the expression is just an entity
-- that does not need any resolution, so just analyze.
diff --git a/gcc/ada/snames.ads-tmpl b/gcc/ada/snames.ads-tmpl
index ba35d51..6b0e9f3 100644
--- a/gcc/ada/snames.ads-tmpl
+++ b/gcc/ada/snames.ads-tmpl
@@ -731,9 +731,11 @@ package Snames is
Name_Compiler_Version : constant Name_Id := N + $; -- GNAT
Name_Component_Size : constant Name_Id := N + $;
Name_Compose : constant Name_Id := N + $;
+ Name_Constant_Indexing : constant Name_Id := N + $; -- GNAT
Name_Constrained : constant Name_Id := N + $;
Name_Count : constant Name_Id := N + $;
Name_Default_Bit_Order : constant Name_Id := N + $; -- GNAT
+ Name_Default_Iterator : constant Name_Id := N + $; -- GNAT
Name_Definite : constant Name_Id := N + $;
Name_Delta : constant Name_Id := N + $;
Name_Denorm : constant Name_Id := N + $;
@@ -756,8 +758,10 @@ package Snames is
Name_Has_Tagged_Values : constant Name_Id := N + $; -- GNAT
Name_Identity : constant Name_Id := N + $;
Name_Img : constant Name_Id := N + $; -- GNAT
+ Name_Implicit_Dereference : constant Name_Id := N + $; -- GNAT
Name_Integer_Value : constant Name_Id := N + $; -- GNAT
Name_Invalid_Value : constant Name_Id := N + $; -- GNAT
+ Name_Iterator_Element : constant Name_Id := N + $; -- GNAT
Name_Large : constant Name_Id := N + $; -- Ada 83
Name_Last : constant Name_Id := N + $;
Name_Last_Bit : constant Name_Id := N + $;
@@ -825,6 +829,7 @@ package Snames is
Name_Val : constant Name_Id := N + $;
Name_Valid : constant Name_Id := N + $;
Name_Value_Size : constant Name_Id := N + $; -- GNAT
+ Name_Variable_Indexing : constant Name_Id := N + $; -- GNAT
Name_Version : constant Name_Id := N + $;
Name_Wchar_T_Size : constant Name_Id := N + $; -- GNAT
Name_Wide_Wide_Width : constant Name_Id := N + $; -- Ada 05
@@ -1263,9 +1268,11 @@ package Snames is
Attribute_Compiler_Version,
Attribute_Component_Size,
Attribute_Compose,
+ Attribute_Constant_Indexing,
Attribute_Constrained,
Attribute_Count,
Attribute_Default_Bit_Order,
+ Attribute_Default_Iterator,
Attribute_Definite,
Attribute_Delta,
Attribute_Denorm,
@@ -1288,8 +1295,10 @@ package Snames is
Attribute_Has_Tagged_Values,
Attribute_Identity,
Attribute_Img,
+ Attribute_Implicit_Dereference,
Attribute_Integer_Value,
Attribute_Invalid_Value,
+ Attribute_Iterator_Element,
Attribute_Large,
Attribute_Last,
Attribute_Last_Bit,
@@ -1357,6 +1366,7 @@ package Snames is
Attribute_Val,
Attribute_Valid,
Attribute_Value_Size,
+ Attribute_Variable_Indexing,
Attribute_Version,
Attribute_Wchar_T_Size,
Attribute_Wide_Wide_Width,
diff --git a/gcc/ada/vms_data.ads b/gcc/ada/vms_data.ads
index 3e23279..573cc51 100644
--- a/gcc/ada/vms_data.ads
+++ b/gcc/ada/vms_data.ads
@@ -5403,24 +5403,22 @@ package VMS_Data is
S_Metric_Coupling : aliased constant S := "/COUPLING_METRICS=" &
"ALL " &
"--coupling-all " &
- "NONE " &
- "--no-coupling-all " &
- "PACKAGE_EFFERENT " &
- "--package-efferent-coupling " &
- "NOPACKAGE_EFFERENT " &
- "--no-package-efferent-coupling " &
- "PACKAGE_AFFERENT " &
- "--package-afferent-coupling " &
- "NOPACKAGE_AFFERENT " &
- "--no-package-afferent-coupling " &
- "CATEGORY_EFFERENT " &
- "--category-efferent-coupling " &
- "NOCATEGORY_EFFERENT " &
- "--no-category-efferent-coupling " &
- "CATEGORY_AFFERENT " &
- "--category-afferent-coupling " &
- "NOCATEGORY_AFFERENT " &
- "--no-category-afferent-coupling";
+ "TAGGED_OUT " &
+ "--tagged-coupling-out " &
+ "TAGGED_IN " &
+ "--tagged-coupling-in " &
+ "HIERARCHY_OUT " &
+ "--hierarchy-coupling-out " &
+ "HIERARCHY_IN " &
+ "--hierarchy-coupling-in " &
+ "UNIT_OUT " &
+ "--unit-coupling-out " &
+ "UNIT_IN " &
+ "--unit-coupling-in " &
+ "CONTROL_OUT " &
+ "--control-coupling-out " &
+ "CONTROL_IN " &
+ "--control-coupling-in";
-- /COUPLING_METRICS=(option, option ...)
@@ -5428,16 +5426,17 @@ package VMS_Data is
--
-- option may be one of the following:
--
- -- ALL All the coupling metrics are computed
- -- NONE (D) None of coupling metrics is computed
- -- PACKAGE_EFFERENT Compute package efferent coupling
- -- NOPACKAGE_EFFERENT Do not compute package efferent coupling
- -- PACKAGE_AFFERENT Compute package afferent coupling
- -- NOPACKAGE_AFFERENT Do not compute package afferent coupling
- -- CATEGORY_EFFERENT Compute category efferent coupling
- -- NOCATEGORY_EFFERENT Do not compute category efferent coupling
- -- CATEGORY_AFFERENT Compute category afferent coupling
- -- NOCATEGORY_AFFERENT Do not compute category afferent coupling
+ -- ALL All the coupling metrics are computed
+ -- NOALL (D) None of coupling metrics is computed
+ -- TAGGED_OUT Compute tagged (class) far-out coupling
+ -- TAGGED_IN Compute tagged (class) far-in coupling
+ -- HIERARCHY_OUT Compute hieraqrchy (category) far-out coupling
+ -- HIERARCHY_IN Compute hieraqrchy (category) far-in coupling
+ -- UNIT_OUT Compute unit far-out coupling
+ -- UNIT_IN Compute unit far-in coupling
+ -- CONTROL_OUT Compute control far-out coupling
+ -- CONTROL_IN Compute control far-in coupling
+
--
-- All combinations of coupling metrics options are allowed.