* [Ada] Fix crash for bad Depends operand
@ 2014-01-24 11:42 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2014-01-24 11:42 UTC (permalink / raw)
To: gcc-patches; +Cc: Robert Dewar
[-- Attachment #1: Type: text/plain, Size: 981 bytes --]
This fixes a failure to properly diagnose a bad Depends operand.
The following program used to provoke this crash:
1. procedure DependsCrash is
2. type R is record
3. B : Boolean;
4. end record;
5.
6. procedure Test (X : R; B : out Boolean)
|
>>> item "X" must appear in at least one input list
of aspect Depends
7. with Depends => (B => X.B);
|
>>> item must denote variable, state or formal
parameter
8.
9. procedure Test (X : R; B : out Boolean)
10. is begin null; end;
11.
12. begin
13. null;
14. end DependsCrash;
Tested on x86_64-pc-linux-gnu, committed on trunk
2014-01-24 Robert Dewar <dewar@adacore.com>
* sem_prag.adb (Analyze_Input_Output): Add missing error check
for junk operand.
* sem_util.adb (Is_Refined_State): Add defense against junk
tree from error.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1111 bytes --]
Index: sem_prag.adb
===================================================================
--- sem_prag.adb (revision 207026)
+++ sem_prag.adb (working copy)
@@ -783,9 +783,9 @@
Item_Id := Entity_Of (Item);
- Record_Possible_Body_Reference (Item, Item_Id);
+ if Present (Item_Id) then
+ Record_Possible_Body_Reference (Item, Item_Id);
- if Present (Item_Id) then
if Ekind_In (Item_Id, E_Abstract_State,
E_In_Parameter,
E_In_Out_Parameter,
Index: sem_util.adb
===================================================================
--- sem_util.adb (revision 207026)
+++ sem_util.adb (working copy)
@@ -3723,6 +3723,12 @@
else
Item_Id := Entity_Of (Item);
+ -- Defend against junk
+
+ if No (Item_Id) then
+ return False;
+ end if;
+
return
Ekind (Item_Id) = E_Abstract_State
and then Has_Visible_Refinement (Item_Id);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-01-24 11:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-24 11:42 [Ada] Fix crash for bad Depends operand Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).