end;
    end Error_Msg;
 
+   ----------------------------------
+   -- Error_Msg_Ada_2005_Extension --
+   ----------------------------------
+
+   procedure Error_Msg_Ada_2005_Extension (Extension : String) is
+      Loc : constant Source_Ptr := Token_Ptr;
+   begin
+      if Ada_Version < Ada_2005 then
+         Error_Msg (Extension & " is an Ada 2005 extension", Loc);
+
+         if No (Ada_Version_Pragma) then
+            Error_Msg ("\unit must be compiled with -gnat05 switch", Loc);
+         else
+            Error_Msg_Sloc := Sloc (Ada_Version_Pragma);
+            Error_Msg ("\incompatible with Ada version set#", Loc);
+         end if;
+      end if;
+   end Error_Msg_Ada_2005_Extension;
+
    --------------------------------
    -- Error_Msg_Ada_2012_Feature --
    --------------------------------
 
    --  overridden interface primitive Iface_Prim) indicating wrong mode of the
    --  first formal (RM 9.4(11.9/3)).
 
+   procedure Error_Msg_Ada_2005_Extension (Extension : String);
+   --  Analogous to Error_Msg_Ada_2012_Feature, but phrase the message using
+   --  "extension" and not "feature". This routine is only used in the parser,
+   --  so the error is always placed at the Token_Ptr.
+
    procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr);
    --  If not operating in Ada 2012 mode or higher, posts errors complaining
    --  that Feature is only supported in Ada 2012, with appropriate suggestions
 
                  ("unexpected LIMITED ignored");
             end if;
 
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP ("LIMITED WITH is an Ada 2005 extension");
-               Error_Msg_SP
-                 ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("`LIMITED WITH`");
 
          elsif Token = Tok_Private then
             Has_Limited := False;
 
                Restore_Scan_State (Scan_State); -- to PRIVATE
                return Item_List;
-
-            elsif Ada_Version < Ada_2005 then
-               Error_Msg_SP ("`PRIVATE WITH` is an Ada 2005 extension");
-               Error_Msg_SP
-                 ("\unit must be compiled with -gnat05 switch");
             end if;
 
+            Error_Msg_Ada_2005_Extension ("`PRIVATE WITH`");
+
          else
             Has_Limited := False;
             Has_Private := False;
 
       end if;
 
       if Token = Tok_With then
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SC ("string expression in raise is Ada 2005 extension");
-            Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("string expression in raise");
 
          Scan; -- past WITH
          Set_Expression (Raise_Node, P_Expression);
 
       --  Ada 2005: an association can be given by: others => <>
 
       if Token = Tok_Others then
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("partial parameterization of formal packages"
-               & " is an Ada 2005 extension");
-            Error_Msg_SP
-              ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension
+           ("partial parameterization of formal package");
 
          Scan;  --  past OTHERS
 
             Set_Access_Definition (Decl_Node,
               P_Access_Definition (Not_Null_Present));
 
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP
-                 ("access definition not allowed in formal object " &
-                  "declaration");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension
+              ("access definition in formal object declaration");
 
          --  Formal object with a subtype mark
 
          Set_Limited_Present (Def_Node);
          Scan;  --  past LIMITED
 
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("LIMITED in derived type is an Ada 2005 extension");
-            Error_Msg_SP
-              ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("LIMITED in derived type");
 
       elsif Token = Tok_Synchronized then
          Set_Synchronized_Present (Def_Node);
          Scan;  --  past SYNCHRONIZED
 
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("SYNCHRONIZED in derived type is an Ada 2005 extension");
-            Error_Msg_SP
-              ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("SYNCHRONIZED in derived type");
       end if;
 
       if Token = Tok_Abstract then
       if Token = Tok_And then
          Scan; -- past AND
 
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("abstract interface is an Ada 2005 extension");
-            Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("abstract interface");
 
          Set_Interface_List (Def_Node, New_List);
 
               New_Node (N_Formal_Abstract_Subprogram_Declaration, Prev_Sloc);
             Scan; -- past ABSTRACT
 
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP
-                 ("formal abstract subprograms are an Ada 2005 extension");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("formal abstract subprogram");
 
          else
             Def_Node :=
             Scan; -- past <>
 
          elsif Token = Tok_Null then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP
