From 0978cc2d460f94b3cb0087f996d77b57dd24ab35 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 17 Aug 2022 10:01:49 +0200 Subject: [PATCH] Add tests for #10559, #10603 (#4367) --- test/testclass.cpp | 8 ++++++++ test/testtokenize.cpp | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index 6891f1b21..a44b64e3e 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -7553,6 +7553,14 @@ private: " virtual void VirtualMethod() = 0;\n" "};"); ASSERT_EQUALS("", errout.str()); + + // #10559 + checkVirtualFunctionCall("struct S {\n" + " S(const int x) : m(std::bind(&S::f, this, x, 42)) {}\n" + " virtual int f(const int x, const int y) = 0;\n" + " std::function m;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void pureVirtualFunctionCallOtherClass() { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 42bc016d4..e74ab390b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -424,6 +424,7 @@ private: TEST_CASE(noCrash2); TEST_CASE(noCrash3); TEST_CASE(noCrash4); + TEST_CASE(noCrash5); // #10603 // --check-config TEST_CASE(checkConfiguration); @@ -7094,6 +7095,12 @@ private: "}\n")); } + void noCrash5() // #10603 + { + ASSERT_NO_THROW(tokenizeAndStringify("class B { using shared_ptr = std::shared_ptr; };\n" + "class D : public B { void f(const std::shared_ptr& ptr) {} };\n")); + } + void checkConfig(const char code[]) { errout.str("");