]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
exp_ch6.adb (Expand_Protected_Subprogram_Call): Add guard to better detect call withi...
authorEd Schonberg <schonberg@adacore.com>
Fri, 6 Jan 2017 11:24:02 +0000 (11:24 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 6 Jan 2017 11:24:02 +0000 (12:24 +0100)
2017-01-06  Ed Schonberg  <schonberg@adacore.com>

* exp_ch6.adb (Expand_Protected_Subprogram_Call): Add guard to
better detect call within an entry_wrapper.
* sem_res.adb (Resolve_Call): A protected call within an
entity_wrapper is analyzed in the context of the protected
object but corresponds to a pre-analysis and is not an access
before elaboration.
* sem_attr.adb: Minor reformatting.

From-SVN: r244139

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_res.adb

index 71f2ada9ef2a425a697912b268230786d823e957..5419627eafaae6fa6ba4e58179f3d2c6d7f80e40 100644 (file)
@@ -1,3 +1,13 @@
+2017-01-06  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_ch6.adb (Expand_Protected_Subprogram_Call): Add guard to
+       better detect call within an entry_wrapper.
+       * sem_res.adb (Resolve_Call): A protected call within an
+       entity_wrapper is analyzed in the context of the protected
+       object but corresponds to a pre-analysis and is not an access
+       before elaboration.
+       * sem_attr.adb: Minor reformatting.
+
 2017-01-06  Justin Squirek  <squirek@adacore.com>
 
        * sem_attr.adb (Analyze_Attribute): Modify semantic checks for
index 2a0dac730d8c83620ff040887a0c5ad3ec207320..3f201bb979adc7c8db1c42ec068edf18244cdda6 100644 (file)
@@ -6006,6 +6006,7 @@ package body Exp_Ch6 is
       --  case this must be handled as an inter-object call.
 
       if not In_Open_Scopes (Scop)
+        or else Is_Entry_Wrapper (Current_Scope)
         or else not Is_Entity_Name (Name (N))
       then
          if Nkind (Name (N)) = N_Selected_Component then
index 8d883383d54a5975467340a0c0aaec8a77ac8304..91d740a17ec696138d75c7bd1c4af7d742a3b9d9 100644 (file)
@@ -3840,24 +3840,29 @@ package body Sem_Attr is
       when Attribute_Finalization_Size =>
          Check_E0;
 
+         --  The prefix denotes an object
+
          if Is_Object_Reference (P) then
             Analyze_And_Resolve (P);
             Check_Object_Reference (P);
 
-         --  Redundant type verification for accurate error output
+         --  Check the prefix is a type to avoid an error message stating the
+         --  prefix must exclusively denote one
+
+         elsif Is_Entity_Name (P) and then Is_Type (Entity (P)) then
 
-         elsif not Is_Entity_Name (P)
-           or else not Is_Type (Entity (P))
-         then
-            Error_Attr_P ("prefix of % attribute must be a definite type or" &
-                          " an object");
-         else
             Check_Type;
             Check_Not_Incomplete_Type;
             if Is_Class_Wide_Type (Etype (P)) then
-               Error_Attr_P ("prefix of % attribute cannot be applied to " &
-                             "a class-wide type");
+               Error_Attr_P
+                 ("prefix of % attribute cannot denote a class-wide type");
             end if;
+
+         --  The prefix does not denote an object or a type
+
+         else
+            Error_Attr_P
+              ("prefix of % attribute must be a definite type or an object");
          end if;
 
          Set_Etype (N, Universal_Integer);
index f174ad9497ee8fbdf6d1bcf8022798aecef08638..74dc0e19433f6e8db39d88c3786949e7d10c34a6 100644 (file)
@@ -6287,12 +6287,14 @@ package body Sem_Res is
 
       --  A protected function cannot be called within the definition of the
       --  enclosing protected type, unless it is part of a pre/postcondition
-      --  on another protected operation.
+      --  on another protected operation. This may appear in the entry
+      --  wrapper created for an entry with preconditions.
 
       if Is_Protected_Type (Scope (Nam))
         and then In_Open_Scopes (Scope (Nam))
         and then not Has_Completion (Scope (Nam))
         and then not In_Spec_Expression
+        and then not Is_Entry_Wrapper (Current_Scope)
       then
          Error_Msg_NE
            ("& cannot be called before end of protected definition", N, Nam);