[COMMITTED] ada: Improve check of attribute reference

Message ID 20230515094316.1408094-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Improve check of attribute reference |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 15, 2023, 9:43 a.m. UTC
  From: Ronan Desplanques <desplanques@adacore.com>

Before this patch, the front end failed to catch many illegal uses
of access attributes of task types.

This patch makes referring to the access attributes of a task type
raise an error, except in the current instance case defined in
clause 8.6 of the reference manual.

gcc/ada/

	* sem_attr.adb: sem_attr.adb (Analyze_Access_Attribute): Tighten
	validity check for task types.

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

---
 gcc/ada/sem_attr.adb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 9de9884069e..ac0c4004930 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1068,9 +1068,11 @@  package body Sem_Attr is
                   Analyze (N);
                   return;
 
-               --  OK if a task type, this test needs sharpening up ???
+               --  OK if current task.
 
-               elsif Is_Task_Type (Typ) then
+               elsif Is_Task_Type (Typ)
+                 and then In_Open_Scopes (Typ)
+               then
                   null;
 
                --  OK if self-reference in an aggregate in Ada 2005, and