diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-04-02 03:39:15 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-15 04:04:41 -0400 |
commit | c7df4e55c944986c5fdbe7da341cf6f5e4ef81c6 (patch) | |
tree | 031af47ccd75525d457fb5865d993957798ffdff | |
parent | 65e088926639654e51b8e85be481d586505b56b4 (diff) | |
download | gcc-c7df4e55c944986c5fdbe7da341cf6f5e4ef81c6.zip gcc-c7df4e55c944986c5fdbe7da341cf6f5e4ef81c6.tar.gz gcc-c7df4e55c944986c5fdbe7da341cf6f5e4ef81c6.tar.bz2 |
[Ada] Improve error message on premature usage of subtypes
2020-06-15 Arnaud Charlet <charlet@adacore.com>
gcc/ada/
* sem_ch8.adb (Premature_Usage): Add support for subtype
references and replace set of if-then-else by a case statement.
-rw-r--r-- | gcc/ada/sem_ch8.adb | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 8a63831..b9e5990 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -8948,43 +8948,43 @@ package body Sem_Ch8 is end if; end if; - if Kind = N_Component_Declaration then - Error_Msg_N - ("component&! cannot be used before end of record declaration", N); + case Kind is + when N_Component_Declaration => + Error_Msg_N + ("component&! cannot be used before end of record declaration", + N); - elsif Kind = N_Parameter_Specification then - Error_Msg_N - ("formal parameter&! cannot be used before end of specification", - N); + when N_Parameter_Specification => + Error_Msg_N + ("formal parameter&! cannot be used before end of specification", + N); - elsif Kind = N_Discriminant_Specification then - Error_Msg_N - ("discriminant&! cannot be used before end of discriminant part", - N); + when N_Discriminant_Specification => + Error_Msg_N + ("discriminant&! cannot be used before end of discriminant part", + N); - elsif Kind = N_Procedure_Specification - or else Kind = N_Function_Specification - then - Error_Msg_N - ("subprogram&! cannot be used before end of its declaration", - N); + when N_Procedure_Specification | N_Function_Specification => + Error_Msg_N + ("subprogram&! cannot be used before end of its declaration", + N); - elsif Kind = N_Full_Type_Declaration then - Error_Msg_N - ("type& cannot be used before end of its declaration!", N); + when N_Full_Type_Declaration | N_Subtype_Declaration => + Error_Msg_N + ("type& cannot be used before end of its declaration!", N); - else - Error_Msg_N - ("object& cannot be used before end of its declaration!", N); + when others => + Error_Msg_N + ("object& cannot be used before end of its declaration!", N); - -- If the premature reference appears as the expression in its own - -- declaration, rewrite it to prevent compiler loops in subsequent - -- uses of this mangled declaration in address clauses. + -- If the premature reference appears as the expression in its own + -- declaration, rewrite it to prevent compiler loops in subsequent + -- uses of this mangled declaration in address clauses. - if Nkind (Parent (N)) = N_Object_Declaration then - Set_Entity (N, Any_Id); - end if; - end if; + if Nkind (Parent (N)) = N_Object_Declaration then + Set_Entity (N, Any_Id); + end if; + end case; end Premature_Usage; ------------------------ |