Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd70ea29

Browse files
Address feedback
1 parent99af17c commitd70ea29

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

‎c/misra/src/rules/RULE-11-10/AtomicQualifierAppliedToVoid.ql‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,33 @@ class AtomicVoidType extends Type {
2323
}
2424
}
2525

26-
TypegetNestedType(Typeroot){
27-
result=root
26+
predicateusesAtomicVoid(Typeroot){
27+
rootinstanceofAtomicVoidType
2828
or
29-
exists(DerivedTypederived|derived=root|result=getNestedType(derived.getBaseType()))
29+
usesAtomicVoid(root.(DerivedType).getBaseType())
30+
or
31+
usesAtomicVoid(root.(RoutineType).getReturnType())
32+
or
33+
usesAtomicVoid(root.(RoutineType).getAParameterType())
34+
or
35+
usesAtomicVoid(root.(FunctionPointerType).getReturnType())
36+
or
37+
usesAtomicVoid(root.(FunctionPointerType).getAParameterType())
38+
or
39+
usesAtomicVoid(root.(TypedefType).getBaseType())
40+
}
41+
42+
classExplicitTypeextendsType{
43+
ElementgetDeclaration(stringdescription){
44+
result.(DeclarationEntry).getType()=thisanddescription=result.(DeclarationEntry).getName()
45+
or
46+
result.(CStyleCast).getType()=thisanddescription="Cast"
47+
}
3048
}
3149

32-
fromDeclarationEntrydecl,AtomicVoidTypeatomicVoid
50+
fromElementdecl,ExplicitTypeexplicitType,stringelementDescription
3351
where
3452
notisExcluded(decl, Declarations9Package::atomicQualifierAppliedToVoidQuery())and
35-
atomicVoid=getNestedType(decl.getType())
36-
selectdecl,decl.getName()+" declared with an atomic void type."
53+
decl=explicitType.getDeclaration(elementDescription)and
54+
usesAtomicVoid(explicitType)
55+
selectdecl,elementDescription+" declared with an atomic void type."
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
| test.c:3:15:3:16 | definition of g3 | g3 declared with an atomic void type. |
22
| test.c:10:17:10:18 | definition of m3 | m3 declared with an atomic void type. |
33
| test.c:15:22:15:23 | definition of p2 | p2 declared with an atomic void type. |
4+
| test.c:20:23:20:24 | declaration of f2 | f2 declared with an atomic void type. |
5+
| test.c:21:25:21:26 | declaration of f3 | f3 declared with an atomic void type. |
6+
| test.c:22:14:22:15 | declaration of f4 | f4 declared with an atomic void type. |
7+
| test.c:23:16:23:17 | declaration of f5 | f5 declared with an atomic void type. |
8+
| test.c:27:3:27:19 | (_Atomic(void) *)... | Cast declared with an atomic void type. |

‎c/misra/test/rules/RULE-11-10/test.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@ void f(_Atomic int p1, // COMPLIANT
1515
_Atomicvoid*p2// NON_COMPLIANT
1616
// _Atomic void p3[] // doesn't compile, even though it perhaps should as
1717
// it is adjusted to void*.
18-
) {}
18+
) {}
19+
20+
typedef _Atomicvoid*f2(void);// NON_COMPLIANT
21+
typedef _Atomicvoid*(*f3)(void);// NON_COMPLIANT
22+
typedefvoidf4(_Atomicvoid*);// NON_COMPLIANT
23+
typedefvoid (*f5)(_Atomicvoid*);// NON_COMPLIANT
24+
25+
voidf6() {
26+
(void*)0;// COMPLIANT
27+
(_Atomicvoid*)0;// NON_COMPLIANT
28+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp