* styleg-c.ads, styleg-c.adb (Missing_Overriding): new procedure to
implement style check that overriding operations are explicitly marked
at such.
* style.ads (Missing_Overriding): new procedure that provides interface
to previous one.
* stylesw.ads, stylesw.adb: New style switch -gnatyO, to enable check
that the declaration or body of overriding operations carries an
explicit overriding indicator.
* sem_ch8.adb
(Analyze_Subprogram_Renaming): if operation is overriding, check whether
explicit indicator should be present.
* sem_ch6.adb (Verify_Overriding_Indicator,
Check_Overriding_Indicator): If operation is overriding, check whether
declaration and/or body of subprogram should be present
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139316
138bc75d-0d04-0410-961f-
82ee72b054a4
2008-08-20 Vincent Celier <celier@adacore.com>
+ * make.adb (Gnatmake_Switch_Found): New Boolean global variable
+ (Switch_May_Be_Passed_To_The_Compiler): New Boolean global variable
+ (Add_Switches): New Boolean parameter Unknown_Switches_To_The_Compiler
+ defaulted to True. Fail when Unknown_Switches_To_The_Compiler is False
+ and a switch is not recognized by gnatmake.
+ (Gnatmake): Implement new scheme for gnatmake switches and global
+ compilation switches.
+ (Switches_Of): Try successively Switches (<file name>),
+ Switches ("Ada"), Switches (others) and Default_Switches ("Ada").
+
+2008-08-20 Ed Schonberg <schonberg@adacore.com>
+
+ * styleg-c.ads, styleg-c.adb (Missing_Overriding): new procedure to
+ implement style check that overriding operations are explicitly marked
+ at such.
+
+ * style.ads (Missing_Overriding): new procedure that provides interface
+ to previous one.
+
+ * stylesw.ads, stylesw.adb: New style switch -gnatyO, to enable check
+ that the declaration or body of overriding operations carries an
+ explicit overriding indicator.
+
+ * sem_ch8.adb
+ (Analyze_Subprogram_Renaming): if operation is overriding, check whether
+ explicit indicator should be present.
+
+ * sem_ch6.adb (Verify_Overriding_Indicator,
+ Check_Overriding_Indicator): If operation is overriding, check whether
+ declaration and/or body of subprogram should be present
+
+2008-08-20 Vincent Celier <celier@adacore.com>
+
* prj-nmsc.adb (Check_Naming_Schemes): Accept source file names for
gprbuild when casing is MixedCase, whatever the casing of the letters
in the file name.
"if subprogram is primitive",
Body_Spec);
end if;
+
+ elsif Style_Check
+ and then Is_Overriding_Operation (Spec_Id)
+ then
+ pragma Assert (Unit_Declaration_Node (Body_Id) = N);
+ Style.Missing_Overriding (N, Body_Id);
end if;
end Verify_Overriding_Indicator;
Set_Is_Overriding_Operation (Subp);
end if;
+ if Style_Check and then not Must_Override (Spec) then
+ Style.Missing_Overriding (Decl, Subp);
+ end if;
+
-- If Subp is an operator, it may override a predefined operation.
-- In that case overridden_subp is empty because of our implicit
-- representation for predefined operators. We have to check whether the
("subprogram & overrides predefined operator ", Spec, Subp);
end if;
- elsif Is_Overriding_Operation (Subp) then
- null;
-
elsif Must_Override (Spec) then
- if not Operator_Matches_Spec (Subp, Subp) then
- Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
-
- else
+ if Is_Overriding_Operation (Subp) then
Set_Is_Overriding_Operation (Subp);
+
+ elsif not Operator_Matches_Spec (Subp, Subp) then
+ Error_Msg_NE ("subprogram & is not overriding", Spec, Subp);
end if;
+
+ elsif not Error_Posted (Subp)
+ and then Style_Check
+ and then Operator_Matches_Spec (Subp, Subp)
+ and then
+ not Is_Predefined_File_Name
+ (Unit_File_Name (Get_Source_Unit (Subp)))
+ then
+ Set_Is_Overriding_Operation (Subp);
+ Style.Missing_Overriding (Decl, Subp);
end if;
elsif Must_Override (Spec) then
-- Ada 2005: check overriding indicator
- if Must_Override (Specification (N))
- and then not Is_Overriding_Operation (Rename_Spec)
- then
- Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec);
+ if Is_Overriding_Operation (Rename_Spec) then
+ if Must_Not_Override (Specification (N)) then
+ Error_Msg_NE
+ ("subprogram& overrides inherited operation",
+ N, Rename_Spec);
+ elsif
+ Style_Check and then not Must_Override (Specification (N))
+ then
+ Style.Missing_Overriding (N, Rename_Spec);
+ end if;
- elsif Must_Not_Override (Specification (N))
- and then Is_Overriding_Operation (Rename_Spec)
- then
- Error_Msg_NE
- ("subprogram& overrides inherited operation", N, Rename_Spec);
+ elsif Must_Override (Specification (N)) then
+ Error_Msg_NE ("subprogram& is not overriding", N, Rename_Spec);
end if;
-- Normal subprogram renaming (not renaming as body)
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2008, 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- --
-- Called after scanning a conditional expression that has at least one
-- level of parentheses around the entire expression.
+ procedure Missing_Overriding (N : Node_Id; E : Entity_Id)
+ renames Style_C_Inst.Missing_Overriding;
+ -- Called where N is the declaration or body of an overriding operation of
+ -- a tagged type, and does not have an overriding_indicator.
+
function Mode_In_Check return Boolean
renames Style_Inst.Mode_In_Check;
-- Determines whether style checking is active and the Mode_In_Check is
end if;
end Check_Identifier;
+ ------------------------
+ -- Missing_Overriding --
+ ------------------------
+
+ procedure Missing_Overriding (N : Node_Id; E : Entity_Id) is
+ begin
+ if Style_Check_Missing_Overriding and then Comes_From_Source (N) then
+ if Nkind (N) = N_Subprogram_Body then
+ Error_Msg_N
+ ("(style) missing OVERRIDING indicator in body of&", E);
+ else
+ Error_Msg_N
+ ("(style) missing OVERRIDING indicator in declaration of&", E);
+ end if;
+ end if;
+ end Missing_Overriding;
+
-----------------------------------
-- Subprogram_Not_In_Alpha_Order --
-----------------------------------
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2008, 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- --
-- spelling is to be checked against the Chars spelling in identifier node
-- Def (which may be either an N_Identifier, or N_Defining_Identifier node)
+ procedure Missing_Overriding (N : Node_Id; E : Entity_Id);
+ -- Called where N is the declaration or body of an overriding operation,
+ -- and the node does not have an overriding_indicator.
+
procedure Subprogram_Not_In_Alpha_Order (Name : Node_Id);
-- Called if Name is the name of a subprogram body in a package body
-- that is not in alphabetical order.
Style_Check_Layout := False;
Style_Check_Max_Line_Length := False;
Style_Check_Max_Nesting_Level := False;
+ Style_Check_Missing_Overriding := False;
Style_Check_Mode_In := False;
Style_Check_Order_Subprograms := False;
Style_Check_Pragma_Casing := False;
Add ('l', Style_Check_Layout);
Add ('n', Style_Check_Standard);
Add ('o', Style_Check_Order_Subprograms);
+ Add ('O', Style_Check_Missing_Overriding);
Add ('p', Style_Check_Pragma_Casing);
Add ('r', Style_Check_References);
Add ('s', Style_Check_Specs);
when 'o' =>
Style_Check_Order_Subprograms := True;
+ when 'O' =>
+ Style_Check_Missing_Overriding := True;
+
when 'p' =>
Style_Check_Pragma_Casing := True;
-- with the IF keyword.
Style_Check_Max_Line_Length : Boolean := False;
- -- This can be set True by using the -gnatg or -gnatym/M switches. If
- -- it is True, it activates checking for a maximum line length of
+ -- This can be set True by using the -gnatg or -gnatym/M switches. If it is
+ -- True, it activates checking for a maximum line length of
-- Style_Max_Line_Length characters.
Style_Check_Max_Nesting_Level : Boolean := False;
-- (a value of zero resets it to False). If True, it activates checking
-- the maximum nesting level against Style_Max_Nesting_Level.
+ Style_Check_Missing_Overriding : Boolean := False;
+ -- This can be set True by using the -gnatyO switch. If it is True, then
+ -- "[not] overriding" is required in subprogram declarations and bodies
+ -- where appropriate.
+
Style_Check_Mode_In : Boolean := False;
-- This can be set True by using -gnatyI. If True, it activates checking
-- that mode IN is not used on its own (since it is the default).