@@ -42,8 +42,23 @@ fun match_signature(child_prim, parent_prim, child_type, parent_type) =
4242 }
4343}
4444
45- @check(category="Style", subcategory="Readability", message="Missing overriding mark")
46- fun overriding_marks(node) =
45+ fun is_overriding_subprogram(node) =
46+ |" Returns whether the node passed as argument corresponds to an overriding
47+ |" subprogram
48+ node is (BasicSubpDecl | BaseSubpBody) (
49+ p_subp_spec_or_null(): BaseSubpSpec(
50+ p_primitive_subp_first_type(): t@TypeDecl(
51+ p_base_type(): bt@TypeDecl(
52+ p_get_primitives(): primitives@(not null)
53+ when stdlib.any([p for p in primitives if match_signature(node, p, t, bt)])
54+ )
55+ )
56+ )
57+ )
58+
59+
60+ @check(category="Style", subcategory="Readability", message="missing overriding indicator")
61+ fun overriding_indicators(node) =
4762 |" Check that overriding subprograms are explicitly marked as such.
4863 |"
4964 |" This applies to all subprograms of a derived type that override a
@@ -70,18 +85,15 @@ fun overriding_marks(node) =
7085 |" procedure Prim (Self : B) is null; -- FLAG
7186 |" end Foo;
7287 # Select primitives subprograms
73- node is (BasicSubpDecl | BaseSubpBody) (
74- p_subp_spec_or_null(): BaseSubpSpec(
75- p_primitive_subp_first_type(): t@TypeDecl(
76- p_base_type(): bt@TypeDecl(
77- p_get_primitives(): primitives@(not null)
78- when stdlib.any([p for p in primitives if match_signature(node, p, t, bt)])
79- )
80- )
81- ),
82- f_overriding: OverridingUnspecified
88+ (
89+ node is (BasicSubpDecl | BaseSubpBody) (f_overriding: OverridingUnspecified)
90+ when is_overriding_subprogram(node)
8391 )
8492
8593 # Body stubs can also take an "overriding" indicator. In that case, check
8694 # the body.
87- or node is SubpBodyStub(p_previous_part_for_decl(): dcl) when overriding_marks(dcl)
95+ or (
96+ node is SubpBodyStub(p_previous_part_for_decl(): dcl,
97+ f_overriding: OverridingUnspecified)
98+ when is_overriding_subprogram(dcl)
99+ )
0 commit comments