[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 17 Feb 2012 13:59:28 +0000 (14:59 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 17 Feb 2012 13:59:28 +0000 (14:59 +0100)
2012-02-17  Yannick Moy  <moy@adacore.com>

* gnat_ugn.texi: Fix typos.

2012-02-17  Pascal Obry  <obry@adacore.com>

* prj-nmsc.adb: prj-nmsc.adb (Check_Aggregated): Check that an
aggregate is not Externally_Built.

2012-02-17  Ed Schonberg  <schonberg@adacore.com>

* sem_aggr.adb (Resolve_Record_Aggregate): If a composite
component has a box association, copy the default value using
the current scope as the scope of internal types, to prevent
scoping anomalies in gigi.

From-SVN: r184337

gcc/ada/ChangeLog
gcc/ada/gnat_ugn.texi
gcc/ada/prj-nmsc.adb
gcc/ada/sem_aggr.adb

index f500453fbd896e9f2c99d74f3d63926635ca278b..5f1aae8baca3086b613ed47c99944d9119a605e6 100644 (file)
@@ -1,3 +1,19 @@
+2012-02-17  Yannick Moy  <moy@adacore.com>
+
+       * gnat_ugn.texi: Fix typos.
+
+2012-02-17  Pascal Obry  <obry@adacore.com>
+
+       * prj-nmsc.adb: prj-nmsc.adb (Check_Aggregated): Check that an
+       aggregate is not Externally_Built.
+
+2012-02-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_aggr.adb (Resolve_Record_Aggregate): If a composite
+       component has a box association, copy the default value using
+       the current scope as the scope of internal types, to prevent
+       scoping anomalies in gigi.
+
 2012-02-17  Robert Dewar  <dewar@adacore.com>
 
        * sem_dim.adb, sem_dim.ads, s-tasren.adb, prj.adb, prj.ads, freeze.adb,
index 6a28dbf533af24f1064739c51b9e89a4a62d4ef7..c9951b78b0e298a3e47562be3c90bdd07841b419 100644 (file)
@@ -18009,9 +18009,11 @@ switch or by the corresponding attribute in the project file.
 
 @item filename
 is the name of the source file containing the library unit package declaration
-for which a test package will be created. The file name may given with a path.
+for which a test package will be created. The file name may be given with a
+path.
 
-@item @samp{@var{gcc_switches}} is a list of switches for
+@item @samp{@var{gcc_switches}}
+is a list of switches for
 @command{gcc}. These switches will be passed on to all compiler invocations
 made by @command{gnatstub} to generate a set of ASIS trees. Here you can provide
 @option{^-I^/INCLUDE_DIRS=^} switches to form the source search path,
@@ -18027,7 +18029,7 @@ is an optional sequence of switches as described in the next section.
 @command{gnattest} results can be found in two different places.
 
 @itemize @bullet
-@item automatic harness
+@item automatic harness:
 the harness code, which is located either in the harness-dir as specified on
 the command line or in the project file. All of this code is generated
 completely automatically and can be destroyed and regenerated at will. It is not
@@ -18044,7 +18046,7 @@ test_runner
 Note that you might need to specify the necessary values of scenario variables
 when you are not using the AUnit defaults.
 
-@item actual unit test stubs
+@item actual unit test stubs:
 a test stub for each visible subprogram is created in a separate file, if it
 doesn't exist already. By default, those separate test files are located in a
 "tests" directory that is created in the directory containing the source file
@@ -18053,10 +18055,10 @@ source, option @option{--separate-root} can be used. For example, if a source
 file my_unit.ads in directory src contains a visible subprogram Proc, then
 the corresponding unit test will be found in file
 src/tests/my_unit-tests-proc_<code>.adb. <code> is a signature encoding used to
-differentiate test names in cases of overloading.
+differentiate test names in case of overloading.
 
-Note that if the project already has both my_unit.ads and my_unit-tests.ads this
-will cause name a conflict with generated test package.
+Note that if the project already has both my_unit.ads and my_unit-tests.ads,
+this will cause a name conflict with the generated test package.
 @end itemize
 
 @node Switches for gnattest
index 5d2499deb3b9d6669f5e2f850c2a59d1a4877626..2b65c15d4b59aa8bb2331836b91002055aa27b03 100644 (file)
@@ -8172,6 +8172,14 @@ package body Prj.Nmsc is
          --  Check the aggregate project attributes, reject any not supported
          --  attributes.
 
+         procedure Check_Aggregated
+           (Project : Project_Id;
+            Data    : in out Tree_Processing_Data);
+         --  Check aggregated projets which should not be externally built.
+         --  What is Data??? if same as outer Data, why passed???
+         --  What exact check is performed here??? Seems a bad idea to have
+         --  two procedures with such close names ???
+
          ---------------------
          -- Check_Aggregate --
          ---------------------
@@ -8180,7 +8188,6 @@ package body Prj.Nmsc is
            (Project : Project_Id;
             Data    : in out Tree_Processing_Data)
          is
-
             procedure Check_Not_Defined (Name : Name_Id);
             --  Report an error if Var is defined
 
@@ -8203,6 +8210,8 @@ package body Prj.Nmsc is
                end if;
             end Check_Not_Defined;
 
+         --  Start of processing for Check_Aggregate
+
          begin
             Check_Not_Defined (Snames.Name_Library_Dir);
             Check_Not_Defined (Snames.Name_Library_Interface);
@@ -8216,6 +8225,43 @@ package body Prj.Nmsc is
             Check_Not_Defined (Snames.Name_Library_Version);
          end Check_Aggregate;
 
+         ----------------------
+         -- Check_Aggregated --
+         ----------------------
+
+         procedure Check_Aggregated
+           (Project : Project_Id;
+            Data    : in out Tree_Processing_Data)
+         is
+            L : Aggregated_Project_List;
+
+         begin
+            --  Check that aggregated projects are not externally built
+
+            L := Project.Aggregated_Projects;
+            while L /= null loop
+               declare
+                  Var : constant Prj.Variable_Value :=
+                          Prj.Util.Value_Of
+                            (Snames.Name_Externally_Built,
+                             L.Project.Decl.Attributes,
+                             Data.Tree.Shared);
+               begin
+                  if not Var.Default then
+                     Error_Msg_Name_1 := L.Project.Display_Name;
+                     Error_Msg
+                       (Data.Flags,
+                        "cannot aggregate externally build library %%",
+                        Var.Location, Project);
+                  end if;
+               end;
+
+               L := L.Next;
+            end loop;
+         end Check_Aggregated;
+
+         --  Local Variables
+
          Shared   : constant Shared_Project_Tree_Data_Access :=
                       Data.Tree.Shared;
          Prj_Data : Project_Processing_Data;
@@ -8231,9 +8277,11 @@ package body Prj.Nmsc is
 
          case Project.Qualifier is
             when Aggregate =>
-               null;
+               Check_Aggregated (Project, Data);
 
             when Aggregate_Library =>
+               Check_Aggregated (Project, Data);
+
                if Project.Object_Directory = No_Path_Information then
                   Project.Object_Directory := Project.Directory;
                end if;
@@ -8251,10 +8299,9 @@ package body Prj.Nmsc is
                end if;
          end case;
 
-         --  Check configuration. This must be done even for gnatmake (even
-         --  though no user configuration file was provided) since the default
-         --  config we generate indicates whether libraries are supported for
-         --  instance.
+         --  Check configuration. Must be done for gnatmake (even though no
+         --  user configuration file was provided) since the default config we
+         --  generate indicates whether libraries are supported for instance.
 
          Check_Configuration (Project, Data);
 
@@ -8318,6 +8365,9 @@ package body Prj.Nmsc is
 
       procedure Check_All_Projects is new For_Every_Project_Imported_Context
         (Tree_Processing_Data, Recursive_Check);
+      --  Comment required???
+
+      --  Local Variables
 
       Data : Tree_Processing_Data;
 
@@ -8342,6 +8392,7 @@ package body Prj.Nmsc is
          List := Tree.Projects;
          while List /= null loop
             Proj := List.Project;
+
             Exte := Proj;
             while Exte.Extended_By /= No_Project loop
                Exte := Exte.Extended_By;
index 77a831e01f6dba2dd4897c1540316bfcd1cca4b3..1b7822c348c732cbd19ae6cc2d8ce16643d7ca03 100644 (file)
@@ -3896,7 +3896,12 @@ package body Sem_Aggr is
 
             begin
                --  If there is a default expression for the aggregate, copy
-               --  it into a new association.
+               --  it into a new association. This copy must modify the scopes
+               --  of internal types that may be attached to the expression
+               --  (e.g. index subtypes of arrays) because in general the type
+               --  declaration and the aggregate appear in different scopes,
+               --  and the backend requires the scope of the type to match the
+               --  point at which it is elaborated.
 
                --  If the component has an initialization procedure (IP) we
                --  pass the component to the expander, which will generate
@@ -3916,6 +3921,7 @@ package body Sem_Aggr is
                then
                   Expr :=
                     New_Copy_Tree (Expression (Parent (Component)),
+                     New_Scope => Current_Scope,
                       New_Sloc => Sloc (N));
 
                   Add_Association