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

Appearance settings

Commit 60f2824

Browse filesBrowse files
committed
update test.c for 6-1 and 6-2
1. `compilant` and `non_compliant` to uppercase 2. mark `int x1` of 6-2 to non_compliant 3. `clang-format` all
1 parent c0ba262 commit 60f2824
Copy full SHA for 60f2824

File tree

2 files changed

+19
-15
lines changed
Filter options

2 files changed

+19
-15
lines changed

‎c/misra/test/rules/RULE-6-1/test.c

Copy file name to clipboardExpand all lines: c/misra/test/rules/RULE-6-1/test.c
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ typedef unsigned int UINT16;
33
enum Color { R, G, B };
44

55
struct SampleStruct {
6-
int x1 : 2; // NON_COMPLIANT - not explicitly signed or unsigned
7-
unsigned int x2 : 2; // COMPILANT - explicitly unsigned (example in the doc)
6+
int x1 : 2; // NON_COMPLIANT - not explicitly signed or unsigned
7+
unsigned int x2 : 2; // COMPILANT - explicitly unsigned
88
signed int x3 : 2; // COMPILANT - explicitly signed
9-
UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type
10-
signed long x5 : 2; // NON_COMPLIANT - cannot declare bit field for long, even if it's signed
11-
signed char x6 : 2; // NON_COMPILANT - cannot declare bit field for char, even if it's signed
9+
UINT16 x4 : 2; // COMPLIANT - type alias resolves to a compliant type
10+
signed long x5 : 2; // NON_COMPLIANT - cannot declare bit field for long, even
11+
// if it's signed
12+
signed char x6 : 2; // NON_COMPILANT - cannot declare bit field for char, even
13+
// if it's signed
1214
enum Color x7 : 3; // NON_COMPILANT - cannot declare bit field for enum
13-
} sample_struct;
15+
} sample_struct;

‎c/misra/test/rules/RULE-6-2/test.c

Copy file name to clipboard
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#include <stdint.h>
22

33
struct SampleStruct {
4-
int x1 : 1; // compilant: single-bit named field without signed declaration
5-
signed int x2 : 1; // non_compilant: single-bit named field with a signed type
4+
int x1 : 1; // NON_COMPILANT: very likely be signed, but if it's not, the
5+
// query will automatically handle it since we use signed(), not
6+
// isExplicitlySigned().
7+
signed int x2 : 1; // NON_COMPILANT: single-bit named field with a signed type
68
signed char
7-
x3 : 1; // non_compilant: single-bit named field with a signed type
9+
x3 : 1; // NON_COMPILANT: single-bit named field with a signed type
810
signed short
9-
x4 : 1; // non_compilant: single-bit named field with a signed type
11+
x4 : 1; // NON_COMPILANT: single-bit named field with a signed type
1012
unsigned int
11-
x5 : 1; // compilant: single-bit named field but with an unsigned type
12-
signed int x6 : 2; // compilant: named field with a signed type but declared
13+
x5 : 1; // COMPILANT: single-bit named field but with an unsigned type
14+
signed int x6 : 2; // COMPILANT: named field with a signed type but declared
1315
// to carry more than 1 bit
14-
int32_t x7 : 1; // non_compilant: single-bit named field that has single-bit
16+
int32_t x7 : 1; // NON_COMPILANT: single-bit named field that has single-bit
1517
// bit-field, even though technically it has 32 bits
16-
signed char : 1; // compilant: single-bit bit-field but unnamed
17-
} sample_struct;
18+
signed char : 1; // COMPILANT: single-bit bit-field but unnamed
19+
} sample_struct;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.