Index: csinfo.adb
===================================================================
--- csinfo.adb	(revision 165935)
+++ csinfo.adb	(working copy)
@@ -23,10 +23,13 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Program to check consistency of sinfo.ads and sinfo.adb. Checks that field
---  name usage is consistent and that assertion cross-reference lists are
---  correct, as well as making sure that all the comments on field name usage
---  are consistent.
+--  Check consistency of sinfo.ads and sinfo.adb. Checks that field name usage
+--  is consistent and that assertion cross-reference lists are correct, as well
+--  as making sure that all the comments on field name usage are consistent.
+
+--  Note that this is used both as a standalone program, and as a procedure
+--  called by XSinfo. This raises an unhandled exception if it finds any
+--  errors; we don't attempt any sophisticated error recovery.
 
 with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
 with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
@@ -635,8 +638,4 @@ begin
    New_Line;
    Put_Line ("All tests completed successfully, no errors detected");
 
-exception
-   when Done =>
-      null;
-
 end CSinfo;
Index: sinfo.ads
===================================================================
--- sinfo.ads	(revision 165935)
+++ sinfo.ads	(working copy)
@@ -100,10 +100,10 @@ package Sinfo is
 
    --  Finally, four utility programs must be run:
 
-   --    Run CSinfo to check that you have made the changes consistently. It
-   --     checks most of the rules given above, with clear error messages. This
-   --     utility reads sinfo.ads and sinfo.adb and generates a report to
-   --     standard output.
+   --    (Optional.) Run CSinfo to check that you have made the changes
+   --     consistently. It checks most of the rules given above. This utility
+   --     reads sinfo.ads and sinfo.adb and generates a report to standard
+   --     output. This step is optional because XSinfo runs CSinfo.
 
    --    Run XSinfo to create sinfo.h, the corresponding C header. This
    --     utility reads sinfo.ads and generates sinfo.h. Note that it does
@@ -120,8 +120,8 @@ package Sinfo is
    --     spec of the Nmake package which contains functions for constructing
    --     nodes.
 
-   --  All of the above steps except CSinfo are done automatically by the
-   --  build scripts when you do a full bootstrap.
+   --  The above steps are done automatically by the build scripts when you do
+   --  a full bootstrap.
 
    --  Note: sometime we could write a utility that actually generated the body
    --  of sinfo from the spec instead of simply checking it, since, as noted
Index: ceinfo.adb
===================================================================
--- ceinfo.adb	(revision 165935)
+++ ceinfo.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1998-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1998-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -23,8 +23,12 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
---  Program to check consistency of einfo.ads and einfo.adb. Checks that
---  field name usage is consistent, including comments mentioning fields.
+--  Check consistency of einfo.ads and einfo.adb. Checks that field name usage
+--  is consistent, including comments mentioning fields.
+
+--  Note that this is used both as a standalone program, and as a procedure
+--  called by XEinfo. This raises an unhandled exception if it finds any
+--  errors; we don't attempt any sophisticated error recovery.
 
 with Ada.Strings.Unbounded;         use Ada.Strings.Unbounded;
 with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO;
@@ -42,6 +46,9 @@ procedure CEinfo is
    Infil  : File_Type;
    Lineno : Natural := 0;
 
+   Err : exception;
+   --  Raised on error
+
    Fieldnm    : VString;
    Accessfunc : VString;
    Line       : VString;
@@ -126,6 +133,7 @@ begin
                Put_Line
                  ("*** unknown field name " & Fieldnm & " at line " & Lineno);
             end if;
+            raise Err;
          end if;
       end if;
    end loop;
@@ -153,6 +161,7 @@ begin
             Put_Line
               ("*** unknown field name " & Fieldnm & " at line " & Lineno);
          end if;
+            raise Err;
       end if;
    end loop;
 
@@ -172,6 +181,7 @@ begin
          Put_Line ("*** incorrect field at line " & Lineno);
          Put_Line ("      found field " & Accessfunc);
          Put_Line ("      expecting field " & Get (Fields, Fieldnm));
+         raise Err;
       end if;
    end loop;
 
@@ -196,9 +206,12 @@ begin
          Put_Line ("*** incorrect field at line " & Lineno);
          Put_Line ("      found field " & Accessfunc);
          Put_Line ("      expecting field " & Get (Fields, Fieldnm));
+         raise Err;
       end if;
    end loop;
 
+   Close (Infil);
+
    Put_Line ("All tests completed successfully, no errors detected");
 
 end CEinfo;
Index: xsinfo.adb
===================================================================
--- xsinfo.adb	(revision 165935)
+++ xsinfo.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -35,10 +35,6 @@
 
 --       sinfo.h       Corresponding c header file
 
