[Ada] Ambiguities with class-wide operations on synchronized types

Message ID 20120723082934.GA18256@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet July 23, 2012, 8:29 a.m.
This patch fixes the code that implements AI05-0090, a check for ambiguities
in calls to primitive operations of tagged synchronized types.

No small example available.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-07-23  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch4.adb (Analyze_Selected_Component): When checking for
	potential ambiguities with class-wide operations on synchronized
	types, attach the copied node properly to the tree, to prevent
	errors during expansion.


Index: sem_ch4.adb
--- sem_ch4.adb	(revision 189774)
+++ sem_ch4.adb	(working copy)
@@ -4222,13 +4222,21 @@ 
                --  Duplicate the call. This is required to avoid problems with
                --  the tree transformations performed by Try_Object_Operation.
+               --  Set properly the parent of the copied call, because it is
+               --  about to be reanalyzed.
-              and then
-                Try_Object_Operation
-                  (N            => Sinfo.Name (New_Copy_Tree (Parent (N))),
-                   CW_Test_Only => True)
-               return;
+               declare
+                  Par : constant Node_Id := New_Copy_Tree (Parent (N));
+               begin
+                  Set_Parent (Par, Parent (Parent (N)));
+                  if Try_Object_Operation
+                    (Sinfo.Name (Par), CW_Test_Only => True)
+                  then
+                     return;
+                  end if;
+               end;
             end if;
          end if;