This patch avoids flagging violations of the No_Obsolescent_Features restriction in generic instances. Such diagnostics are redundant since the violation will be flagged in the template anyway.
The following is a test of this patch gnat.adc contains pragma Restrictions (No_Obsolescent_Features); 1. generic 2. package obsolescent_generic is 3. procedure Initialize; 4. end obsolescent_generic; 1. package body obsolescent_generic is 2. procedure Initialize is 3. A : Integer; 4. B : Integer; 5. for A use at B'address; | >>> violation of restriction "no_obsolescent_features" at gnat.adc:1 6. begin 7. null; 8. end Initialize; 9. end obsolescent_generic; Compiling: obsolescent_instance1.ads 1. package obsolescent_instance1 is 2. procedure Call; 3. end obsolescent_instance1; Compiling: obsolescent_instance1.adb 1. with obsolescent_generic; 2. package body obsolescent_instance1 is 3. package Instance1 is new obsolescent_generic; 4. procedure Call is 5. begin 6. Instance1.Initialize; 7. end Call; 8. end obsolescent_instance1; Prior to this patch, the compilation of the instance resulted in a diagnostic on line 3 of the body (the instantiation). Tested on x86_64-pc-linux-gnu, committed on trunk 2012-02-17 Robert Dewar <de...@adacore.com> * restrict.adb (Check_Restriction): Add special handling for No_Obsolescent_Features.
Index: restrict.adb =================================================================== --- restrict.adb (revision 184330) +++ restrict.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, 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- -- @@ -532,6 +532,15 @@ elsif not Restrictions.Set (R) then null; + -- Don't complain about No_Obsolescent_Features in an instance, since we + -- will complain on the template, which is much better. Are there other + -- cases like this ??? Do we need a more general mechanism ??? + + elsif R = No_Obsolescent_Features + and then Instantiation_Location (Sloc (N)) /= No_Location + then + null; + -- Here if restriction set, check for violation (either this is a -- Boolean restriction, or a parameter restriction with a value of -- zero and an unknown count, or a parameter restriction with a