Skip to content

Commit f1fc28e

Browse files
Address feedback
1 parent 973fc3a commit f1fc28e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

cpp/misra/src/rules/RULE-8-0-1/MissingPrecedenceClarifyingParenthesis.ql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ import cpp
1818
import codingstandards.cpp.misra
1919
import codingstandards.cpp.AlertReporting
2020

21+
/**
22+
* MISRA operator precedence levels are not an exact match with standard C++ operator precedence,
23+
* and therefore defined in this class.
24+
*
25+
* For example, MISRA treats ternary, assigment, and throw operators as having separate precedence
26+
* levels, while in C++17 they all have the same precedence. Additionally, MISRA treats all
27+
* operators not in the list below as having the same precedence, while in C++17 some of the
28+
* remaining operators (*x, x[], x++, ++x) have different precedences than others.
29+
*
30+
* This list is defined in the MISRA specification.
31+
*/
2132
class MisraPrecedenceExpr instanceof Expr {
2233
int precedence;
2334
string operator;

cpp/misra/test/rules/RULE-8-0-1/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ void f9() {
205205
}
206206

207207
// Test macros
208-
#define UNSAFE_MACRO(x, y, z) x + y *z // NON_COMPLIANT macro definition
209-
#define SAFE_MACRO(x, y, z) x + (y * z) // COMPLIANT macro definition
208+
#define UNSAFE_MACRO(x, y, z) x + y *z // Non compliant at usage sites
209+
#define SAFE_MACRO(x, y, z) x + (y * z) // Compliant at usage sites
210210

211211
void f10() {
212212
int l1 = 1, l2 = 2, l3 = 3;

0 commit comments

Comments
 (0)