Skip to content

Commit 0b9e2cb

Browse files
committed
Rule 7.0.2: Treat nullptr_t as a pointer for this rule
1 parent 3575db1 commit 0b9e2cb

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cpp/misra/src/rules/RULE-7-0-2/NoImplicitBoolConversion.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ predicate isBitFieldOfSizeOne(Expr expr) {
4343

4444
predicate isPointerType(Type t) {
4545
t.getUnspecifiedType() instanceof PointerType or
46-
t.getUnspecifiedType() instanceof PointerToMemberType
46+
t.getUnspecifiedType() instanceof PointerToMemberType or
47+
t.getUnspecifiedType() instanceof NullPointerType
4748
}
4849

4950
from Element e, string reason

cpp/misra/test/rules/RULE-7-0-2/NoImplicitBoolConversion.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
| test.cpp:99:30:99:31 | (bool)... | Conversion from 'int32_t' to 'bool'. |
1010
| test.cpp:112:12:112:13 | (bool)... | Conversion from 'int32_t' to 'bool'. |
1111
| test.cpp:127:13:127:16 | (bool)... | Conversion from 'int32_t *' to 'bool'. |
12-
| test.cpp:130:7:130:13 | (bool)... | Conversion from 'decltype(nullptr)' to 'bool'. |
1312
| test.cpp:135:13:135:32 | static_cast<bool>... | Conversion from 'int' to 'bool'. |
1413
| test.cpp:136:13:136:14 | (bool)... | Conversion from 'uint8_t' to 'bool'. |
1514
| test.cpp:148:13:148:13 | call to operator bool | Conversion operator call from 'TestClassImplicit' to 'bool'. |

cpp/misra/test/rules/RULE-7-0-2/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void test_pointer_conversions() {
127127
bool l1 = f3(); // NON_COMPLIANT
128128
bool l2 = f3() != nullptr; // COMPLIANT
129129

130-
if (nullptr) { // NON_COMPLIANT
130+
if (nullptr) { // COMPLIANT
131131
}
132132
}
133133

0 commit comments

Comments
 (0)