summaryrefslogtreecommitdiff
path: root/gcc/ada/par-ch3.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-24 16:30:08 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2014-02-24 16:30:08 +0000
commitebadca1de6017da9639a8a086a731b1ee505cdf9 (patch)
tree6aec8ad587cff01ba9f05b72d71f56e0fad6ff70 /gcc/ada/par-ch3.adb
parentcab1b01ebef65249e1d316261b3e0003d6a2b433 (diff)
downloadgcc-ebadca1de6017da9639a8a086a731b1ee505cdf9.tar.gz
2014-02-24 Robert Dewar <dewar@adacore.com>
* sinfo.ads, sem_ch12.adb, sem_res.adb, sem_ch4.adb, par-ch12.adb: Minor reformatting. * atree.ads, atree.adb (Node35): New function. (Set_Node35): New procedure. * debug.adb: Define new debug flag -gnatd.X. * einfo.ads, einfo.adb (Import_Pragma): New field. * freeze.adb (Wrap_Imported_Procedure): New procedure (not really active yet, has to be activated with -gnatd.X. * sem_prag.adb (Set_Imported): Set new Import_Pragma field (Set_Imported): Don't set Is_Public (see Freeze.Wrap_Imported_Subprogram) * par-ch3.adb (P_Component_List): Handle unexpected null component. 2014-02-24 Yannick Moy <moy@adacore.com> * sem_ch3.adb: Correct reference to SPARK RM in error messages. * gnat_rm.texi: Correct documentation of attribute Update. 2014-02-24 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb (Analyze_Iterator_Specification): Reject container iterator in older versions of Ada. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208076 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/par-ch3.adb')
-rw-r--r--gcc/ada/par-ch3.adb123
1 files changed, 68 insertions, 55 deletions
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index c09a68fbb2f..11e9f81c4d1 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -3270,87 +3270,100 @@ package body Ch3 is
Component_List_Node : Node_Id;
Decls_List : List_Id;
Scan_State : Saved_Scan_State;
+ Null_Loc : Source_Ptr;
begin
Component_List_Node := New_Node (N_Component_List, Token_Ptr);
Decls_List := New_List;
+ -- Handle null
+
if Token = Tok_Null then
+ Null_Loc := Token_Ptr;
Scan; -- past NULL
TF_Semicolon;
P_Pragmas_Opt (Decls_List);
- Set_Null_Present (Component_List_Node, True);
- return Component_List_Node;
- else
- P_Pragmas_Opt (Decls_List);
+ -- If we have an END or WHEN now, everything is fine, otherwise we
+ -- complain about the null, ignore it, and scan for more components.
- if Token /= Tok_Case then
- Component_Scan_Loop : loop
- P_Component_Items (Decls_List);
- P_Pragmas_Opt (Decls_List);
-
- exit Component_Scan_Loop when Token = Tok_End
- or else Token = Tok_Case
- or else Token = Tok_When;
-
- -- We are done if we do not have an identifier. However, if
- -- we have a misspelled reserved identifier that is in a column
- -- to the right of the record definition, we will treat it as
- -- an identifier. It turns out to be too dangerous in practice
- -- to accept such a mis-spelled identifier which does not have
- -- this additional clue that confirms the incorrect spelling.
-
- if Token /= Tok_Identifier then
- if Start_Column > Scope.Table (Scope.Last).Ecol
- and then Is_Reserved_Identifier
- then
- Save_Scan_State (Scan_State); -- at reserved id
- Scan; -- possible reserved id
+ if Token = Tok_End or else Token = Tok_When then
+ Set_Null_Present (Component_List_Node, True);
+ return Component_List_Node;
+ else
+ Error_Msg ("NULL component only allowed in null record", Null_Loc);
+ end if;
+ end if;
- if Token = Tok_Comma or else Token = Tok_Colon then
- Restore_Scan_State (Scan_State);
- Scan_Reserved_Identifier (Force_Msg => True);
+ -- Scan components for non-null record
- -- Note reserved identifier used as field name after
- -- all because not followed by colon or comma
+ P_Pragmas_Opt (Decls_List);
- else
- Restore_Scan_State (Scan_State);
- exit Component_Scan_Loop;
- end if;
+ if Token /= Tok_Case then
+ Component_Scan_Loop : loop
+ P_Component_Items (Decls_List);
+ P_Pragmas_Opt (Decls_List);
- -- Non-identifier that definitely was not reserved id
+ exit Component_Scan_Loop when Token = Tok_End
+ or else Token = Tok_Case
+ or else Token = Tok_When;
+
+ -- We are done if we do not have an identifier. However, if we
+ -- have a misspelled reserved identifier that is in a column to
+ -- the right of the record definition, we will treat it as an
+ -- identifier. It turns out to be too dangerous in practice to
+ -- accept such a mis-spelled identifier which does not have this
+ -- additional clue that confirms the incorrect spelling.
+
+ if Token /= Tok_Identifier then
+ if Start_Column > Scope.Table (Scope.Last).Ecol
+ and then Is_Reserved_Identifier
+ then
+ Save_Scan_State (Scan_State); -- at reserved id
+ Scan; -- possible reserved id
+
+ if Token = Tok_Comma or else Token = Tok_Colon then
+ Restore_Scan_State (Scan_State);
+ Scan_Reserved_Identifier (Force_Msg => True);
+
+ -- Note reserved identifier used as field name after all
+ -- because not followed by colon or comma.
else
+ Restore_Scan_State (Scan_State);
exit Component_Scan_Loop;
end if;
+
+ -- Non-identifier that definitely was not reserved id
+
+ else
+ exit Component_Scan_Loop;
end if;
- end loop Component_Scan_Loop;
- end if;
+ end if;
+ end loop Component_Scan_Loop;
+ end if;
- if Token = Tok_Case then
- Set_Variant_Part (Component_List_Node, P_Variant_Part);
+ if Token = Tok_Case then
+ Set_Variant_Part (Component_List_Node, P_Variant_Part);
- -- Check for junk after variant part
+ -- Check for junk after variant part
- if Token = Tok_Identifier then
- Save_Scan_State (Scan_State);
- Scan; -- past identifier
+ if Token = Tok_Identifier then
+ Save_Scan_State (Scan_State);
+ Scan; -- past identifier
- if Token = Tok_Colon then
- Restore_Scan_State (Scan_State);
- Error_Msg_SC ("component may not follow variant part");
- Discard_Junk_Node (P_Component_List);
+ if Token = Tok_Colon then
+ Restore_Scan_State (Scan_State);
+ Error_Msg_SC ("component may not follow variant part");
+ Discard_Junk_Node (P_Component_List);
- elsif Token = Tok_Case then
- Restore_Scan_State (Scan_State);
- Error_Msg_SC ("only one variant part allowed in a record");
- Discard_Junk_Node (P_Component_List);
+ elsif Token = Tok_Case then
+ Restore_Scan_State (Scan_State);
+ Error_Msg_SC ("only one variant part allowed in a record");
+ Discard_Junk_Node (P_Component_List);
- else
- Restore_Scan_State (Scan_State);
- end if;
+ else
+ Restore_Scan_State (Scan_State);
end if;
end if;
end if;