diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-05-02 10:32:34 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-05-02 10:32:34 +0200 |
commit | c0e938d0cdbc3ae9b202e855d9f7ccea96138344 (patch) | |
tree | 3806acc558ed9137664e033b2109e2fd981f3a13 /gcc/ada/sem_ch4.adb | |
parent | 99bba92c35b2ea997f0e7f326a921faf23c0b45c (diff) | |
download | gcc-c0e938d0cdbc3ae9b202e855d9f7ccea96138344.zip gcc-c0e938d0cdbc3ae9b202e855d9f7ccea96138344.tar.gz gcc-c0e938d0cdbc3ae9b202e855d9f7ccea96138344.tar.bz2 |
[multiple changes]
2017-05-02 Hristian Kirtchev <kirtchev@adacore.com>
* exp_attr.adb: Minor reformatting.
2017-05-02 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Analyze_Selected_Component): Improve error
detection for illegal references to private components or
operations of a protected type in the body of the type.
From-SVN: r247469
Diffstat (limited to 'gcc/ada/sem_ch4.adb')
-rw-r--r-- | gcc/ada/sem_ch4.adb | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 4f2c1fd..12f930d 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4311,6 +4311,7 @@ package body Sem_Ch4 is Act_Decl : Node_Id; Comp : Entity_Id; Has_Candidate : Boolean := False; + Hidden_Comp : Entity_Id; In_Scope : Boolean; Is_Private_Op : Boolean; Parent_N : Node_Id; @@ -4850,6 +4851,7 @@ package body Sem_Ch4 is -- can only be a direct name or an expanded name. Set_Etype (Sel, Any_Type); + Hidden_Comp := Empty; In_Scope := In_Open_Scopes (Prefix_Type); Is_Private_Op := False; @@ -4900,6 +4902,10 @@ package body Sem_Ch4 is Has_Candidate := True; else + if Ekind (Comp) = E_Component then + Hidden_Comp := Comp; + end if; + goto Next_Comp; end if; @@ -4921,6 +4927,20 @@ package body Sem_Ch4 is end if; <<Next_Comp>> + if Comp = First_Private_Entity (Type_To_Use) then + if Etype (Sel) /= Any_Type then + + -- We have a candiate. + exit; + + else + -- Indicate that subsequent operations are private, + -- for better error reporting. + + Is_Private_Op := True; + end if; + end if; + Next_Entity (Comp); exit when not In_Scope and then @@ -4968,11 +4988,20 @@ package body Sem_Ch4 is elsif In_Scope and then Is_Object_Reference (Original_Node (Prefix (N))) + and then Comes_From_Source (N) and then Is_Private_Op then - Error_Msg_NE - ("invalid reference to private operation of some object of " - & "type &", N, Type_To_Use); + if Present (Hidden_Comp) then + Error_Msg_NE + ("invalid reference to private component of object " + & "of type &", N, Type_To_Use); + + else + Error_Msg_NE + ("invalid reference to private operation of some object of " + & "type &", N, Type_To_Use); + end if; + Set_Entity (Sel, Any_Id); Set_Etype (Sel, Any_Type); return; |