From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id BE5973858D1E for ; Mon, 20 May 2024 07:49:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE5973858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BE5973858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::234 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716191358; cv=none; b=BN6hWej9NPDP7+Ltzmx9X9Kyo3T+mdG9k40fvwwLcUoKeGkoNx+436Ay0nmKwsn5sFNwMAR661nzwHbm3z3sfTVoJ+zapiiRXG0798+hbRJg5tTOdhc3rv47A77aXipg9AeHplOnCzUIf8bG5lhcZyEYPdLuu9DM1eYO1a/Z0l4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716191358; c=relaxed/simple; bh=fjG00puu3M2YEhPJ4Yw7UBW12+I7R/9WbshWjuqBP8s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kEuS9e1gyQ7qHLE7Vcdzd/JG+JX02omSzB7pgGFjWfpo29inqOYjiwuFyq29QPQMwMJ9p978FfT234fqRHLkF0wzfF0r/Cdf3O4QF6mPfWnIY55wmzGqwoJh1lvQ/Iqi2/1xFE+I4al98dLsdsU05TfubSHj1OYc/7unlBt63sk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2e27277d2c1so50943871fa.2 for ; Mon, 20 May 2024 00:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1716191354; x=1716796154; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K4PxvgpTuETKawRHNdLSUj3S2oQzVsAMCZAqw5t7dcA=; b=HqQBGOEf8lrsy8h1ILdjRAFB8q+H9CI6M2hQUL1hJ3PMJLuW47kLMrbQT6bzgo0f5r CiFNzCqFn3pk3STsL5dYsrFqzwhft7SePYQVw2vs8TpliifgdPwMXBl4U3FnWwJVz64G hqjXY4W+g022UEPdBNx3gMWA+h+M4sD89UkiywDD/82XtK8HAXz6Xwmu4iVC1Taly+3e +v0MV91ssc/EJRNiZYrtffhyjjAN98pN/cXtV+HbA+EO9l0aJwynXc7CsqTThj1ekzae U7Q/Z0iexMar37yylWqeKKCx87Vta8KG86ugrm4KTCGDhCRBrbCjnSpdy6boFJ/5Ncn5 UZIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716191354; x=1716796154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K4PxvgpTuETKawRHNdLSUj3S2oQzVsAMCZAqw5t7dcA=; b=ErmbgwrB/Klq4PW2C8KlpYRUJVG5xdUTeqAyihz38rpwCGYMZuBjQ17/xyf8AudDag EzFcy7uxEoh2fdBXpo7OuYBu4cXYq8W4o/AVRgWT3v+g3p9R7e4+INaEIGb1LHXePxiX ctk7pmxgXNSjYN0PlNZDH/Xa33p65GXWzbd2kBpqRvMNsR37TupWW5ItYWMpLOMjHtKx CQCiaEx/OA8VFlK0qHP0hYhk8yyO2zvVYYnLJ8Co2ijyLQ5zp9jU8DdpJZ96SQRDYSQ7 7CfywxRpUJ371px7pr4Ps+Jue0wBk62jQiRtx14gFrXWYzvHfbUE/bRkRM31AEFP6vn/ CiCg== X-Gm-Message-State: AOJu0Yz/1iJNsadJqQMcTxxnLiZ0AZB+j2v57AkPJzJLlCrLeDuc7d9w BdfE3V+R3s6R8sjC+kI2eadr2qvu6MzTacwMaUBmfrRn4OSxm3C7F4+WRZlUpanepdAs0Kqrt6M = X-Google-Smtp-Source: AGHT+IGOPo2h+A0Ct2Sv0yk1dq42P9vuwuoVoEOlQOVhTr1s0c1Xyd0Q3ll8kRV8tzAMr169Sgvd2w== X-Received: by 2002:a2e:8054:0:b0:2e7:19ba:b84e with SMTP id 38308e7fff4ca-2e719bab928mr30146101fa.20.1716191354146; Mon, 20 May 2024 00:49:14 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:de37:8b1c:1f33:2610]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41f88111033sm446892175e9.34.2024.05.20.00.49.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 00:49:13 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Jose Ruiz Subject: [COMMITTED 03/30] ada: Implement representation aspect Max_Entry_Queue_Length Date: Mon, 20 May 2024 09:48:29 +0200 Message-ID: <20240520074858.222435-3-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240520074858.222435-1-poulhies@adacore.com> References: <20240520074858.222435-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Jose Ruiz Enforce Max_Entry_Queue_Length (and its synonym Max_Entry_Queue_Depth) when applied to individual protected entries. gcc/ada/ * exp_ch9.adb (Expand_N_Protected_Type_Declaration): Clarify comments. * sem_prag.adb (Analyze_Pragma): Check for duplicates Max_Entry_Queue_Length, Max_Entry_Queue_Depth and Max_Queue_Length for the same protected entry. * sem_util.adb (Get_Max_Queue_Length): Take into account all three representation aspects that can be used to set this restriction. (Has_Max_Queue_Length): Likewise. * doc/gnat_rm/implementation_defined_pragmas.rst: (pragma Max_Queue_Length): Fix pragma in example. * gnat_rm.texi: Regenerate. Tested on x86_64-pc-linux-gnu, committed on master. --- .../implementation_defined_pragmas.rst | 2 +- gcc/ada/exp_ch9.adb | 6 ++-- gcc/ada/gnat_rm.texi | 2 +- gcc/ada/sem_prag.adb | 11 +++++++ gcc/ada/sem_util.adb | 33 ++++++++++++++----- 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst index bcbd85984dc..0661670e047 100644 --- a/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst +++ b/gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst @@ -3771,7 +3771,7 @@ Pragma Max_Queue_Length Syntax:: - pragma Max_Entry_Queue (static_integer_EXPRESSION); + pragma Max_Queue_Length (static_integer_EXPRESSION); This pragma is used to specify the maximum callers per entry queue for diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb index 051b1df060f..4de253ab6e8 100644 --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -9405,7 +9405,8 @@ package body Exp_Ch9 is end loop; -- Create the declaration of an array object which contains the values - -- of aspect/pragma Max_Queue_Length for all entries of the protected + -- of any aspect/pragma Max_Queue_Length, Max_Entry_Queue_Length or + -- Max_EntryQueue_Depth for all entries of the protected -- type. This object is later passed to the appropriate protected object -- initialization routine. @@ -9422,7 +9423,8 @@ package body Exp_Ch9 is Need_Array : Boolean := False; begin - -- First check if there is any Max_Queue_Length pragma + -- First check if there is any Max_Queue_Length, + -- Max_Entry_Queue_Length or Max_Entry_Queue_Depth pragma. Item := First_Entity (Prot_Typ); while Present (Item) loop diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 40516121b7a..4dbbb036a25 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -5312,7 +5312,7 @@ no effect in GNAT, other than being syntax checked. Syntax: @example -pragma Max_Entry_Queue (static_integer_EXPRESSION); +pragma Max_Queue_Length (static_integer_EXPRESSION); @end example This pragma is used to specify the maximum callers per entry queue for diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index f27e40edcbb..0e2ce9de4b5 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -20388,6 +20388,17 @@ package body Sem_Prag is ("pragma % must apply to a protected entry declaration"); end if; + -- Check for duplicates + + if Has_Rep_Pragma (Entry_Id, Name_Max_Entry_Queue_Length) + or else + Has_Rep_Pragma (Entry_Id, Name_Max_Entry_Queue_Depth) + or else + Has_Rep_Pragma (Entry_Id, Name_Max_Queue_Length) + then + Error_Msg_N ("??duplicate Max_Entry_Queue_Length pragma", N); + end if; + -- Mark the pragma as Ghost if the related subprogram is also -- Ghost. This also ensures that any expansion performed further -- below will produce Ghost nodes. diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index d512d462b44..09358278210 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -10714,26 +10714,38 @@ package body Sem_Util is function Get_Max_Queue_Length (Id : Entity_Id) return Uint is pragma Assert (Is_Entry (Id)); - Prag : constant Entity_Id := Get_Pragma (Id, Pragma_Max_Queue_Length); - Max : Uint; + PMQL : constant Entity_Id := Get_Pragma (Id, Pragma_Max_Queue_Length); + PMEQD : constant Entity_Id := + Get_Pragma (Id, Pragma_Max_Entry_Queue_Depth); + PMEQL : constant Entity_Id := + Get_Pragma (Id, Pragma_Max_Entry_Queue_Length); + Max : Uint; begin -- A value of 0 or -1 represents no maximum specified, and entries and -- entry families with no Max_Queue_Length aspect or pragma default to -- it. - if No (Prag) then - return Uint_0; + -- We have already checked that there is at most one of these pragmas + + if Present (PMQL) then + Max := Expr_Value + (Expression (First (Pragma_Argument_Associations (PMQL)))); + elsif Present (PMEQD) then + Max := Expr_Value + (Expression (First (Pragma_Argument_Associations (PMEQD)))); + elsif Present (PMEQL) then + Max := Expr_Value + (Expression (First (Pragma_Argument_Associations (PMEQL)))); + else + Max := Uint_0; end if; - Max := Expr_Value - (Expression (First (Pragma_Argument_Associations (Prag)))); - -- Since -1 and 0 are equivalent, return 0 for instances of -1 for -- uniformity. if Max = -1 then - return Uint_0; + Max := Uint_0; end if; return Max; @@ -12217,7 +12229,10 @@ package body Sem_Util is begin return Ekind (Id) = E_Entry - and then Present (Get_Pragma (Id, Pragma_Max_Queue_Length)); + and then + (Present (Get_Pragma (Id, Pragma_Max_Queue_Length)) or else + Present (Get_Pragma (Id, Pragma_Max_Entry_Queue_Depth)) or else + Present (Get_Pragma (Id, Pragma_Max_Entry_Queue_Length))); end Has_Max_Queue_Length; --------------------------------- -- 2.43.2