mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Merge pull request #1615 from geoffw0/exprowninit
CPP: Test + workaround for UseInOwnInitializer.ql
This commit is contained in:
@@ -32,6 +32,7 @@ where va.initializesItself(v, init)
|
||||
exists (CrementOperation crement | crement.getAnOperand() = va)
|
||||
)
|
||||
and not va.isUnevaluated()
|
||||
and not v.isConst()
|
||||
and not (
|
||||
va.getParent() = init and
|
||||
exists(MacroInvocation mi |
|
||||
|
||||
@@ -66,3 +66,26 @@ void test11() {
|
||||
void test12() {
|
||||
self_initialize(int, x); // GOOD (statement is from a macro)
|
||||
}
|
||||
|
||||
namespace ns1
|
||||
{
|
||||
const int v2 = 1;
|
||||
const int v4 = 1;
|
||||
const int v6 = 1;
|
||||
};
|
||||
|
||||
namespace ns2
|
||||
{
|
||||
const int v1 = ns1::v2; // GOOD
|
||||
const int v2 = ns1::v2; // GOOD [produces INVALID_KEY trap warning]
|
||||
};
|
||||
|
||||
const int v3 = ns1::v4; // GOOD
|
||||
const int v4 = ns1::v4; // GOOD
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
const int v5 = ns1::v6 + 1; // GOOD
|
||||
const int v6 = ns1::v6 + 1; // GOOD [produces INVALID_KEY trap warning]
|
||||
const int v7 = ns3::v7; // BAD [NOT DETECTED]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user