]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Spurious error on Lock_Free protected type with discriminants
authorJustin Squirek <squirek@adacore.com>
Mon, 5 Dec 2022 22:05:44 +0000 (22:05 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 5 Jan 2023 14:29:59 +0000 (15:29 +0100)
This patch corrects an issue in the compiler whereby unprefixed discriminants
appearing in protected subprograms were unable to be properly resolved -
leading to spurious resolution errors.

gcc/ada/

* sem_ch8.adb (Set_Entity_Or_Discriminal): Verify we are actually
resetting the entity field of a non-prefixed discriminant
reference.

gcc/ada/sem_ch8.adb

index 841076bbd01d52ea350a66502c41201f311fdd56..fe89e1127ee0fa471150fe7e12722321474fb394 100644 (file)
@@ -4891,14 +4891,16 @@ package body Sem_Ch8 is
          then
             null;
 
-         --  Don't replace the discriminant in strict preanalysis mode since
-         --  it can lead to errors during full analysis when the discriminant
-         --  gets referenced later.
+         --  Don't replace a non-qualified discriminant in strict preanalysis
+         --  mode since it can lead to errors during full analysis when the
+         --  discriminant gets referenced later.
 
          --  This can occur in situations where a protected type contains
-         --  an expression function which references a discriminant.
+         --  an expression function which references a non-prefixed
+         --  discriminant.
 
-         elsif Preanalysis_Active
+         elsif No (P)
+           and then Preanalysis_Active
            and then Inside_Preanalysis_Without_Freezing = 0
          then
             null;