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/ada/sem_ch6.adb | |
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/ada/sem_ch6.adb')
-rw-r--r-- | gcc/ada/sem_ch6.adb | 31 |
1 files changed, 24 insertions, 7 deletions
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 |