This patch improves the handling of an error in a discriminant specification
for an access discriminant.
Compiling b.ads must yield:
b.ads:3:43: "constant" must appear after "access"
---
package B is
type Constant_Reference (D : constant access Integer) is null record
with Implicit_Dereference => D;
end B;
Tested on x86_64-pc-linux-gnu, committed on trunk
2015-10-20 Ed Schonberg <[email protected]>
* par-ch3.adb (P_Known_Discriminant_Part_Opt): Handle properly
a misplaced "constant" keyword in a discriminant specification.
Index: par-ch3.adb
===================================================================
--- par-ch3.adb (revision 229049)
+++ par-ch3.adb (working copy)
@@ -3030,8 +3030,23 @@
Set_Discriminant_Type
(Specification_Node,
P_Access_Definition (Not_Null_Present));
+
+ -- Catch ouf-of-order keywords
+
+ elsif Token = Tok_Constant then
+ Scan;
+
+ if Token = Tok_Access then
+ Error_Msg_SC ("CONSTANT must appear after ACCESS");
+ Set_Discriminant_Type
+ (Specification_Node,
+ P_Access_Definition (Not_Null_Present));
+
+ else
+ Error_Msg_SC ("misplaced CONSTANT");
+ end if;
+
else
-
Set_Discriminant_Type
(Specification_Node, P_Subtype_Mark);
No_Constraint;