DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B0902: pragma replaced by an aspect

Catalog status: active. Default severity: warning. Stable name: obsolescent-pragma. Family: Syntax and source text.

Since Ada 2012, properties such as Inline, Import, Convention, Pure and No_Return are written as aspects on the declaration they apply to. The pragma forms are obsolescent (Ada RM J.15), and so are GNAT's Precondition and Postcondition pragmas. Verada warns and takes the pragma as the aspect on its target, the declaration it names in the same declarative part (or, for a pragma such as Pure that names nothing, the package). The fix-it removes the pragma and adds the aspect where its target is declared.

Example (Vada)

package Clocks is
   pragma Pure;
   function Ticks return Integer;
   pragma Import (C, Ticks, "ticks");
end Clocks;

What to do

package Clocks with Pure is
   function Ticks return Integer
     with Import, Convention => C, External_Name => "ticks";
end Clocks;

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See syntax and source text, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.