[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 25 Apr 2017 09:46:05 +0000 (11:46 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 25 Apr 2017 09:46:05 +0000 (11:46 +0200)
2017-04-25  Bob Duff  <duff@adacore.com>

* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
Use Source_Index (Current_Sem_Unit) to find the correct casing.
* exp_prag.adb (Expand_Pragma_Check): Use Source_Index
(Current_Sem_Unit) to find the correct casing.
* par.adb (Par): Null out Current_Source_File, to ensure that
the above bugs won't rear their ugly heads again.

2017-04-25  Ed Schonberg  <schonberg@adacore.com>

* sem_ch8.adb (Find_Type): For an attribute reference
'Class, if prefix type is synchronized and previous errors
have suppressed the creation of the corresponding record type,
create a spurious class-wide for the synchonized type itself,
to catch other misuses of the attribute

2017-04-25  Steve Baird  <baird@adacore.com>

* exp_ch6.adb (Expand_Simple_Function_Return): if CodePeer_Mode
is True, then don't generate the accessibility check for the
tag of a tagged result.
* exp_intr.adb (Expand_Dispatching_Constructor_Call):
if CodePeer_Mode is True, then don't generate the
tag checks for the result of call to an instance of
Ada.Tags.Generic_Dispatching_Constructor (i.e., both the "is a
descendant of" check and the accessibility check).

2017-04-25  Ed Schonberg  <schonberg@adacore.com>

* sem_ch13.adb: Code cleanups.
* a-strbou.ads: minor whitespace fix in Trim for bounded strings.
* sem_ch8.ads: Minor comment fix.

From-SVN: r247168

gcc/ada/ChangeLog
gcc/ada/a-strbou.ads
gcc/ada/exp_ch6.adb
gcc/ada/exp_intr.adb
gcc/ada/exp_prag.adb
gcc/ada/par.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch8.adb
gcc/ada/sem_ch8.ads
gcc/ada/sem_prag.adb

index ac39123cec269065b2c6e729e1dafa03cf6adee3..e108648cf6b706771fd94b3467dba1566f9f7f29 100644 (file)
@@ -1,3 +1,37 @@
+2017-04-25  Bob Duff  <duff@adacore.com>
+
+       * sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
+       Use Source_Index (Current_Sem_Unit) to find the correct casing.
+       * exp_prag.adb (Expand_Pragma_Check): Use Source_Index
+       (Current_Sem_Unit) to find the correct casing.
+       * par.adb (Par): Null out Current_Source_File, to ensure that
+       the above bugs won't rear their ugly heads again.
+
+2017-04-25  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch8.adb (Find_Type): For an attribute reference
+       'Class, if prefix type is synchronized and previous errors
+       have suppressed the creation of the corresponding record type,
+       create a spurious class-wide for the synchonized type itself,
+       to catch other misuses of the attribute
+
+2017-04-25  Steve Baird  <baird@adacore.com>
+
+       * exp_ch6.adb (Expand_Simple_Function_Return): if CodePeer_Mode
+       is True, then don't generate the accessibility check for the
+       tag of a tagged result.
+       * exp_intr.adb (Expand_Dispatching_Constructor_Call):
+       if CodePeer_Mode is True, then don't generate the
+       tag checks for the result of call to an instance of
+       Ada.Tags.Generic_Dispatching_Constructor (i.e., both the "is a
+       descendant of" check and the accessibility check).
+
+2017-04-25  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch13.adb: Code cleanups.
+       * a-strbou.ads: minor whitespace fix in Trim for bounded strings.
+       * sem_ch8.ads: Minor comment fix.
+
 2017-04-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        * exp_ch4.adb (Library_Level_Target): New function.
index 7703b72810711864e576973ef7076df3ec09a5d8..5e7a9c71d151dc6d4102d1026e62c7840aaaa3cc 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2014, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2016, Free Software Foundation, Inc.         --
 --                                                                          --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -391,8 +391,8 @@ package Ada.Strings.Bounded is
 
       function Trim
         (Source : Bounded_String;
-          Left  : Maps.Character_Set;
-          Right : Maps.Character_Set) return Bounded_String;
+         Left   : Maps.Character_Set;
+         Right  : Maps.Character_Set) return Bounded_String;
 
       procedure Trim
         (Source : in out Bounded_String;
index cb90fd259cd6ee0bf9d4bc5e5ceb9642012f7d4d..8c4868d7eb324806f1a5d201abfa29a24f1aa8b6 100644 (file)
@@ -6635,15 +6635,20 @@ package body Exp_Ch6 is
                    Attribute_Name => Name_Tag);
             end if;
 
-            Insert_Action (Exp,
-              Make_Raise_Program_Error (Loc,
-                Condition =>
-                  Make_Op_Gt (Loc,
-                    Left_Opnd  => Build_Get_Access_Level (Loc, Tag_Node),
-                    Right_Opnd =>
-                      Make_Integer_Literal (Loc,
-                        Scope_Depth (Enclosing_Dynamic_Scope (Scope_Id)))),
-                Reason => PE_Accessibility_Check_Failed));
+            if not CodePeer_Mode then
+               --  CodePeer doesn't do anything useful with
+               --  Ada.Tags.Type_Specific_Data components
+
+               Insert_Action (Exp,
+                 Make_Raise_Program_Error (Loc,
+                   Condition =>
+                     Make_Op_Gt (Loc,
+                       Left_Opnd  => Build_Get_Access_Level (Loc, Tag_Node),
+                       Right_Opnd =>
+                         Make_Integer_Literal (Loc,
+                           Scope_Depth (Enclosing_Dynamic_Scope (Scope_Id)))),
+                   Reason => PE_Accessibility_Check_Failed));
+            end if;
          end;
 
       --  AI05-0073: If function has a controlling access result, check that
index 4363c75a1909aeefd05811f95bfec9df926a02b0..fde0617aa834cbe8ba6b1f8afaf5d61d7fbbdd8a 100644 (file)
@@ -421,20 +421,22 @@ package body Exp_Intr is
       Result_Typ := Class_Wide_Type (Etype (Act_Constr));
 
       --  Check that the accessibility level of the tag is no deeper than that
-      --  of the constructor function.
+      --  of the constructor function (unless CodePeer_Mode)
 
-      Insert_Action (N,
-        Make_Implicit_If_Statement (N,
-          Condition       =>
-            Make_Op_Gt (Loc,
-              Left_Opnd  =>
-                Build_Get_Access_Level (Loc, New_Copy_Tree (Tag_Arg)),
-              Right_Opnd =>
-                Make_Integer_Literal (Loc, Scope_Depth (Act_Constr))),
-
-          Then_Statements => New_List (
-            Make_Raise_Statement (Loc,
-              New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
+      if not CodePeer_Mode then
+         Insert_Action (N,
+           Make_Implicit_If_Statement (N,
+             Condition       =>
+               Make_Op_Gt (Loc,
+                 Left_Opnd  =>
+                   Build_Get_Access_Level (Loc, New_Copy_Tree (Tag_Arg)),
+                 Right_Opnd =>
+                   Make_Integer_Literal (Loc, Scope_Depth (Act_Constr))),
+
+             Then_Statements => New_List (
+               Make_Raise_Statement (Loc,
+                 New_Occurrence_Of (RTE (RE_Tag_Error), Loc)))));
+      end if;
 
       if Is_Interface (Etype (Act_Constr)) then
 
@@ -505,10 +507,11 @@ package body Exp_Intr is
 
       --  Do not generate a run-time check on the built object if tag
       --  checks are suppressed for the result type or tagged type expansion
-      --  is disabled.
+      --  is disabled or if CodePeer_Mode.
 
       if Tag_Checks_Suppressed (Etype (Result_Typ))
         or else not Tagged_Type_Expansion
+        or else CodePeer_Mode
       then
          null;
 
index b8490a74a2c18f38b1e3bfb5f1ac0d33d7d8429a..da6a4c3ab8b01dca559276f39d0d2b051bfff15d 100644 (file)
@@ -33,6 +33,7 @@ with Exp_Ch11; use Exp_Ch11;
 with Exp_Util; use Exp_Util;
 with Expander; use Expander;
 with Inline;   use Inline;
+with Lib;      use Lib;
 with Namet;    use Namet;
 with Nlists;   use Nlists;
 with Nmake;    use Nmake;
@@ -432,11 +433,12 @@ package body Exp_Prag is
                   Add_Str_To_Name_Buffer ("failed invariant from ");
 
                --  For all other checks, the string is "xxx failed at yyy"
-               --  where xxx is the check name with current source file casing.
+               --  where xxx is the check name with appropriate casing.
 
                else
                   Get_Name_String (Nam);
-                  Set_Casing (Identifier_Casing (Current_Source_File));
+                  Set_Casing
+                    (Identifier_Casing (Source_Index (Current_Sem_Unit)));
                   Add_Str_To_Name_Buffer (" failed at ");
                end if;
 
index 26730d497e66c9863474be2133ffc6cd16cdb156..863149b0cdd1a1140526324665477791083c1fc2 100644 (file)
@@ -1457,6 +1457,8 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
    procedure Labl is separate;
    procedure Load is separate;
 
+   Result : List_Id := Empty_List;
+
 --  Start of processing for Par
 
 begin
@@ -1472,13 +1474,13 @@ begin
       begin
          loop
             if Token = Tok_EOF then
-               Compiler_State := Analyzing;
-               return Pragmas;
+               Result := Pragmas;
+               exit;
 
             elsif Token /= Tok_Pragma then
                Error_Msg_SC ("only pragmas allowed in configuration file");
-               Compiler_State := Analyzing;
-               return Error_List;
+               Result := Error_List;
+               exit;
 
             else
                P_Node := P_Pragma;
@@ -1690,7 +1692,9 @@ begin
 
       Restore_Opt_Config_Switches (Save_Config_Switches);
       Set_Comes_From_Source_Default (False);
-      Compiler_State := Analyzing;
-      return Empty_List;
    end if;
+
+   Compiler_State      := Analyzing;
+   Current_Source_File := No_Source_File;
+   return Result;
 end Par;
index 5be65af3d8f2708ed7b9301d1cf4ae5df5e5a312..14d71af07468f3a3b7ca51511a5e75e534f0d314 100644 (file)
@@ -1680,7 +1680,7 @@ package body Sem_Ch13 is
                end if;
 
                --  A variable is most likely modified from the outside. Take
-               --  Take the optimistic approach to avoid spurious errors.
+               --  the optimistic approach to avoid spurious errors.
 
                if Ekind (E) = E_Variable then
                   Set_Never_Set_In_Source (E, False);
@@ -3208,13 +3208,15 @@ package body Sem_Ch13 is
                   end if;
 
                   --  Check that the class-wide predicate cannot be applied to
-                  --  an operation of a synchronized type that is not a tagged
-                  --  type. Other legality checks are performed when analyzing
-                  --  the contract of the operation.
+                  --  an operation of a synchronized type. AI12-0182 forbids
+                  --  these altogether, while earlier language semantics made
+                  --  them legal on tagged synchronized types.
+
+                  --  Other legality checks are performed when analyzing the
+                  --  contract of the operation.
 
                   if Class_Present (Aspect)
                     and then Is_Concurrent_Type (Current_Scope)
-                    and then not Is_Tagged_Type (Current_Scope)
                     and then Ekind_In (E, E_Entry, E_Function, E_Procedure)
                   then
                      Error_Msg_Name_1 := Original_Aspect_Pragma_Name (Aspect);
index ee6bcddcaf01f80e1539c6502d717bd9b3d707ee..a3d8f40a9ae5b511eaf7034fa3ef9b28c14aafbb 100644 (file)
@@ -7345,10 +7345,14 @@ package body Sem_Ch8 is
                if Is_Concurrent_Type (T) then
                   if No (Corresponding_Record_Type (Entity (Prefix (N)))) then
 
-                     --  Previous error. Use current type, which at least
-                     --  provides some operations.
+                     --  Previous error. Create a class-wide type for the
+                     --  synchronized type itself, with minimal semantic
+                     --  attributes, to catch other errors in some ACATS tests.
 
-                     C := Entity (Prefix (N));
+                     pragma Assert (Serious_Errors_Detected > 0);
+                     Make_Class_Wide_Type (T);
+                     C := Class_Wide_Type (T);
+                     Set_First_Entity (C, First_Entity (T));
 
                   else
                      C := Class_Wide_Type
index 99d2b1485d46870deac461e753f31e30409a7f96..ae63e172ceeba61deb7854b866e01154cb866c29 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2016, 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- --
@@ -171,7 +171,7 @@ package Sem_Ch8 is
 
    procedure Set_Use (L : List_Id);
    --  Find use clauses that are declarative items in a package declaration
-   --  and  set the potentially use-visible flags of imported entities before
+   --  and set the potentially use-visible flags of imported entities before
    --  analyzing the corresponding package body.
 
    procedure ws;
index 7a996bf975f6b7685e57cf2d7b3f4be63c09559c..77fc34b47c49acf5838c38accc1d3175701b8456 100644 (file)
@@ -9416,7 +9416,8 @@ package body Sem_Prag is
 
                         if Is_Bad_Spelling_Of (Chars (Expr), Name_Enter) then
                            Set_Casing
-                             (Identifier_Casing (Current_Source_File));
+                             (Identifier_Casing
+                               (Source_Index (Current_Sem_Unit)));
                            Error_Msg_String (1 .. Rnm'Length) :=
                              Name_Buffer (1 .. Name_Len);
                            Error_Msg_Strlen := Rnm'Length;