diff mbox

[Ada] Don't ally Body_With_No_Spec style check to parameterized expressions

Message ID 20101026105200.GA21322@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 26, 2010, 10:52 a.m. UTC
The point of parameterized expressions is to allow the spec to serve as body,
but the style check would defeat that.

The following should compile and execute quietly, when compiled with
gcc -c -gnatys:

pragma Ada_2012;
procedure Nospecreq is

   type Uns is mod 2**Integer'Size;
   type U64 is mod 2**64;

   function "*" (Left : Uns; Right : Uns) return U64 is
     (U64 (Left) * U64 (Right));

   X : constant Uns := 123_456_789;
   Y : constant U64 := 123_456_789 ** 2;

begin
   pragma Assert (X * X = Y);
end Nospecreq;

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-26  Geert Bosch  <bosch@adacore.com>

	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Parameterized
	expressions don't need a spec, even when style checks require
	subprograms to have one.
diff mbox

Patch

Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 165935)
+++ sem_ch6.adb	(working copy)
@@ -2330,6 +2330,8 @@  package body Sem_Ch6 is
            and then Comes_From_Source (Body_Id)
            and then not Suppress_Style_Checks (Body_Id)
            and then not In_Instance
+           and then Nkind (Original_Node (Body_Id))
+                            /= N_Parameterized_Expression
          then
             Style.Body_With_No_Spec (N);
          end if;