-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- we set Force_Msg to True, since we want at least one message for each
-- separate declaration (but not use) of a reserved identifier.
- if Token = Tok_Identifier then
-
- -- Ada 2005 (AI-284): Compiling in Ada95 mode we warn that INTERFACE,
- -- OVERRIDING, and SYNCHRONIZED are new reserved words. Note that
- -- in the case where these keywords are misused in Ada 95 mode,
- -- this routine will generally not be called at all.
-
- if Ada_Version = Ada_95
- and then Warn_On_Ada_2005_Compatibility
- then
- if Token_Name = Name_Overriding
- or else Token_Name = Name_Synchronized
- or else (Token_Name = Name_Interface
- and then Prev_Token /= Tok_Pragma)
- then
- Error_Msg_N ("& is a reserved word in Ada 2005?", Token_Node);
- end if;
- end if;
+ -- Duplication should be removed, common code should be factored???
- -- Similarly, warn about Ada 2012 reserved words
-
- if Ada_Version in Ada_95 .. Ada_2005
- and then Warn_On_Ada_2012_Compatibility
- then
- if Token_Name = Name_Some then
- Error_Msg_N ("& is a reserved word in Ada 2012?", Token_Node);
- end if;
- end if;
+ if Token = Tok_Identifier then
+ Check_Future_Keyword;
-- If we have a reserved identifier, manufacture an identifier with
-- a corresponding name after posting an appropriate error message
Error_Msg_SP
("(Ada 83) limited record declaration not allowed!");
- -- In Ada2005, "abstract limited" can appear before "new",
+ -- In Ada 2005, "abstract limited" can appear before "new",
-- but it cannot be part of an untagged record declaration.
elsif Abstract_Present
--------------------------------
-- SUBTYPE_DECLARATION ::=
- -- subtype DEFINING_IDENTIFIER is [NULL_EXCLUSION] SUBTYPE_INDICATION;
+ -- subtype DEFINING_IDENTIFIER is [NULL_EXCLUSION] SUBTYPE_INDICATION
+ -- {ASPECT_SPECIFICATIONS];
-- The caller has checked that the initial token is SUBTYPE
begin
Constr_Node := P_Constraint_Opt;
- if No (Constr_Node) then
+ if No (Constr_Node)
+ or else
+ (Nkind (Constr_Node) = N_Range_Constraint
+ and then Nkind (Range_Expression (Constr_Node)) = N_Error)
+ then
return Subtype_Mark;
else
if Not_Null_Present then
Scan; -- past RANGE
end if;
- Expr_Node := P_Expression;
- Check_Simple_Expression (Expr_Node);
- Set_Low_Bound (Typedef_Node, Expr_Node);
- T_Dot_Dot;
- Expr_Node := P_Expression;
- Check_Simple_Expression (Expr_Node);
- Set_High_Bound (Typedef_Node, Expr_Node);
+ Expr_Node := P_Expression_Or_Range_Attribute;
+
+ -- Range case (not permitted by the grammar, this is surprising but
+ -- the grammar in the RM is as quoted above, and does not allow Range).
+
+ if Expr_Form = EF_Range_Attr then
+ Error_Msg_N
+ ("Range attribute not allowed here, use First .. Last", Expr_Node);
+ Set_Low_Bound (Typedef_Node, Expr_Node);
+ Set_Attribute_Name (Expr_Node, Name_First);
+ Set_High_Bound (Typedef_Node, Copy_Separate_Tree (Expr_Node));
+ Set_Attribute_Name (High_Bound (Typedef_Node), Name_Last);
+
+ -- Normal case of explicit range
+
+ else
+ Check_Simple_Expression (Expr_Node);
+ Set_Low_Bound (Typedef_Node, Expr_Node);
+ T_Dot_Dot;
+ Expr_Node := P_Expression;
+ Check_Simple_Expression (Expr_Node);
+ Set_High_Bound (Typedef_Node, Expr_Node);
+ end if;
+
return Typedef_Node;
end P_Signed_Integer_Type_Definition;
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
end if;
- if Aliased_Present then
- Error_Msg_SP ("ALIASED not allowed here");
- end if;
+ -- AI95-406 makes "aliased" legal (and useless) in this context so
+ -- followintg code which used to be needed is commented out.
+
+ -- if Aliased_Present then
+ -- Error_Msg_SP ("ALIASED not allowed here");
+ -- end if;
Set_Subtype_Indication (CompDef_Node, Empty);
Set_Aliased_Present (CompDef_Node, False);
Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
end if;
- if Aliased_Present then
- Error_Msg_SP ("ALIASED not allowed here");
- end if;
+ -- AI95-406 makes "aliased" legal (and useless) here, so the
+ -- following code which used to be required is commented out.
+
+ -- if Aliased_Present then
+ -- Error_Msg_SP ("ALIASED not allowed here");
+ -- end if;
Set_Subtype_Indication (CompDef_Node, Empty);
Set_Aliased_Present (CompDef_Node, False);
P_Identifier_Declarations (Decls, Done, In_Spec);
end if;
- -- Ada2005: A subprogram declaration can start with "not" or
+ -- Ada 2005: A subprogram declaration can start with "not" or
-- "overriding". In older versions, "overriding" is handled
-- like an identifier, with the appropriate messages.