---  Note: this program assumes that sinfo.ads has passed the error checks
---  which are carried out by the CSinfo utility, so it does not duplicate
---  these checks and assumes the source is correct.
-
 --  An optional argument allows the specification of an output file name to
 --  override the default sinfo.h file name for the generated output file.
 
@@ -50,6 +46,8 @@ with Ada.Text_IO;                   use 
 with GNAT.Spitbol;                  use GNAT.Spitbol;
 with GNAT.Spitbol.Patterns;         use GNAT.Spitbol.Patterns;
 
+with CSinfo;
+
 procedure XSinfo is
 
    Done : exception;
@@ -115,6 +113,11 @@ procedure XSinfo is
 --  Start of processing for XSinfo
 
 begin
+   --  First run CSinfo to check for errors. Note that CSinfo is also a
+   --  stand-alone program that can be run separately.
+
+   CSinfo;
+
    Set_Exit_Status (1);
    Anchored_Mode := True;
 
@@ -238,10 +241,13 @@ begin
 
       Getline;
    end loop;
+   --  Can't get here; above loop only left via raise
 
 exception
    when Done =>
+      Close (InS);
       Put_Line (Ofile, "");
+      Close (Ofile);
       Set_Exit_Status (0);
 
 end XSinfo;
Index: xeinfo.adb
===================================================================
--- xeinfo.adb	(revision 165935)
+++ xeinfo.adb	(working copy)
@@ -57,6 +57,8 @@ with GNAT.Spitbol;                  use 
 with GNAT.Spitbol.Patterns;         use GNAT.Spitbol.Patterns;
 with GNAT.Spitbol.Table_Boolean;    use GNAT.Spitbol.Table_Boolean;
 
+with CEinfo;
+
 procedure XEinfo is
 
    package TB renames GNAT.Spitbol.Table_Boolean;
@@ -241,6 +243,11 @@ procedure XEinfo is
 --  Start of processing for XEinfo
 
 begin
+   --  First run CEinfo to check for errors. Note that CEinfo is also a
+   --  stand-alone program that can be run separately.
+
+   CEinfo;
+
    Anchored_Mode := True;
 
    if Argument_Count > 0 then
@@ -489,6 +496,9 @@ begin
      (Ofile,
       "/* End of einfo.h (C version of Einfo package specification) */");
 
+   Close (InF);
+   Close (Ofile);
+
 exception
    when Err =>
       Put_Line (Standard_Error, Lineno & ".  " & Line);
Index: Make-generated.in
===================================================================
--- Make-generated.in	(revision 165935)
+++ Make-generated.in	(working copy)
@@ -29,13 +29,13 @@ $(ADA_GEN_SUBDIR)/treeprs.ads : $(ADA_GE
 	$(CP) $^ $(ADA_GEN_SUBDIR)/bldtools/treeprs
 	(cd $(ADA_GEN_SUBDIR)/bldtools/treeprs; gnatmake -q xtreeprs ; ./xtreeprs ../../treeprs.ads )
 
-$(ADA_GEN_SUBDIR)/einfo.h : $(ADA_GEN_SUBDIR)/einfo.ads $(ADA_GEN_SUBDIR)/einfo.adb $(ADA_GEN_SUBDIR)/xeinfo.adb
+$(ADA_GEN_SUBDIR)/einfo.h : $(ADA_GEN_SUBDIR)/einfo.ads $(ADA_GEN_SUBDIR)/einfo.adb $(ADA_GEN_SUBDIR)/xeinfo.adb $(ADA_GEN_SUBDIR)/ceinfo.adb
 	-$(MKDIR) $(ADA_GEN_SUBDIR)/bldtools/einfo
 	$(RM) $(addprefix $(ADA_GEN_SUBDIR)/bldtools/einfo/,$(notdir $^))
 	$(CP) $^ $(ADA_GEN_SUBDIR)/bldtools/einfo
 	(cd $(ADA_GEN_SUBDIR)/bldtools/einfo; gnatmake -q xeinfo ; ./xeinfo ../../einfo.h )
 
-$(ADA_GEN_SUBDIR)/sinfo.h : $(ADA_GEN_SUBDIR)/sinfo.ads $(ADA_GEN_SUBDIR)/xsinfo.adb
+$(ADA_GEN_SUBDIR)/sinfo.h : $(ADA_GEN_SUBDIR)/sinfo.ads $(ADA_GEN_SUBDIR)/sinfo.adb $(ADA_GEN_SUBDIR)/xsinfo.adb $(ADA_GEN_SUBDIR)/csinfo.adb
 	-$(MKDIR) $(ADA_GEN_SUBDIR)/bldtools/sinfo
 	$(RM) $(addprefix $(ADA_GEN_SUBDIR)/bldtools/sinfo/,$(notdir $^))
 	$(CP) $^ $(ADA_GEN_SUBDIR)/bldtools/sinfo
