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] |
With this patch, Check_Policy can optionally use the same syntax as Assertion_Policy (the old syntax is still allowed). This test shows error detection 1. package BadCpol is 2. pragma Check_Policy 3. (Junk, Ignore); -- OK 4. pragma Check_Policy 5. (Junk => Ignore); -- OK 6. pragma Check_Policy 7. (Name => Junk, Policy => Ignore); -- OK 8. pragma Check_Policy 9. (Name => Name, Policy => Policy); -- Error | >>> pragma "Check_Policy" does not allow "Name" as check name 10. pragma Check_Policy 11. (Name => Name1, Policy => Ignore); -- OK 12. pragma Check_Policy 13. (Policy, Ignore); -- Error | >>> pragma "Check_Policy" does not allow "Policy" as check name 14. pragma Check_Policy 15. (Policy => Ignore); -- Error | >>> pragma "Check_Policy" does not allow "Policy" as check name 16. pragma Check_Policy 17. (Pre'Class, Ignore); -- OK 18. pragma Check_Policy 19. (Pre'Class => Check); -- OK 20. pragma Check_Policy 21. (Pre => Check, Post); -- Error | >>> pragma argument identifier required here >>> since previous argument had identifier (RM 2.8(4)) >>> missing assertion kind for pragma "Check_Policy" 22. end; The following test compiled and run without -gnata generates the output: OK 1 OK 2 OK 3 1. with Text_IO; use Text_IO; 2. with System.Assertions; 3. use System.Assertions; 4. 5. procedure GoodCpol is 6. X, Y : Integer; 7. 8. begin 9. X := 23; 10. Y := 24; 11. 12. declare 13. pragma Check_Policy (Grumble, Check); 14. begin 15. pragma Check (Grumble, Y < X); | >>> warning: check will fail at run time 16. Put_Line ("Not OK 1"); 17. exception 18. when Assert_Failure => 19. Put_Line ("OK 1"); 20. end; 21. 22. declare 23. pragma Check_Policy (Mumble => Ignore, Grumble => Check); 24. begin 25. pragma Check (Mumble, Y = 100, "Not OK 2"); 26. pragma Check (Grumble, Y < X); 27. Put_Line ("Not OK 3"); 28. exception 29. when Assert_Failure => 30. Put_Line ("OK 2"); 31. 32. end; 33. declare 34. pragma Check_Policy (Mumble => Disable); 35. begin 36. pragma Check (Mumble, "Not OK 4"); 37. Put_Line ("OK 3"); 38. exception 39. when Assert_Failure => 40. Put_Line ("Not OK 5"); 41. end; 42. end GoodCpol; Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-12 Robert Dewar <dewar@adacore.com> * exp_util.adb (Make_Invariant_Call): Use Check_Kind instead of Check_Enabled. * gnat_rm.texi (Check_Policy): Update documentation for new Check_Policy syntax. * sem_prag.adb (Check_Kind): Replaces Check_Enabled (Analyze_Pragma, case Check_Policy): Rework to accomodate new syntax (like Assertion_Policy). * sem_prag.ads (Check_Kind): Replaces Check_Enabled.
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] |