Index: par-ch6.adb
===================================================================
--- par-ch6.adb	(revision 194188)
+++ par-ch6.adb	(working copy)
@@ -1721,13 +1721,8 @@
          Scan; -- past ALIASED
          Set_Aliased_Present (Decl_Node);
 
-         if Ada_Version < Ada_2012 then
-            Error_Msg_SC -- CODEFIX
-              ("ALIASED not allowed in extended return in Ada 2012?");
-         else
-            Error_Msg_SC -- CODEFIX
-              ("ALIASED not allowed in extended return");
-         end if;
+         --  The restrictions on the use of aliased in an extended return
+         --  are semantic, not syntactic.
 
          if Token = Tok_Constant then
             Scan; -- past CONSTANT
Index: sem_ch6.adb
===================================================================
--- sem_ch6.adb	(revision 194199)
+++ sem_ch6.adb	(working copy)
@@ -787,6 +787,7 @@
 
             Analyze_And_Resolve (Expr, R_Type);
             Check_Limited_Return (Expr);
+
          end if;
 
          --  RETURN only allowed in SPARK as the last statement in function
@@ -806,8 +807,9 @@
          --  Analyze parts specific to extended_return_statement:
 
          declare
-            Obj_Decl : constant Node_Id :=
+            Obj_Decl    : constant Node_Id :=
                          Last (Return_Object_Declarations (N));
+            Has_Aliased : constant Boolean := Aliased_Present (Obj_Decl);
 
             HSS : constant Node_Id := Handled_Statement_Sequence (N);
 
@@ -842,6 +844,19 @@
             Set_Referenced (Defining_Identifier (Obj_Decl));
 
             Check_References (Stm_Entity);
+
+            --  Check RM 6.5 (5.9/3)
+
+            if Has_Aliased then
+               if Ada_Version < Ada_2012 then
+                  Error_Msg_N ("aliased only allowed for limited"
+                     & " return objects in Ada 2012?", N);
+
+               elsif not Is_Immutably_Limited_Type (R_Type) then
+                  Error_Msg_N ("aliased only allowed for limited"
+                     & " return objects", N);
+               end if;
+            end if;
          end;
       end if;
 
