Skip to content

Commit c8df15f

Browse files
committed
Add test case for uninstantiated template
1 parent 2029a18 commit c8df15f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

cpp/autosar/test/rules/M9-3-3/test.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,29 @@ class Z22 : Z1 {
161161
void f2() final {} // COMPLIANT
162162
void f3() { this->a = 100; } // COMPLIANT
163163
};
164+
165+
template <class T> class Array {
166+
public:
167+
T &back();
168+
169+
private:
170+
T data[128];
171+
unsigned int size;
172+
};
173+
174+
template <class T, template <class...> class U> class Stack {
175+
public:
176+
T &Top() {
177+
return this->data.back();
178+
} // Likely NON_COMPLIANT, but cannot be determined until instantiation.
179+
private:
180+
U<T> data;
181+
};
182+
183+
using IntVectorStack = Stack<int, Array>;
184+
185+
void test_template() {
186+
IntVectorStack s;
187+
188+
int i = s.Top();
189+
}

0 commit comments

Comments
 (0)