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] Illegal use of current instance in attribute reference


The current instance of a type in an aspect specification is an object of
the type. If the type is scalar, it cannot be the prefix of an attribute
reference such as 'First,  whose prefix must an array object (even though it
can be a scalar type in other contexts).

Compiling foo.adb must yield:
foo.adb:3:29:
  prefix of "First" attribute cannot be the current instance of a scalar type
foo.adb:6:29:
  prefix of "First" attribute cannot be the current instance of a scalar type

---
procedure Foo is
    type T_Data_Sending_Frequency is new Natural
      with Default_Value => T_Data_Sending_Frequency'First;

    type Infrequent is new Natural
      with Default_Value => Infrequent'First + 3;

begin
    null;
end;

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

2016-04-20  Ed Schonberg  <schonberg@adacore.com>

	* sem_attr.adb (Check_Type): Reject an attribute reference in
	an aspect expression, when the prefix of the reference is the
	current instance of the type to which the aspect applies.

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]