sem_ch3.adb (Analyze_Variant_Part): check that type of discriminant is discrete befor...
authorGeert Bosch <bosch@gcc.gnu.org>
Mon, 17 Dec 2001 21:07:05 +0000 (22:07 +0100)
committerGeert Bosch <bosch@gcc.gnu.org>
Mon, 17 Dec 2001 21:07:05 +0000 (22:07 +0100)
* sem_ch3.adb (Analyze_Variant_Part): check that type of discriminant
is discrete before analyzing choices.

* bindgen.adb (Gen_Output_File_Ada): Generate a new C-like string
containing the name of the Ada Main Program. This string is mainly
intended for the debugger.
(Gen_Output_File_C): Do the equivalent change when generating a C file.

* ali.adb: Set new Dummy_Entry field in dependency entry

* ali.ads: Add Dummy_Entry field to source dependency table

* bcheck.adb (Check_Consistency): Ignore dummy D lines

* lib-writ.adb (Writ_ALI): Write dummy D lines for missing source files

* lib-writ.ads: Document dummy D lines for missing files.

* types.ads: (Dummy_Time_Stamp): New value for non-existant files

From-SVN: r48126

gcc/ada/ChangeLog
gcc/ada/ali.adb
gcc/ada/ali.ads
gcc/ada/bcheck.adb
gcc/ada/bindgen.adb
gcc/ada/lib-writ.adb
gcc/ada/lib-writ.ads
gcc/ada/sem_ch3.adb
gcc/ada/types.ads

index 2c049d969ae9c91b5645a42d6be50a15c10363d3..76ab8a0177965afaad3cf579a2702af1b7b17bc1 100644 (file)
@@ -1,3 +1,29 @@
+2001-12-17  Ed Schonberg <schonber@gnat.com>
+
+       * sem_ch3.adb (Analyze_Variant_Part): check that type of discriminant 
+       is discrete before analyzing choices.
+       
+2001-12-17  Joel Brobecker <brobecke@gnat.com>
+
+       * bindgen.adb (Gen_Output_File_Ada): Generate a new C-like string 
+       containing the name of the Ada Main Program. This string is mainly 
+       intended for the debugger.
+       (Gen_Output_File_C): Do the equivalent change when generating a C file.
+       
+2001-12-17  Robert Dewar <dewar@gnat.com>
+
+       * ali.adb: Set new Dummy_Entry field in dependency entry
+       
+       * ali.ads: Add Dummy_Entry field to source dependency table
+       
+       * bcheck.adb (Check_Consistency): Ignore dummy D lines
+       
+       * lib-writ.adb (Writ_ALI): Write dummy D lines for missing source files
+       
+       * lib-writ.ads: Document dummy D lines for missing files.
+       
+       * types.ads: (Dummy_Time_Stamp): New value for non-existant files
+
 2001-12-17  Robert Dewar <dewar@gnat.com>
 
        * ali.adb: Type reference does not reset current file.
index c0d744ffb93102e1e8760558cd74633b90949a6d..5a4c21bcffabde38355ec28ef9b5284533ec242e 100644 (file)
@@ -1128,8 +1128,10 @@ package body ALI is
          Sdep.Increment_Last;
          Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
          Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
