===================================================================
@@ -5060,12 +5060,15 @@
Analyze_And_Resolve (Expr);
end if;
- if Is_OK_Static_Expression (Expr) then
- return;
+ -- An expression cannot be considered static if its resolution failed
+ -- or if it erroneous. Stop the analysis of the related pragma.
- elsif Etype (Expr) = Any_Type then
+ if Etype (Expr) = Any_Type or else Error_Posted (Expr) then
raise Pragma_Exit;
+ elsif Is_OK_Static_Expression (Expr) then
+ return;
+
-- An interesting special case, if we have a string literal and we
-- are in Ada 83 mode, then we allow it even though it will not be
-- flagged as static. This allows the use of Ada 95 pragmas like
@@ -5077,12 +5080,6 @@
then
return;
- -- Static expression that raises Constraint_Error. This has already
- -- been flagged, so just exit from pragma processing.
-
- elsif Is_OK_Static_Expression (Expr) then
- raise Pragma_Exit;
-
-- Finally, we have a real error
else
===================================================================
@@ -1974,7 +1974,12 @@
procedure Resolution_Failed is
begin
Patch_Up_Value (N, Typ);
+
+ -- Set the type to the desired one to minimize cascaded errors. Note
+ -- that this is an approximation and does not work in all cases.
+
Set_Etype (N, Typ);
+
Debug_A_Exit ("resolving ", N, " (done, resolution failed)");
Set_Is_Overloaded (N, False);
===================================================================
@@ -1022,22 +1022,30 @@
Resolve (Nam, T);
+ -- Do not perform the legality checks below when the resolution of
+ -- the renaming name failed because the associated type is Any_Type.
+
+ if Etype (Nam) = Any_Type then
+ null;
+
-- Ada 2005 (AI-231): In the case where the type is defined by an
-- access_definition, the renamed entity shall be of an access-to-
-- constant type if and only if the access_definition defines an
-- access-to-constant type. ARM 8.5.1(4)
- if Constant_Present (Access_Definition (N))
+ elsif Constant_Present (Access_Definition (N))
and then not Is_Access_Constant (Etype (Nam))
then
- Error_Msg_N ("(Ada 2005): the renamed object is not "
- & "access-to-constant (RM 8.5.1(6))", N);
+ Error_Msg_N
+ ("(Ada 2005): the renamed object is not access-to-constant "
+ & "(RM 8.5.1(6))", N);
elsif not Constant_Present (Access_Definition (N))
and then Is_Access_Constant (Etype (Nam))
then
- Error_Msg_N ("(Ada 2005): the renamed object is not "
- & "access-to-variable (RM 8.5.1(6))", N);
+ Error_Msg_N
+ ("(Ada 2005): the renamed object is not access-to-variable "
+ & "(RM 8.5.1(6))", N);
end if;
if Is_Access_Subprogram_Type (Etype (Nam)) then