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

Commitf7cd25e

Browse files
committed
BuiltInTypeRules: Handle bit fields in switch cases
1 parentbc7bf51 commitf7cd25e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎cpp/misra/src/codingstandards/cpp/misra/BuiltInTypeRules.qll‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,16 @@ predicate isPreConversionAssignment(Expr source, Type targetType, string context
243243
exists(SwitchCasecase,SwitchStmtswitch|
244244
case.getExpr()=sourceand
245245
case.getSwitchStmt()=switchand
246-
targetType=switch.getExpr().getFullyConverted().getType()and
247246
context="switch case"
247+
|
248+
ifswitch.getExpr().(FieldAccess).getTarget()instanceofBitField
249+
then
250+
// For the MISRA type rules we treat bit fields as a special case
251+
targetType=getBitFieldType(switch.getExpr().(FieldAccess).getTarget())
252+
else
253+
// Regular variable initialization
254+
// Get the type of the switch expression, which is the type of the case expression
255+
targetType=switch.getExpr().getFullyConverted().getType()
248256
)
249257
or
250258
// Class aggregate literal initialization

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp