[COMMITTED,02/51] ada: Avoid giving multiple errors on ghost argument

Message ID 20260602084541.3829876-2-poulhies@adacore.com
State Committed
Commit 5200b096cedd09a51fecffebc19ae699d2d5a160
Headers
Series [COMMITTED,01/51] ada: Rename Private_Component function |

Commit Message

Marc Poulhiès June 2, 2026, 8:44 a.m. UTC
  From: Viljar Indus <indus@adacore.com>

Avoid marking multiple errors on the same line if the ghost
expression is both non-static and also would evaluate to False.

gcc/ada/ChangeLog:

	* sem_prag.adb (Analyze_Abstract_State): make error checks
	exclusive.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_prag.adb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index e3f1ed0e085..a22ae61cd55 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -13595,9 +13595,7 @@  package body Sem_Prag is
                                           & "in pragma % "
                                           & "must be static"),
                                        Expr);
-                                 end if;
-
-                                 if Is_False (Expr_Value (Expr)) then
+                                 elsif Is_False (Expr_Value (Expr)) then
                                     Is_Ghost := False;
 
                                     --  "Ghostness" cannot be turned off once