aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2021-03-03 20:15:56 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-16 04:43:05 -0400
commit1a9ff8d39c1f5a63755f2a8bb0a982c7af4ee817 (patch)
treea5a5925693632156078ad4efaec6b99830b9b561 /gcc
parent3feba0a578c364e6ca44ad5f954a30dc55e98065 (diff)
downloadgcc-1a9ff8d39c1f5a63755f2a8bb0a982c7af4ee817.zip
gcc-1a9ff8d39c1f5a63755f2a8bb0a982c7af4ee817.tar.gz
gcc-1a9ff8d39c1f5a63755f2a8bb0a982c7af4ee817.tar.bz2
[Ada] Ignore volatile restrictions in preanalysis
gcc/ada/ * sem_util.adb (Is_OK_Volatile_Context): All references to volatile objects are legal in preanalysis. (Within_Volatile_Function): Previously it was wrongly called on Empty entities; now it is only called on E_Return_Statement, which allow the body to be greatly simplified.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_util.adb32
1 files changed, 14 insertions, 18 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 68e9a08..6376b4e 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -18871,27 +18871,14 @@ package body Sem_Util is
------------------------------
function Within_Volatile_Function (Id : Entity_Id) return Boolean is
- Func_Id : Entity_Id;
+ pragma Assert (Ekind (Id) = E_Return_Statement);
- begin
- -- Traverse the scope stack looking for a [generic] function
-
- Func_Id := Id;
- while Present (Func_Id) and then Func_Id /= Standard_Standard loop
- if Ekind (Func_Id) in E_Function | E_Generic_Function then
-
- -- ??? This routine could just use Return_Applies_To, but it
- -- is currently wrongly called by unanalyzed return statements
- -- coming from expression functions.
- pragma Assert (Func_Id = Return_Applies_To (Id));
+ Func_Id : constant Entity_Id := Return_Applies_To (Id);
- return Is_Volatile_Function (Func_Id);
- end if;
-
- Func_Id := Scope (Func_Id);
- end loop;
+ begin
+ pragma Assert (Ekind (Func_Id) in E_Function | E_Generic_Function);
- return False;
+ return Is_Volatile_Function (Func_Id);
end Within_Volatile_Function;
-- Local variables
@@ -18901,6 +18888,15 @@ package body Sem_Util is
-- Start of processing for Is_OK_Volatile_Context
begin
+ -- Ignore context restriction when doing preanalysis, e.g. on a copy of
+ -- an expression function, because this copy is not fully decorated and
+ -- it is not possible to reliably decide the legality of the context.
+ -- Any violations will be reported anyway when doing the full analysis.
+
+ if not Full_Analysis then
+ return True;
+ end if;
+
-- For actual parameters within explicit parameter associations switch
-- the context to the corresponding subprogram call.