diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2008-08-20 17:43:11 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2008-08-20 17:43:11 +0200 |
commit | 235f4375ba4542ab13ea4d54d731ba599076331f (patch) | |
tree | db110bbbc9ab65618b70d615e6c675b9d6248c05 /gcc | |
parent | 54e034613467cfab3e89f23f7a1043910791d35b (diff) | |
download | gcc-235f4375ba4542ab13ea4d54d731ba599076331f.zip gcc-235f4375ba4542ab13ea4d54d731ba599076331f.tar.gz gcc-235f4375ba4542ab13ea4d54d731ba599076331f.tar.bz2 |
styleg-c.ads, [...] (Missing_Overriding): new procedure to implement style check that overriding operations are...
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
From-SVN: r139316
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/ChangeLog | 33 | ||||
-rw-r--r-- | gcc/ada/sem_ch6.adb | 31 | ||||
-rw-r--r-- | gcc/ada/sem_ch8.adb | 21 | ||||
-rw-r--r-- | gcc/ada/style.ads | 7 | ||||
-rw-r--r-- | gcc/ada/styleg-c.adb | 17 | ||||
-rw-r--r-- | gcc/ada/styleg-c.ads | 6 | ||||
-rw-r--r-- | gcc/ada/stylesw.adb | 5 | ||||
-rw-r--r-- | gcc/ada/stylesw.ads | 9 |
8 files changed, 109 insertions, 20 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b01ef10..571e30e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,38 @@ 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. diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 1100c30..23de8b6 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -1724,6 +1724,12 @@ package body Sem_Ch6 is "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; @@ -4167,6 +4173,10 @@ package body Sem_Ch6 is 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 @@ -4190,16 +4200,23 @@ package body Sem_Ch6 is ("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 diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 25c21d9..5dada26 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -1822,16 +1822,19 @@ package body Sem_Ch8 is -- 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) diff --git a/gcc/ada/style.ads b/gcc/ada/style.ads index d9b8ae9..07e5702 100644 --- a/gcc/ada/style.ads +++ b/gcc/ada/style.ads @@ -6,7 +6,7 @@ -- -- -- 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- -- @@ -187,6 +187,11 @@ package Style is -- 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 diff --git a/gcc/ada/styleg-c.adb b/gcc/ada/styleg-c.adb index 003a751..5734471 100644 --- a/gcc/ada/styleg-c.adb +++ b/gcc/ada/styleg-c.adb @@ -230,6 +230,23 @@ package body Styleg.C 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 -- ----------------------------------- diff --git a/gcc/ada/styleg-c.ads b/gcc/ada/styleg-c.ads index 082f90e..b3fc1f6 100644 --- a/gcc/ada/styleg-c.ads +++ b/gcc/ada/styleg-c.ads @@ -6,7 +6,7 @@ -- -- -- 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- -- @@ -53,6 +53,10 @@ package Styleg.C is -- 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. diff --git a/gcc/ada/stylesw.adb b/gcc/ada/stylesw.adb index 34688df..764d9af 100644 --- a/gcc/ada/stylesw.adb +++ b/gcc/ada/stylesw.adb @@ -49,6 +49,7 @@ package body Stylesw is 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; @@ -123,6 +124,7 @@ package body Stylesw is 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); @@ -370,6 +372,9 @@ package body Stylesw is when 'o' => Style_Check_Order_Subprograms := True; + when 'O' => + Style_Check_Missing_Overriding := True; + when 'p' => Style_Check_Pragma_Casing := True; diff --git a/gcc/ada/stylesw.ads b/gcc/ada/stylesw.ads index 87552d3..8ed2ae2 100644 --- a/gcc/ada/stylesw.ads +++ b/gcc/ada/stylesw.ads @@ -156,8 +156,8 @@ package Stylesw is -- 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; @@ -165,6 +165,11 @@ package Stylesw is -- (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). |