Skip to content

Commit d6710e0

Browse files
committed
RULE-8-7: Only report external identifiers with definitions
1 parent 39f7c94 commit d6710e0

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

c/misra/src/rules/RULE-8-7/ShouldNotBeDefinedWithExternalLinkage.ql

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ predicate isReferencedInTranslationUnit(
4646
from ExternalIdentifiers e, ExternalIdentifierReference a1, TranslationUnit t1
4747
where
4848
not isExcluded(e, Declarations6Package::shouldNotBeDefinedWithExternalLinkageQuery()) and
49+
// Only report external identifiers where we see the definition
50+
e.hasDefinition() and
4951
isReferencedInTranslationUnit(e, a1, t1) and
5052
// Not referenced in any other translation unit
5153
not exists(TranslationUnit t2 |

c/misra/test/rules/RULE-8-7/test.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ extern int i; // COMPLIANT - accessed multiple translation units
22
extern int i1; // NON_COMPLIANT - accessed one translation unit
33
extern void f1(); // COMPLIANT - accessed multiple translation units
44
extern void f2(); // NON_COMPLIANT - accessed one translation unit
5-
extern void f4(); // COMPLIANT - accessed across translation units
5+
extern void f4(); // COMPLIANT - accessed across translation units
6+
extern void f5(); // COMPLIANT - no definition

c/misra/test/rules/RULE-8-7/test1.c

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ void f() {
33
i = 0;
44
f1();
55
f4();
6+
f5();
67
}

0 commit comments

Comments
 (0)