This is the mail archive of the 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] Constraints on class-wide types are ignored

A class-wide type has anonymous discriminants, because type extensions can
add discriminants at will.  A constraint on a class-wide type is thus a partial
constraint that applies only to the known discriminants of the root type. Such
a partial constraint is a language pathology that the ARG has decided not to
test. This patch simply discards such a constraint on an access type, so that
the designated type includes all (unconstrained) extensions of the root type.

The following must compile with the warning: warning: constraint on class-wide type ignored

package Volumes is
   type VolumeWidgetType (Stereo : boolean) is tagged
        IsStereo : boolean := Stereo;
      end record;

   type VolumeWidget is access all VolumeWidgetType'Class;

   Mic1 : VolumeWidget (Stereo => False);

end Volumes;

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

2013-09-10  Ed Schonberg  <>

	* sem_ch3.adb (Process_Subtype): Discard constraint on access
	to class-wide type. Such constraints are not supported and are
	considered a language pathology.

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]