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] Use of incomplete types in invariant and predicate expressions.


An incomplete type may appear in the profile of a subprogram used in a
predicate for the type. Analysis of the constructed predicate function will
include a call to the subprogram, and an actual of the full type will be
resolved against an actual of the incomplete view. This patch handles this
construction properly.

Compiling

   gcc -c -gnatc invariant_question.ads

must yield:

invariant_question.ads:12:27: warning:
     predicate check includes a function call that requires a predicate check
invariant_question.ads:12:27: warning: this will result in infinite recursion

---
package Invariant_Question
is

   type Record_T;

   function Is_Valid (X : Record_T) return Boolean;

   type Record_T is record
      X : Boolean;
      Y : Boolean;
   end record with
     Dynamic_Predicate => Is_Valid (Record_T);

end Invariant_Question;

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

2015-01-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch4.adb (Analyze_One_Call): If formal has an incomplete
	type and actual has the corresponding full view, there is no
	error, but a case of use of incomplete type in a predicate or
	invariant expression.

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]