This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Component of protected object cannot be denoted by a selected component


This change adds a missing diagnostic for illegal code attempting to denote
a component of an object of a protected type using a selected component.
Such illegal usage might previously cause a crash of the compiler.

The following compilation must be rejected with the two error messages:
selected_protected_component.adb:6:20: invisible selector "IntC" for type "Parent" defined at selected_protected_component.ads:5
selected_protected_component.adb:7:16: invisible selector "IntC" for type "Parent" defined at selected_protected_component.ads:5

package Selected_Protected_Component is
   type Parent;
   type Ptr is access Parent;

   protected type Parent is
      procedure Delete (O : in out Ptr);
   private
      IntC : Integer;
   end Parent;
end Selected_Protected_Component;

package body Selected_Protected_Component is
   protected body Parent is
      procedure Delete (O : in out Ptr) is
         I : Integer;
      begin
         I := O.all.IntC;
         I := O.IntC;
      end delete;
   end Parent;
end Selected_Protected_Component;

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-06-17  Thomas Quinot  <quinot@adacore.com>

	* sem_ch4.adb (Analyze_Selected_Component): A selected component may
	not denote a (private) component of a protected object.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]