-                 ("null default subprograms are an Ada 2005 extension");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("null default subprogram");
 
             if Nkind (Spec_Node) = N_Procedure_Specification then
                Set_Null_Present (Spec_Node);
 
                   --  Ada 2005 (AI-419): LIMITED NEW
 
                elsif Token = Tok_New then
-                  if Ada_Version < Ada_2005 then
-                     Error_Msg_SP
-                       ("LIMITED in derived type is an Ada 2005 extension");
-                     Error_Msg_SP
-                       ("\unit must be compiled with -gnat05 switch");
-                  end if;
+                  Error_Msg_Ada_2005_Extension ("LIMITED in derived type");
 
                   Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl;
                   Set_Limited_Present (Typedef_Node);
                   Set_Null_Exclusion_Present (Decl_Node, Not_Null_Present);
 
                   if Token = Tok_Access then
-                     if Ada_Version < Ada_2005 then
-                        Error_Msg_SP
-                          ("generalized use of anonymous access types " &
-                           "is an Ada 2005 extension");
-                        Error_Msg_SP
-                          ("\unit must be compiled with -gnat05 switch");
-                     end if;
+                     Error_Msg_Ada_2005_Extension
+                       ("generalized use of anonymous access types");
 
                      Set_Object_Definition
                        (Decl_Node, P_Access_Definition (Not_Null_Present));
                --  Access definition (AI-406) or subtype indication
 
                if Token = Tok_Access then
-                  if Ada_Version < Ada_2005 then
-                     Error_Msg_SP
-                       ("generalized use of anonymous access types " &
-                        "is an Ada 2005 extension");
-                     Error_Msg_SP
-                       ("\unit must be compiled with -gnat05 switch");
-                  end if;
+                  Error_Msg_Ada_2005_Extension
+                    ("generalized use of anonymous access types");
 
                   Set_Object_Definition
                     (Decl_Node, P_Access_Definition (Not_Null_Present));
             Not_Null_Present := P_Null_Exclusion;  --  Ada 2005 (AI-231/423)
 
             if Token = Tok_Access then
-               if Ada_Version < Ada_2005 then
-                  Error_Msg_SP
-                    ("generalized use of anonymous access types " &
-                     "is an Ada 2005 extension");
-                  Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-               end if;
+               Error_Msg_Ada_2005_Extension
+                 ("generalized use of anonymous access types");
 
                Acc_Node := P_Access_Definition (Not_Null_Present);
 
          --  Ada 2005 (AI-230): Access Definition case
 
          elsif Token = Tok_Access then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP
-                 ("generalized use of anonymous access types " &
-                  "is an Ada 2005 extension");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension
+              ("generalized use of anonymous access types");
 
             Acc_Node := P_Access_Definition (Null_Exclusion_Present => False);
 
       if Token = Tok_And then
          Scan; -- past AND
 
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("abstract interface is an Ada 2005 extension");
-            Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("abstract interface");
 
          Set_Interface_List (Typedef_Node, New_List);
 
       --  Ada 2005 (AI-230): Access Definition case
 
       if Token = Tok_Access then
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("generalized use of anonymous access types " &
-               "is an Ada 2005 extension");
-            Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension
+           ("generalized use of anonymous access types");
 
          --  AI95-406 makes "aliased" legal (and useless) in this context so
          --  followintg code which used to be needed is commented out.
             --  Ada 2005 (AI-230): Access Definition case
 
             if Token = Tok_Access then
-               if Ada_Version < Ada_2005 then
-                  Error_Msg_SP
-                    ("generalized use of anonymous access types " &
-                     "is an Ada 2005 extension");
-                  Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-               end if;
+               Error_Msg_Ada_2005_Extension
+                 ("generalized use of anonymous access types");
 
                --  AI95-406 makes "aliased" legal (and useless) here, so the
                --  following code which used to be required is commented out.
       Typedef_Node : Node_Id;
 
    begin
