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] Improve error message on static vs non-static predicate use


This patch enhances the error message related to the use of a bad predicate.
The compiler now advises on how to remedy the issue if the context warrants it.

------------
-- Source --
------------

--  main.adb

with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Main is
   subtype Even is Integer range 1 .. 10 with
     Dynamic_Predicate => Even in 2 | 4 | 6 | 8 | 10;
begin
   for E in Even loop
      Put (E, 3);
   end loop;
end Main;

----------------------------
-- Compilation and output --
----------------------------

$ gcc -c -gnat12 main.adb
main.adb:7:13: cannot use subtype "Even" with non-static predicate for loop
  iteration
main.adb:7:13: predicate of "Even" should be marked static

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

2013-04-25  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_case.adb (Analyze_Choices): Enhance the error message
	given on a bad use of subtype predicate.
	* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Enhance
	the error message given on a bad use of subtype predicate.
	* sem_util.adb (Bad_Predicated_Subtype_Use): Add formal parameter
	Suggest_Static. Emit an extra error message advising how to
	remedy the bad use of the predicate if the context warrants it.
	* sem_util.ads (Bad_Predicated_Subtype_Use): Add formal parameter
	Suggest_Static along with a comment explaining its usage.

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]