Skip to content

Commit e5b4abb

Browse files
committed
A0-1-6: Add failing test case for alias templates
An alias template is an alias (e.g. a using statement) which is part of a template, and is currently considered to be unused even if the template is instantiated.
1 parent fde0df0 commit e5b4abb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cpp/autosar/test/rules/A0-1-6/UnusedTypeDeclarations.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
| test.cpp:10:11:10:11 | D | Type declaration D is not used. |
44
| test.cpp:74:11:74:11 | R | Type declaration R is not used. |
55
| test.cpp:87:12:87:12 | struct <unnamed> | Type declaration struct <unnamed> is not used. |
6+
| test.cpp:104:26:104:26 | Y<int> | Type declaration Y<int> is not used. |
7+
| test.cpp:107:29:107:29 | Z | Type declaration Z is not used. |
8+
| test.cpp:108:29:108:30 | AA | Type declaration AA is not used. |

cpp/autosar/test/rules/A0-1-6/test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,14 @@ void test_nested_struct() {
9999

100100
template <class T> class X { // COMPLIANT - template class never instantiated
101101
using custom_type = E<T>; // COMPLIANT - template class never instantiated
102-
};
102+
};
103+
104+
template <class T> class Y {}; // COMPLIANT[FALSE_POSITIVE] - used in the test case below
105+
106+
// Alias templates
107+
template <typename T> using Z = Y<T>; // COMPLIANT[FALSE_POSITIVE] - used below
108+
template <typename T> using AA = Y<T>; // NON_COMPLIANT - never instantiated
109+
110+
void test_alias_template() {
111+
Z<int> v;
112+
}

0 commit comments

Comments
 (0)