OSDN Git Service

2010-10-05 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / comperr.adb
index 64ec0c7..da6c8a6 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2007, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2009, 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- --
 with Atree;    use Atree;
 with Debug;    use Debug;
 with Errout;   use Errout;
-with Fname;    use Fname;
 with Gnatvsn;  use Gnatvsn;
-with Lib;      use Lib;
 with Namet;    use Namet;
+with Opt;      use Opt;
 with Osint;    use Osint;
 with Output;   use Output;
 with Sinput;   use Sinput;
 with Sprint;   use Sprint;
 with Sdefault; use Sdefault;
+with Targparm; use Targparm;
 with Treepr;   use Treepr;
 with Types;    use Types;
 
@@ -112,6 +112,38 @@ package body Comperr is
 
       Abort_In_Progress := True;
 
+      --  Generate a "standard" error message instead of a bug box in case of
+      --  .NET compiler, since we do not support all constructs of the
+      --  language. Of course ideally, we should detect this before bombing
+      --  on e.g. an assertion error, but in practice most of these bombs
+      --  are due to a legitimate case of a construct not being supported (in
+      --  a sense they all are, since for sure we are not supporting something
+      --  if we bomb!) By giving this message, we provide a more reasonable
+      --  practical interface, since giving scary bug boxes on unsupported
+      --  features is definitely not helpful.
+
+      --  Similarly if we are generating SCIL, an error message is sufficient
+      --  instead of generating a bug box.
+
+      --  Note that the call to Error_Msg_N below sets Serious_Errors_Detected
+      --  to 1, so we use the regular mechanism below in order to display a
+      --  "compilation abandoned" message and exit, so we still know we have
+      --  this case (and -gnatdk can still be used to get the bug box).
+
+      if (VM_Target = CLI_Target or else CodePeer_Mode)
+        and then Serious_Errors_Detected = 0
+        and then not Debug_Flag_K
+        and then Sloc (Current_Error_Node) > No_Location
+      then
+         if VM_Target = CLI_Target then
+            Error_Msg_N
+              ("unsupported construct in this context",
+               Current_Error_Node);
+         else
+            Error_Msg_N ("cannot generate 'S'C'I'L", Current_Error_Node);
+         end if;
+      end if;
+
       --  If any errors have already occurred, then we guess that the abort
       --  may well be caused by previous errors, and we don't make too much
       --  fuss about it, since we want to let programmer fix the errors first.
@@ -369,26 +401,19 @@ package body Comperr is
          Write_Line ("Note that list may not be accurate in some cases, ");
          Write_Line ("so please double check that the problem can still ");
          Write_Line ("be reproduced with the set of files listed.");
+         Write_Line ("Consider also -gnatd.n switch (see debug.adb).");
          Write_Eol;
 
-         for U in Main_Unit .. Last_Unit loop
-            begin
-               if not Is_Internal_File_Name
-                        (File_Name (Source_Index (U)))
-               then
-                  Write_Name (Full_File_Name (Source_Index (U)));
-                  Write_Eol;
-               end if;
+         begin
+            Dump_Source_File_Names;
 
-            --  No point in double bug box if we blow up trying to print
-            --  the list of file names! Output informative msg and quit.
+         --  If we blow up trying to print the list of file names, just output
+         --  informative msg and continue.
 
-            exception
-               when others =>
-                  Write_Str ("list may be incomplete");
-                  exit;
-            end;
-         end loop;
+         exception
+            when others =>
+               Write_Str ("list may be incomplete");
+         end;
 
          Write_Eol;
          Set_Standard_Output;