From bb2ba53bf5dfc0d4da067447fb4b31c6debfc6ce Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 22 Sep 2022 19:41:29 +0200 Subject: [PATCH] Add tests for #6504, #11177 (#4494) * Add test for #11177 * Add test for #6504 --- test/testconstructors.cpp | 8 ++++++++ test/testincompletestatement.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 41c475a97..7b0af6b78 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -4332,6 +4332,14 @@ private: "template\n" "A>::A() : m_value(false) {}"); ASSERT_EQUALS("", errout.str()); + + check("template struct S;\n" // #11177 + "template <> struct S final {\n" + " explicit S(int& i);\n" + " int& m;\n" + "};\n" + "S::S(int& i) : m(i) {}\n"); + ASSERT_EQUALS("", errout.str()); } void unknownTemplateType() { diff --git a/test/testincompletestatement.cpp b/test/testincompletestatement.cpp index c124c49f4..41f783ad4 100644 --- a/test/testincompletestatement.cpp +++ b/test/testincompletestatement.cpp @@ -696,6 +696,12 @@ private: ASSERT_EQUALS("[test.cpp:2]: (warning) Redundant code: Found a statement that begins with NULL constant.\n" "[test.cpp:3]: (warning) Redundant code: Found a statement that begins with NULL constant.\n", errout.str()); + + check("struct S { int i; };\n" // #6504 + "void f(S* s) {\n" + " (*s).i;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant code: Found unused member access.\n", errout.str()); } void vardecl() {