-      if Ada_Version < Ada_2005 then
-         Error_Msg_SP ("abstract interface is an Ada 2005 extension");
-         Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-      end if;
+      Error_Msg_Ada_2005_Extension ("abstract interface");
 
       if Abstract_Present then
          Error_Msg_SP
          --  Ada 2005 (AI-318-02)
 
          if Token = Tok_Access then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SC
-                 ("anonymous access result type is an Ada 2005 extension");
-               Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("anonymous access result type");
 
             Result_Node := P_Access_Definition (Result_Not_Null);
 
         or else Token = Tok_Procedure
         or else Token = Tok_Function
       then
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP ("access-to-subprogram is an Ada 2005 extension");
-            Error_Msg_SP ("\unit should be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("access-to-subprogram");
 
          Subp_Node := P_Access_Type_Definition (Header_Already_Parsed => True);
          Set_Null_Exclusion_Present (Subp_Node, Null_Exclusion_Present);
             Set_All_Present (Def_Node);
 
          elsif Token = Tok_Constant then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP ("access-to-constant is an Ada 2005 extension");
-               Error_Msg_SP ("\unit should be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("access-to-constant");
 
             Scan; -- past CONSTANT
             Set_Constant_Present (Def_Node);
 
 
       procedure Box_Error is
       begin
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SC ("box in aggregate is an Ada 2005 extension");
-         end if;
+         Error_Msg_Ada_2005_Extension ("'<'> in aggregate");
 
          --  Ada 2005 (AI-287): The box notation is allowed only with named
          --  notation because positional notation might be error prone. For
          --  Ada 2005(AI-287): The box notation is used to indicate the
          --  default initialization of aggregate components
 
-         if Ada_Version < Ada_2005 then
-            Error_Msg_SP
-              ("component association with '<'> is an Ada 2005 extension");
-            Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-         end if;
+         Error_Msg_Ada_2005_Extension ("component association with '<'>");
 
          Set_Box_Present (Assoc_Node);
          Scan; -- Past box
 
          --  Ada 2005 (AI-318-02)
 
          if Token = Tok_Access then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SC
-                 ("anonymous access result type is an Ada 2005 extension");
-               Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("anonymous access result type");
 
             Result_Node := P_Access_Definition (Result_Not_Null);
 
             --  Ada 2005 (AI-248): Parse a null procedure declaration
 
             elsif Token = Tok_Null then
-               if Ada_Version < Ada_2005 then
-                  Error_Msg_SP ("null procedures are an Ada 2005 extension");
-                  Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-               end if;
+               Error_Msg_Ada_2005_Extension ("null procedure");
 
                Scan; -- past NULL
 
          --  Ada 2005 (AI-318-02)
 
          if Token = Tok_Access then
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SC
-                 ("anonymous access result type is an Ada 2005 extension");
-               Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("anonymous access result type");
 
             Result_Node := P_Access_Definition (Result_Not_Null);
 
          --  Extended_return_statement (Ada 2005 only -- AI-318):
 
          else
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP
-                 (" extended_return_statement is an Ada 2005 extension");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("extended return statement");
 
             Ret_Node := New_Node (N_Extended_Return_Statement, Ret_Sloc);
             Decl := P_Return_Object_Declaration;
 
             if Token = Tok_New then
                Scan; --  past NEW
 
-               if Ada_Version < Ada_2005 then
-                  Error_Msg_SP ("task interface is an Ada 2005 extension");
-                  Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-               end if;
+               Error_Msg_Ada_2005_Extension ("task interface");
 
                Set_Interface_List (Task_Node, New_List);
 
          if Token = Tok_New then
             Scan; --  past NEW
 
-            if Ada_Version < Ada_2005 then
-               Error_Msg_SP ("protected interface is an Ada 2005 extension");
-               Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
-            end if;
+            Error_Msg_Ada_2005_Extension ("protected interface");
 
             Set_Interface_List (Protected_Node, New_List);
 
             if Ada_Version = Ada_83 then
                Error_Msg_BC ("OR or ELSE expected");
             else
-               Error_Msg_BC ("OR or ELSE or THEN ABORT expected");
+               Error_Msg_BC ("OR or ELSE or `THEN ABORT` expected");
             end if;
 
             Select_Node := Error;