Skip to content

Commit 79fc3a9

Browse files
committed
M3-2-1: Add failing tests cases for variables templates
Variable templates cause multiple variables to be generated, causing false positives for M3-2-1.
1 parent cc527b1 commit 79fc3a9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cpp/autosar/test/rules/M3-2-1/DeclarationsOfAnObjectShallHaveCompatibleTypes.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:7:5:7:6 | definition of a7 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:7:5:7:6 | definition of a7 | a7 | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:19:11:19:12 | declaration of a7 | a7 |
55
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:14:5:14:6 | definition of a2 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:14:5:14:6 | definition of a2 | a2 | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:23:13:23:14 | declaration of a2 | a2 |
66
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:19:5:19:7 | definition of a11 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:19:5:19:7 | definition of a11 | a11 | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:28:12:28:14 | declaration of a11 | a11 |
7+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one |
8+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one |
9+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | number_one |
10+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | number_one |
11+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one |
12+
| test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:43:22:43 | definition of number_one | number_one | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:22:32:22:32 | definition of number_one | number_one |
713
| test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:11:12:11:13 | declaration of a4 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:11:12:11:13 | declaration of a4 | a4 | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:4:6:4:7 | definition of a4 | a4 |
814
| test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:13:13:13:14 | declaration of a5 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:13:13:13:14 | declaration of a5 | a5 | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:5:5:5:6 | definition of a5 | a5 |
915
| test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:17:1:17:3 | declaration of a6 | The object $@ is not compatible with re-declaration $@ | test_declarations_of_an_object_shall_have_compatible_types_unit2.cpp:17:1:17:3 | declaration of a6 | a6 | test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp:6:6:6:7 | definition of a6 | a6 |

cpp/autosar/test/rules/M3-2-1/test_declarations_of_an_object_shall_have_compatible_types_unit1.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ int a2; // NON_COMPLIANT
1717
int a9[100]; // COMPLIANT
1818
int a10[100]; // COMPLIANT
1919
int a11[100]; // NON_COMPLIANT - different sizes
20+
21+
// Variable templates can cause false positives
22+
template <class T> constexpr T number_one = T(1); // COMPLIANT
23+
24+
int test() { return number_one<int>; }
25+
26+
long test2() { return number_one<long>; }

0 commit comments

Comments
 (0)