This lets the compiler give a proper error message instead.
gcc/ada/
* contracts.adb (Contract_Error): New exception.
(Add_Contract_Item): Raise Contract_Error instead of Program_Error.
(Add_Generic_Contract_Pragma): Deal with Contract_Error.
package body Contracts is
package body Contracts is
+ Contract_Error : exception;
+ -- This exception is raised by Add_Contract_Item when it is invoked on an
+ -- invalid pragma. Note that clients of the package must filter them out
+ -- before invoking Add_Contract_Item, so it should not escape the package.
+
procedure Analyze_Package_Instantiation_Contract (Inst_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of package
-- instantiation Inst_Id as if they appear at the end of a declarative
procedure Analyze_Package_Instantiation_Contract (Inst_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of package
-- instantiation Inst_Id as if they appear at the end of a declarative
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Entry bodies, the applicable pragmas are:
end if;
-- Entry bodies, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Entry or subprogram declarations, the applicable pragmas are:
end if;
-- Entry or subprogram declarations, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Packages or instantiations, the applicable pragmas are:
end if;
-- Packages or instantiations, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Package bodies, the applicable pragmas are:
end if;
-- Package bodies, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- The four volatility refinement pragmas are ok for all types.
end if;
-- The four volatility refinement pragmas are ok for all types.
-- The pragma is not a proper contract item
-- The pragma is not a proper contract item
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Task bodies, the applicable pragmas are:
end if;
-- Task bodies, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
-- Task units, the applicable pragmas are:
end if;
-- Task units, the applicable pragmas are:
-- The pragma is not a proper contract item
else
-- The pragma is not a proper contract item
else
end if;
end Add_Contract_Item;
end if;
end Add_Contract_Item;
else
Add_Contract_Item (Prag, Templ_Id);
end if;
else
Add_Contract_Item (Prag, Templ_Id);
end if;
+
+ exception
+ -- We do not stop the compilation at this point in the case of an
+ -- invalid pragma because it will be properly diagnosed afterward.
+
+ when Contract_Error => null;
end Add_Generic_Contract_Pragma;
-- Local variables
end Add_Generic_Contract_Pragma;
-- Local variables