diff --git a/cpp/ql/test/library-tests/templates/switch/test.cpp b/cpp/ql/test/library-tests/templates/switch/test.cpp new file mode 100644 index 00000000000..4da12e52f92 --- /dev/null +++ b/cpp/ql/test/library-tests/templates/switch/test.cpp @@ -0,0 +1,23 @@ + +// A regression test for a bug extracting the enum constants in a template +// class. + +template +class C { + enum { foo, bar, baz } delim; + void f(); +}; + +template +void C::f() { + switch (delim) { + case bar: + break; + case baz: + break; + case foo: + break; + } +} + +template class C; diff --git a/cpp/ql/test/library-tests/templates/switch/test.expected b/cpp/ql/test/library-tests/templates/switch/test.expected new file mode 100644 index 00000000000..b4124494ffe --- /dev/null +++ b/cpp/ql/test/library-tests/templates/switch/test.expected @@ -0,0 +1,2 @@ +| test.cpp:13:3:20:3 | switch (...) ... | 3 | +| test.cpp:13:3:20:3 | switch (...) ... | 3 | diff --git a/cpp/ql/test/library-tests/templates/switch/test.ql b/cpp/ql/test/library-tests/templates/switch/test.ql new file mode 100644 index 00000000000..f9de6d417e5 --- /dev/null +++ b/cpp/ql/test/library-tests/templates/switch/test.ql @@ -0,0 +1,4 @@ +import cpp + +from SwitchStmt ss +select ss, count(SwitchCase sc | ss = sc.getSwitchStmt())