2009-05-06 Robert Dewar <dewar@adacore.com>
+ * sem_warn.adb: Minor reformatting
+
+2009-05-06 Javier Miranda <miranda@adacore.com>
+
+ * sem_prag.adb (Process_Import_Or_Interface): Imported CPP types must
+ not have discriminants or components with default expressions.
+ (Analyze_Pragma): For pragma CPP_Class check that imported types
+ have no discriminants and components have no default expression.
+
+ * sem_aggr.adb (Resolve_Aggr_Expr): Add missing check on wrong use of
+ class-wide types in the expression of a record component association.
+
+2009-05-06 Sergey Rybin <rybin@adacore.com>
+
+ * vms_data.ads: Add qualifier for gnatmetric extra exit points metric
+
+ * gnat_ugn.texi: Add description for the new extra exit points metric
+ (gnatmetric section).
+
+2009-05-06 Robert Dewar <dewar@adacore.com>
+
* s-fileio.adb: Minor comment update
* sem_ch8.adb: Minor reformatting
@setfilename gnat_ugn.info
@copying
-Copyright @copyright{} 1995-2005, 2006, 2007, 2008 Free Software Foundation,
+Copyright @copyright{} 1995-2009 Free Software Foundation,
Inc.
Permission is granted to copy, distribute and/or modify this document
Do not consider @code{exit} statements as @code{goto}s when
computing Essential Complexity
+@item ^--extra-exit-points^/EXTRA_EXIT_POINTS_ON^
+Report the extra exit points for subprogram bodies
+
+@item ^--no-extra-exit-points^/EXTRA_EXIT_POINTS_OFF^
+Do not report the extra exit points for subprogram bodies
@end table
(Chars (Arg), Names (Index1))
then
Error_Msg_Name_1 := Names (Index1);
- Error_Msg_N ("\possible misspelling of%", Arg);
+ Error_Msg_N -- CODEFIX
+ ("\possible misspelling of%", Arg);
exit;
end if;
end loop;
Set_Is_CPP_Class (Def_Id);
Set_Is_Limited_Record (Def_Id);
+
+ -- Imported CPP types must not have discriminants (because C++
+ -- classes do not have discriminants).
+
+ if Has_Discriminants (Def_Id) then
+ Error_Msg_N
+ ("imported 'C'P'P type cannot have discriminants",
+ First (Discriminant_Specifications
+ (Declaration_Node (Def_Id))));
+ end if;
+
+ -- Components of imported CPP types must not have default
+ -- expressions because the constructor (if any) is in the
+ -- C++ side.
+
+ declare
+ Tdef : constant Node_Id :=
+ Type_Definition (Declaration_Node (Def_Id));
+ Clist : Node_Id;
+ Comp : Node_Id;
+
+ begin
+ if Nkind (Tdef) = N_Record_Definition then
+ Clist := Component_List (Tdef);
+
+ else
+ pragma Assert (Nkind (Tdef) = N_Derived_Type_Definition);
+ Clist := Component_List (Record_Extension_Part (Tdef));
+ end if;
+
+ if Present (Clist) then
+ Comp := First (Component_Items (Clist));
+ while Present (Comp) loop
+ if Present (Expression (Comp)) then
+ Error_Msg_N
+ ("component of imported 'C'P'P type cannot have" &
+ " default expression", Expression (Comp));
+ end if;
+
+ Next (Comp);
+ end loop;
+ end if;
+ end;
end if;
else
Error_Msg_String (1 .. Rnm'Length) :=
Name_Buffer (1 .. Name_Len);
Error_Msg_Strlen := Rnm'Length;
- Error_Msg_N
+ Error_Msg_N -- CODEFIX
("\possible misspelling of ""~""",
Get_Pragma_Arg (Arg));
exit;
for PN in First_Pragma_Name .. Last_Pragma_Name loop
if Is_Bad_Spelling_Of (Pname, PN) then
Error_Msg_Name_1 := PN;
- Error_Msg_N
+ Error_Msg_N -- CODEFIX
("\?possible misspelling of %!", Pragma_Identifier (N));
exit;
end if;
Set_Is_CPP_Class (Typ);
Set_Is_Limited_Record (Typ);
Set_Convention (Typ, Convention_CPP);
+
+ -- Imported CPP types must not have discriminants (because C++
+ -- classes do not have discriminants).
+
+ if Has_Discriminants (Typ) then
+ Error_Msg_N
+ ("imported 'C'P'P type cannot have discriminants",
+ First (Discriminant_Specifications
+ (Declaration_Node (Typ))));
+ end if;
+
+ -- Components of imported CPP types must not have default
+ -- expressions because the constructor (if any) is in the
+ -- C++ side.
+
+ if Is_Incomplete_Or_Private_Type (Typ)
+ and then No (Underlying_Type (Typ))
+ then
+ -- It should be an error to apply pragma CPP to a private
+ -- type if the underlying type is not visible (as it is
+ -- for any representation item). For now, for backward
+ -- compatibility we do nothing but we cannot check components
+ -- because they are not available at this stage. All this code
+ -- will be removed when we cleanup this obsolete GNAT pragma???
+
+ null;
+
+ else
+ declare
+ Tdef : constant Node_Id :=
+ Type_Definition (Declaration_Node (Typ));
+ Clist : Node_Id;
+ Comp : Node_Id;
+
+ begin
+ if Nkind (Tdef) = N_Record_Definition then
+ Clist := Component_List (Tdef);
+ else
+ pragma Assert (Nkind (Tdef) = N_Derived_Type_Definition);
+ Clist := Component_List (Record_Extension_Part (Tdef));
+ end if;
+
+ if Present (Clist) then
+ Comp := First (Component_Items (Clist));
+ while Present (Comp) loop
+ if Present (Expression (Comp)) then
+ Error_Msg_N
+ ("component of imported 'C'P'P type cannot have" &
+ " default expression", Expression (Comp));
+ end if;
+
+ Next (Comp);
+ end loop;
+ end if;
+ end;
+ end if;
end CPP_Class;
---------------------
"AVERAGE_COMPLEXITY_ON " &
"--complexity-average " &
"AVERAGE_COMPLEXITY_OFF " &
- "--no-complexity-average";
+ "--no-complexity-average " &
+ "EXTRA_EXIT_POINTS_ON " &
+ "--extra-exit-points " &
+ "EXTRA_EXIT_POINTS_OFF " &
+ "--no-extra-exit-points";
-- /COMPLEXITY_METRICS=(option, option ...)
-- Specifies the complexity metrics to be computed (if at least one
-- executable bodies
-- AVERAGE_COMPLEXITY_OFF Do not compute the average complexity for
-- executable bodies
+ -- EXTRA_EXIT_POINTS_ON Compute extra exit points metric
+ -- EXTRA_EXIT_POINTS_OFF Do not compute extra exit points metric
--
-- All combinations of line metrics options are allowed.