From 749e01a5f310f2c4327f030d425aa6e23afbbbd5 Mon Sep 17 00:00:00 2001 From: Gary Dismukes Date: Fri, 8 Oct 2021 17:57:37 -0400 Subject: [Ada] Warning on nonmatching subtypes in fully conforming subprogram specs and bodies gcc/ada/ * sem_ch6.adb: Add with and use of Warnsw. (Check_Conformance): Report a warning when subtypes or designated subtypes of formal parameters or result subtypes denote different declarations between the spec and body of the (Subprogram_Subtypes_Have_Same_Declaration): New function nested within Check_Conformance that determines whether two subtype entities referenced in a subprogram come from the same declaration. Returns True immediately if the subprogram is in a generic instantiation, or the subprogram is marked Is_Internal or is declared in an internal (GNAT library) unit, or GNAT_Mode is enabled, otherwise compares the nonlimited views of the entities (or their designated subtypes' nonlimited views in the anonymous access cases). (Nonlimited_View_Of_Subtype): New function nested within function Subprogram_Subtypes_Have_Same_Declaration that returns Non_Limited_View of a type or subtype that is an incomplete or class-wide type that comes from a limited of a package (From_Limited_With is True for the entity), or returns Full_View when the nonlimited view is an incomplete type. Otherwise returns the entity passed in. * warnsw.ads (Warn_On_Pedantic_Checks): New warning flag. (type Warning_Record): New component Warn_On_Pedantic_Checks. * warnsw.adb (All_Warnings): Set Warn_On_Pedantic_Checks from parameter Setting. (Restore_Warnings): Restore the value of the Warn_On_Pedantic_Checks flag. (Save_Warnings): Save the value of the Warn_On_Pedantic_Checks flag. (Set_Underscore_Warning_Switch): Add settings of the Warn_On_Pedantic flag according to the switch ("-gnatw_p" vs. "-gnatw_P"). * doc/gnat_ugn/building_executable_programs_with_gnat.rst: Add documentation of new switches -gnatw_p and -gnatw_P (warnings for pedantic checks). * gnat_ugn.texi: Regenerate. * usage.adb: Add Warn_On_Pedantic_Checks. --- gcc/ada/usage.adb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/ada/usage.adb') diff --git a/gcc/ada/usage.adb b/gcc/ada/usage.adb index bca3527..207303b 100644 --- a/gcc/ada/usage.adb +++ b/gcc/ada/usage.adb @@ -557,6 +557,8 @@ begin "order"); Write_Line (" .P* turn off warnings for suspicious parameter " & "order"); + Write_Line (" _p turn on warnings for pedantic checks"); + Write_Line (" _P turn off warnings for pedantic checks"); Write_Line (" q*+ turn on warnings for questionable " & "missing parenthesis"); Write_Line (" Q turn off warnings for questionable " & -- cgit v1.1