Skip to content

Commit 2ed4443

Browse files
committed
Deduplicate the test cases and update the expected results.
1 parent 8002997 commit 2ed4443

File tree

2 files changed

+54
-95
lines changed

2 files changed

+54
-95
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
| test.cpp:4:22:4:24 | 99 | Assignment of an non-integer type to variable $@ which is a variable with an explicitly signed char type | test.cpp:4:17:4:18 | a1 | a1 |
2-
| test.cpp:6:20:6:22 | 99 | Assignment of an non-integer type to variable $@ which is a variable with an explicitly signed char type | test.cpp:6:15:6:16 | a3 | a3 |
3-
| test.cpp:9:20:9:22 | 99 | Assignment of an non-integer type to variable $@ which is a variable with an explicitly signed char type | test.cpp:9:15:9:16 | a5 | a5 |
4-
| test.cpp:12:21:12:23 | 99 | Assignment of an non-integer type to variable $@ which is a variable with an explicitly signed char type | test.cpp:12:16:12:17 | a7 | a7 |
1+
| test.cpp:106:7:106:8 | (unsigned char)... | Implicit conversion of plain char $@ to unsigned char. | test.cpp:106:7:106:8 | x3 | expression |
2+
| test.cpp:109:20:109:21 | (signed char)... | Implicit conversion of plain char $@ to signed char. | test.cpp:109:20:109:21 | x4 | expression |
3+
| test.cpp:119:21:119:22 | (uint8_t)... | Implicit conversion of plain char $@ to uint8_t. | test.cpp:119:21:119:22 | x7 | expression |
4+
| test.cpp:122:20:122:21 | (int8_t)... | Implicit conversion of plain char $@ to int8_t. | test.cpp:122:20:122:21 | x8 | expression |
5+
| test.cpp:132:17:132:18 | definition of c3 | Implicit conversion of plain char $@ to unsigned char from instantiating template 'C1<T, y>'. | test.cpp:5:12:5:12 | 120 | expression |
6+
| test.cpp:135:17:135:18 | definition of c4 | Implicit conversion of plain char $@ to signed char from instantiating template 'C2<T, y>'. | test.cpp:13:12:13:12 | 120 | expression |
7+
| test.cpp:145:15:145:16 | definition of c7 | Implicit conversion of plain char $@ to uint8_t from instantiating template 'C5<T, y>'. | test.cpp:22:12:22:12 | 1 | expression |
8+
| test.cpp:148:15:148:16 | definition of c8 | Implicit conversion of plain char $@ to int8_t from instantiating template 'C6<T, y>'. | test.cpp:30:12:30:12 | 1 | expression |
9+
| test.cpp:165:7:165:10 | (unsigned char)... | Implicit conversion of plain char $@ to unsigned char. | test.cpp:165:7:165:10 | * ... | expression |
10+
| test.cpp:170:7:170:10 | (signed char)... | Implicit conversion of plain char $@ to signed char. | test.cpp:170:7:170:10 | * ... | expression |
11+
| test.cpp:185:7:185:10 | (uint8_t)... | Implicit conversion of plain char $@ to uint8_t. | test.cpp:185:7:185:10 | * ... | expression |
12+
| test.cpp:190:7:190:10 | (int8_t)... | Implicit conversion of plain char $@ to int8_t. | test.cpp:190:7:190:10 | * ... | expression |
13+
| test.cpp:204:6:204:7 | (unsigned char)... | Implicit conversion of plain char $@ to unsigned char. | test.cpp:204:6:204:7 | a3 | expression |
14+
| test.cpp:207:6:207:7 | (signed char)... | Implicit conversion of plain char $@ to signed char. | test.cpp:207:6:207:7 | a4 | expression |
15+
| test.cpp:217:7:217:8 | (uint8_t)... | Implicit conversion of plain char $@ to uint8_t. | test.cpp:217:7:217:8 | a7 | expression |
16+
| test.cpp:220:7:220:8 | (int8_t)... | Implicit conversion of plain char $@ to int8_t. | test.cpp:220:7:220:8 | a8 | expression |
17+
| test.cpp:234:3:234:4 | call to f7 | Implicit conversion of plain char $@ to unsigned char from instantiating template 'f7'. | test.cpp:49:56:49:56 | x | expression |
18+
| test.cpp:238:3:238:4 | call to f8 | Implicit conversion of plain char $@ to signed char from instantiating template 'f8'. | test.cpp:50:54:50:54 | x | expression |
19+
| test.cpp:251:3:251:5 | call to f15 | Implicit conversion of plain char $@ to uint8_t from instantiating template 'f15'. | test.cpp:55:56:55:56 | x | expression |
20+
| test.cpp:255:3:255:5 | call to f16 | Implicit conversion of plain char $@ to int8_t from instantiating template 'f16'. | test.cpp:56:55:56:55 | x | expression |
21+
| test.cpp:272:12:272:14 | definition of c11 | Implicit conversion of plain char $@ to unsigned char from instantiating template 'C9<T>'. | test.cpp:60:15:60:15 | y | expression |
22+
| test.cpp:277:13:277:15 | definition of c12 | Implicit conversion of plain char $@ to signed char from instantiating template 'C10<T>'. | test.cpp:68:16:68:16 | y | expression |
23+
| test.cpp:292:13:292:15 | definition of c15 | Implicit conversion of plain char $@ to uint8_t from instantiating template 'C13<T>'. | test.cpp:77:16:77:16 | y | expression |
24+
| test.cpp:296:13:296:15 | definition of c16 | Implicit conversion of plain char $@ to int8_t from instantiating template 'C14<T>'. | test.cpp:85:16:85:16 | y | expression |

