Skip to content

Commit c33e0fd

Browse files
jketemaCopilot
andcommitted
Simplify empty parameter pack regression
Reduce the regression case to a single abbreviated template function called with empty and non-empty packs while retaining the expected restrictionPack alert. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8321729 commit c33e0fd

2 files changed

Lines changed: 4 additions & 21 deletions

File tree

‎cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables/UnusedStaticVariables.expected‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
| test.cpp:8:12:8:21 | staticVar6 | Static variable staticVar6 is never read. |
33
| test.cpp:10:11:10:19 | constVar8 | Static variable constVar8 is never read. |
44
| test.cpp:12:12:12:22 | staticVar10 | Static variable staticVar10 is never read. |
5-
| test.cpp:68:58:68:72 | restrictionPack | Static variable restrictionPack is never read. |
5+
| test.cpp:53:25:53:39 | restrictionPack | Static variable restrictionPack is never read. |

‎cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables/test.cpp‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,12 @@ struct WithDestructor
5050
static WithConstructor constructed; // GOOD (constructor has a side effect)
5151
static WithDestructor destructed; // GOOD (destructor has a side effect)
5252

53-
template <typename From, typename To>
54-
concept ConvertibleTo = requires(From value) { static_cast<To>(value); };
55-
56-
struct Store
57-
{
58-
using LinkAddressType = unsigned;
59-
struct LinkType
60-
{
61-
LinkAddressType restriction;
62-
};
63-
};
64-
65-
template <typename TStore>
66-
static auto All(
67-
const TStore&,
68-
ConvertibleTo<typename TStore::LinkAddressType> auto... restrictionPack) // $ SPURIOUS: Alert
53+
static auto All(auto... restrictionPack) // $ SPURIOUS: Alert
6954
{
70-
typename TStore::LinkType restriction{static_cast<typename TStore::LinkAddressType>(restrictionPack)...};
71-
return restriction;
55+
return (0U + ... + static_cast<unsigned>(restrictionPack));
7256
}
7357

7458
int main()
7559
{
76-
Store store;
77-
return All(store).restriction + All(store, 2U).restriction;
60+
return All() + All(2U);
7861
}

0 commit comments

Comments
 (0)