From ca898d4be04ec3d899637e2e9e1627c5f5fd5541 Mon Sep 17 00:00:00 2001 From: Matthew Gretton-Dann Date: Tue, 22 Oct 2019 10:54:14 +0100 Subject: [PATCH] C++: Further nontype template testcases. --- .../nontype_instantiations/general/test.cpp | 19 +++++++++++++++++++ .../general/test.expected | 10 ++++++++++ .../nontype_instantiations/general/test.ql | 4 ++++ 3 files changed, 33 insertions(+) create mode 100644 cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.cpp create mode 100644 cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.expected create mode 100644 cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.ql diff --git a/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.cpp b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.cpp new file mode 100644 index 00000000000..1baabe3ca30 --- /dev/null +++ b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.cpp @@ -0,0 +1,19 @@ +// semmle-extractor-options: --edg --trap_container=folder --edg --trap-compression=none +template +struct C { }; + +static const int one1 = 1, one2 = 1; +C c = C(); +C e; + +template +struct D { }; + +D a; +D b; + +template +struct E { }; + +E z; + diff --git a/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.expected b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.expected new file mode 100644 index 00000000000..70dfdbc3edf --- /dev/null +++ b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.expected @@ -0,0 +1,10 @@ +| test.cpp:3:8:3:8 | C<1> | file://:0:0:0:0 | int | test.cpp:5:25:5:25 | 1 | +| test.cpp:3:8:3:8 | C<2> | file://:0:0:0:0 | int | file://:0:0:0:0 | 2 | +| test.cpp:3:8:3:8 | C | file://:0:0:0:0 | int | file://:0:0:0:0 | x | +| test.cpp:10:8:10:8 | D | test.cpp:9:19:9:19 | T | file://:0:0:0:0 | X | +| test.cpp:10:8:10:8 | D | file://:0:0:0:0 | int | test.cpp:12:8:12:8 | 2 | +| test.cpp:10:8:10:8 | D | file://:0:0:0:0 | long | file://:0:0:0:0 | 2 | +| test.cpp:16:8:16:8 | E | file://:0:0:0:0 | T * | file://:0:0:0:0 | X | +| test.cpp:16:8:16:8 | E | test.cpp:15:19:15:19 | T | file://:0:0:0:0 | X | +| test.cpp:16:8:16:8 | E | file://:0:0:0:0 | int | file://:0:0:0:0 | 0 | +| test.cpp:16:8:16:8 | E | file://:0:0:0:0 | int * | file://:0:0:0:0 | 0 | diff --git a/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.ql b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.ql new file mode 100644 index 00000000000..8915d6523b6 --- /dev/null +++ b/cpp/ql/test/library-tests/templates/nontype_instantiations/general/test.ql @@ -0,0 +1,4 @@ +import cpp + +from Declaration d +select d, d.getATemplateArgument(), d.getATemplateArgumentValue()