cpp/autosar/test/rules/M5-0-12/test.cpp

Lines changed: 30 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,6 @@ template <typename T, T y> class C2 {
1616
signed char x;
1717
};
1818

19-
template <typename T, T y> class C3 {
20-
public:
21-
C3() : x(y) {}
22-
23-
private:
24-
unsigned char x;
25-
};
26-
27-
template <typename T, T y> class C4 {
28-
public:
29-
C4() : x(y) {}
30-
31-
private:
32-
signed char x;
33-
};
34-
3519
/* Twin templates for std::uint8_t and std::int8_t */
3620
template <typename T, T y> class C5 {
3721
public:
@@ -49,22 +33,6 @@ template <typename T, T y> class C6 {
4933
std::int8_t x;
5034
};
5135

52-
template <typename T, T y> class C7 {
53-
public:
54-
C7() : x(y) {}
55-
56-
private:
57-
std::uint8_t x;
58-
};
59-
60-
template <typename T, T y> class C8 {
61-
public:
62-
C8() : x(y) {}
63-
64-
private:
65-
std::int8_t x;
66-
};
67-
6836
void f1(unsigned char x) {}
6937
void f2(signed char x) {}
7038
void f3(unsigned char x) {}
@@ -103,22 +71,6 @@ template <typename T> class C10 {
10371
signed char x;
10472
};
10573

106-
template <typename T> class C11 {
107-
public:
108-
C11(T y) : x(y) {}
109-
110-
private:
111-
signed char x;
112-
};
113-
114-
template <typename T> class C12 {
115-
public:
116-
C12(T y) : x(y) {}
117-
118-
private:
119-
signed char x;
120-
};
121-
12274
/* Twin template classes for std::uint8_t and std::int8_t */
12375
template <typename T> class C13 {
12476
public:
@@ -136,22 +88,6 @@ template <typename T> class C14 {
13688
std::int8_t x;
13789
};
13890

139-
template <typename T> class C15 {
140-
public:
141-
C15(T y) : x(y) {}
142-
143-
private:
144-
std::int8_t x;
145-
};
146-
147-
template <typename T> class C16 {
148-
public:
149-
C16(T y) : x(y) {}
150-
151-
private:
152-
std::int8_t x;
153-
};
154-
15591
int main() {
15692

15793
/* ========== 1. Assigning a char to another char ========== */
@@ -166,15 +102,15 @@ int main() {
166102
signed char y2 = x2; // COMPLIANT: signed char assigned to a signed char
167103

168104
char x3 = 'x';
169-
unsigned char y3 = x3; // NON-COMPLIANT: plain char assigned to a unsigned char
105+
unsigned char y3 =
106+
x3; // NON-COMPLIANT: plain char assigned to a unsigned char
170107

171108
char x4 = 'x';
172109
signed char y4 = x4; // NON-COMPLIANT: plain char assigned to a signed char
173110

174111
/* Twin cases with std::uint8_t and std::int8_t */
175112
std::uint8_t x5 = 1;
176-
std::uint8_t y5 =
177-
x5; // COMPLIANT: std::uint8_t assigned to a std::uint8_t
113+
std::uint8_t y5 = x5; // COMPLIANT: std::uint8_t assigned to a std::uint8_t
178114

179115
std::int8_t x6 = 1;
180116
std::int8_t y6 = x6; // COMPLIANT: std::int8_t assigned to a std::int8_t
@@ -193,24 +129,24 @@ int main() {
193129
C2<signed char, 1> c2; // COMPLIANT: signed char arg passed to a signed char
194130
// member through a template
195131

196-
C3<char, 'x'> c3; // NON-COMPLIANT: plain char arg passed to a unsigned char
132+
C1<char, 'x'> c3; // NON-COMPLIANT: plain char arg passed to a unsigned char
197133
// member through a template
198134

199-
C4<char, 'x'> c4; // NON-COMPLIANT: plain char arg passed to a signed char
135+
C2<char, 'x'> c4; // NON-COMPLIANT: plain char arg passed to a signed char
200136
// member through a template
201137

202138
/* Twin cases with std::uint8_t and std::int8_t */
203-
C5<std::uint8_t, 1> c5; // COMPLIANT: std::uint8_t arg passed to a std::uint8_t
204-
// member through a template
139+
C5<std::uint8_t, 1> c5; // COMPLIANT: std::uint8_t arg passed to a
140+
// std::uint8_t member through a template
205141

206142
C6<std::int8_t, 1> c6; // COMPLIANT: std::int8_t arg passed to a std::int8_t
207-
// member through a template
143+
// member through a template
208144

209-
C7<char, 'x'> c7; // NON-COMPLIANT: plain char arg passed to a std::uint8_t
210-
// member through a template
145+
C5<char, 1> c7; // NON-COMPLIANT: plain char arg passed to a
146+
// std::uint8_t member through a template
211147

212-
C8<char, 'x'> c8; // NON-COMPLIANT: plain char arg passed to a std::int8_t
213-
// member through a template
148+
C6<char, 1> c8; // NON-COMPLIANT: plain char arg passed to a std::int8_t
149+
// member through a template
214150

215151
/* ========== 1-3. Assigning a char to a char through a pointer ========== */
216152

@@ -299,8 +235,8 @@ int main() {
299235
// through a template
300236

301237
char a12 = 'a';
302-
f8(a12); // NON-COMPLIANT: plain char arg passed to a signed char parameter through
303-
// a template
238+
f8(a12); // NON-COMPLIANT: plain char arg passed to a signed char parameter
239+
// through a template
304240

305241
/* Twin cases with std::uint8_t and std::int8_t */
306242
std::uint8_t a13 = 1;
@@ -316,8 +252,8 @@ int main() {
316252
// through a template
317253

318254
char a16 = 'a';
319-
f16(a16); // NON-COMPLIANT: plain char arg passed to a std::int8_t parameter through
320-
// a template
255+
f16(a16); // NON-COMPLIANT: plain char arg passed to a std::int8_t parameter
256+
// through a template
321257

322258
/* ========== 2-3. Passing a char argument to a char parameter through a
323259
* template ========== */
@@ -328,16 +264,18 @@ int main() {
328264
// of a constructor through a template
329265

330266
signed char a18 = 1;
331-
C10<signed char> c10(a18); // COMPLIANT: signed char arg passed to an signed
332-
// char parameter of a constructor through a template
267+
C10<signed char> c10(
268+
a18); // COMPLIANT: signed char arg passed to an signed
269+
// char parameter of a constructor through a template
333270

334271
char a19 = 'a';
335-
C11<char> c11(a19); // NON-COMPLIANT: plain char arg passed to a signed char
336-
// parameter of a constructor through a template
272+
C9<char> c11(
273+
a19); // NON-COMPLIANT: plain char arg passed to a unsigned signed char
274+
// parameter of a constructor through a template
337275

338276
char a20 = 'a';
339-
C12<char> c12(a20); // NON-COMPLIANT: plain char arg passed to an signed char
340-
// parameter of a constructor through a template
277+
C10<char> c12(a20); // NON-COMPLIANT: plain char arg passed to an signed char
278+
// parameter of a constructor through a template
341279

342280
/* Twin cases with std::uint8_t and std::int8_t */
343281
std::uint8_t a21 = 1;
@@ -346,14 +284,15 @@ int main() {
346284
// of a constructor through a template
347285

348286
std::int8_t a22 = 1;
349-
C14<std::int8_t> c14(a22); // COMPLIANT: std::int8_t arg passed to a std::int8_t
350-
// parameter of a constructor through a template
287+
C14<std::int8_t> c14(
288+
a22); // COMPLIANT: std::int8_t arg passed to a std::int8_t
289+
// parameter of a constructor through a template
351290

352291
char a23 = 'a';
353-
C15<char> c15(a23); // NON-COMPLIANT: plain char arg passed to a std::int8_t
292+
C13<char> c15(a23); // NON-COMPLIANT: plain char arg passed to a std::uint8_t
354293
// parameter of a constructor through a template
355294

356295
char a24 = 'a';
357-
C16<char> c16(a24); // NON-COMPLIANT: plain char arg passed to a std::int8_t
296+
C14<char> c16(a24); // NON-COMPLIANT: plain char arg passed to a std::int8_t
358297
// parameter of a constructor through a template
359-
}
298+
}

0 commit comments

Comments
 (0)