+         Sdep.Table (Sdep.Last).Dummy_Entry :=
+           (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
 
-         --  Check for version number present, and if so store it
+         --  Acquire checksum value
 
          Skip_Space;
 
index 1e427e836b83f455d7ff8aa4020f3f9d0153c1a9..78b9435f33476586c7830c9acb8b719d93f9e33f 100644 (file)
@@ -517,10 +517,16 @@ package ALI is
       --  Name of source file
 
       Stamp : Time_Stamp_Type;
-      --  Time stamp value
+      --  Time stamp value. Note that this will be all zero characters
+      --  for the dummy entries for missing or non-dependent files.
 
       Checksum : Word;
-      --  Checksum value
+      --  Checksum value. Note that this will be all zero characters
+      --  for the dummy entries for missing or non-dependent files
+
+      Dummy_Entry : Boolean;
+      --  Set True for dummy entries that correspond to missing files
+      --  or files where no dependency relationship exists.
 
       Subunit_Name : Name_Id;
       --  Name_Id for subunit name if present, else No_Name
index c4da75740301fc68618602bdc935739d4442f766..77b3284fc333f89441126acfb89900add5afbab6 100644 (file)
@@ -529,6 +529,10 @@ package body Bcheck is
          Sdep_Loop : for D in
            ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
          loop
+            if Sdep.Table (D).Dummy_Entry then
+               goto Continue;
+            end if;
+
             Src := Source_Id (Get_Name_Table_Info (Sdep.Table (D).Sfile));
 
             --  If the time stamps match, or all checksums match, then we
@@ -587,6 +591,8 @@ package body Bcheck is
                exit Sdep_Loop;
             end if;
 
+         <<Continue>>
+            null;
          end loop Sdep_Loop;
       end loop ALIs_Loop;
    end Check_Consistency;
index d2af91bc8d6b4fb84cc5f9daa235c27d1977479b..a45e7923e1f46da1769a8e7fe1eda4b669297a39 100644 (file)
@@ -1752,9 +1752,10 @@ package body Bindgen is
          end if;
       end if;
 
-      --  Generate the GNAT_Version info only for the main program. Otherwise,
-      --  it can lead under some circumstances to a symbol duplication during
-      --  the link (for instance when a C program uses 2 Ada libraries)
+      --  Generate the GNAT_Version and Ada_Main_Program_name info only for
+      --  the main program. Otherwise, it can lead under some circumstances
+      --  to a symbol duplication during the link (for instance when a
+      --  C program uses 2 Ada libraries)
 
       if Bind_Main_Program then
          WBI ("");
@@ -1762,6 +1763,17 @@ package body Bindgen is
          WBI ("                    ""GNAT Version: " &
                                    Gnat_Version_String & """;");
          WBI ("   pragma Export (C, GNAT_Version, ""__gnat_version"");");
+
+         WBI ("");
+         Set_String ("   Ada_Main_Program_Name : constant String := """);
+         Get_Name_String (Units.Table (First_Unit_Entry).Uname);
+         Set_Main_Program_Name;
+         Set_String (""" & Ascii.NUL;");
+         Write_Statement_Buffer;
+
+         WBI
+           ("   pragma Export (C, Ada_Main_Program_Name, " &
+            """__gnat_ada_main_program_name"");");
       end if;
 
       --  No need to generate a finalization routine if there is no
@@ -2006,15 +2018,21 @@ package body Bindgen is
          WBI ("void __gnat_break_start () {}");
       end if;
 
-      --  Generate the __gnat_version info only for the main program.
-      --  Otherwise, it can lead under some circumstances to a symbol
-      --  duplication during the link (for instance when a C program
-      --  uses 2 Ada libraries)
+      --  Generate the __gnat_version and __gnat_ada_main_program_name info
+      --  only for the main program. Otherwise, it can lead under some
+      --  circumstances to a symbol duplication during the link (for instance
+      --  when a C program uses 2 Ada libraries)
 
       if Bind_Main_Program then
          WBI ("");
          WBI ("char __gnat_version[] = ""GNAT Version: " &
                                    Gnat_Version_String & """;");
+
+         Set_String ("char __gnat_ada_main_program_name[] = """);
+         Get_Name_String (Units.Table (First_Unit_Entry).Uname);
+         Set_Main_Program_Name;
+         Set_String (""";");
+         Write_Statement_Buffer;
       end if;
 
       --  Generate the adafinal routine. In no runtime mode, this is
index a7039f8390fff7114200dab8e6631d2d80b3305e..c2b15d59df02f2551aa5408c59adc49c0f8a667e 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.160 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
 --                                                                          --
@@ -880,50 +880,60 @@ package body Lib.Writ is
       begin
          for J in 1 .. Num_Sdep loop
             Unum := Sdep_Table (J);
+            Units.Table (Unum).Dependency_Num := J;
             Sind := Units.Table (Unum).Source_Index;
 
-            --  Error defence, ignore entries with no source index
+            Write_Info_Initiate ('D');
+            Write_Info_Char (' ');
 
-            if Sind /= No_Source_File then
-               Units.Table (Unum).Dependency_Num := J;
+            --  Normal case of a dependent unit entry with a source index
 
-               if Units.Table (Unum).Dependent_Unit then
-                  Write_Info_Initiate ('D');
-                  Write_Info_Char (' ');
-                  Write_Info_Name (File_Name (Sind));
-                  Write_Info_Tab (25);
-                  Write_Info_Str (String (Time_Stamp (Sind)));
-                  Write_Info_Char (' ');
-                  Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
-
-                  --  If subunit, add unit name, omitting the %b at the end
+            if Sind /= No_Source_File
+              and then Units.Table (Unum).Dependent_Unit
+            then
+               Write_Info_Name (File_Name (Sind));
+               Write_Info_Tab (25);
+               Write_Info_Str (String (Time_Stamp (Sind)));
+               Write_Info_Char (' ');
+               Write_Info_Str (Get_Hex_String (Source_Checksum (Sind)));
 
-                  if Present (Cunit (Unum))
-                    and then Nkind (Unit (Cunit (Unum))) = N_Subunit
-                  then
-                     Get_Decoded_Name_String (Unit_Name (Unum));
-                     Write_Info_Char (' ');
-                     Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
-                  end if;
+               --  If subunit, add unit name, omitting the %b at the end
 
-                  --  If Source_Reference pragma used output information
+               if Present (Cunit (Unum))
+                 and then Nkind (Unit (Cunit (Unum))) = N_Subunit
+               then
+                  Get_Decoded_Name_String (Unit_Name (Unum));
+                  Write_Info_Char (' ');
+                  Write_Info_Str (Name_Buffer (1 .. Name_Len - 2));
+               end if;
 
-                  if Num_SRef_Pragmas (Sind) > 0 then
-                     Write_Info_Char (' ');
+               --  If Source_Reference pragma used output information
 
-                     if Num_SRef_Pragmas (Sind) = 1 then
-                        Write_Info_Nat (Int (First_Mapped_Line (Sind)));
-                     else
-                        Write_Info_Nat (0);
-                     end if;
+               if Num_SRef_Pragmas (Sind) > 0 then
+                  Write_Info_Char (' ');
 
-                     Write_Info_Char (':');
-                     Write_Info_Name (Reference_Name (Sind));
+                  if Num_SRef_Pragmas (Sind) = 1 then
+                     Write_Info_Nat (Int (First_Mapped_Line (Sind)));
+                  else
+                     Write_Info_Nat (0);
                   end if;
 
-                  Write_Info_EOL;
+                  Write_Info_Char (':');
+                  Write_Info_Name (Reference_Name (Sind));
                end if;
+
+            --  Case where there is no source index (happens for missing files)
+            --  Also come here for non-dependent units.
+
+            else
+               Write_Info_Name (Unit_File_Name (Unum));
+               Write_Info_Tab (25);
+               Write_Info_Str (String (Dummy_Time_Stamp));
+               Write_Info_Char (' ');
+               Write_Info_Str (Get_Hex_String (0));
             end if;
+
+            Write_Info_EOL;
          end loop;
       end;
 
index 75621d765a4a330b6059aa6d55fa9318ef2c5323..f1770ba590e5072bf40c9ef49870d3d76a201e1e 100644 (file)
@@ -403,6 +403,7 @@ package Lib.Writ is
 
    --  The dependency lines indicate the source files on which the compiled
    --  units depend. This is used by the binder for consistency checking.
+   --  These lines are also referenced by the cross-reference information.
 
    --    D source-name time-stamp checksum [subunit-name] line:file-name
 
@@ -437,6 +438,13 @@ package Lib.Writ is
    --      lines to ease readability. Blanks between fields are also
    --      ignored.
 
+   --      For entries corresponding to files that were not present (and
+   --      thus resulted in error messages), or for files that are not
+   --      part of the dependency set, both the time stamp and checksum
+   --      are set to all zero characters. These dummy entries are ignored
+   --      by the binder in dependency checking, but must be present for
+   --      proper interpretation of the cross-reference data.
+
    --------------------------
    -- Cross-Reference Data --
    --------------------------
index eb3d2939405c4ea736ea25706715072d391518ef..d1076c85ef9a5e2ff5e2ca1a633f30bd8737cbc3 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---                            $Revision: 1.10 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001, Free Software Foundation, Inc.         --
 --                                                                          --
@@ -2609,6 +2609,13 @@ package body Sem_Ch3 is
 
       Discr_Type := Etype (Entity (Discr_Name));
 
+      if not Is_Discrete_Type (Discr_Type) then
+         Error_Msg_N
+           ("discriminant in a variant part must be of a discrete type",
+             Name (N));
+         return;
+      end if;
+
       --  Call the instantiated Analyze_Choices which does the rest of the work
 
       Analyze_Choices
index 4c73f2e4bc8bb2e5130f3ff7f5107f4aee2357ec..bd25cf616ec565a79e2335f2a15ee34c0b2b061c 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                            $Revision: 1.3 $
+--                            $Revision$
 --                                                                          --
 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
 --                                                                          --
@@ -622,6 +622,10 @@ pragma Preelaborate (Types);
    --  exact way in which this string is represented, and instead should
    --  use the subprograms below.
 
+   Dummy_Time_Stamp : constant Time_Stamp_Type := (others => '0');
+   --  This is used for dummy time stamp values used in the D lines for
+   --  non-existant files, and is intended to be an impossible value.
+
    function "="  (Left, Right : Time_Stamp_Type) return Boolean;
    function "<=" (Left, Right : Time_Stamp_Type) return Boolean;
    function ">=" (Left, Right : Time_Stamp_Type) return Boolean;