mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
These tests exercise the problematic cases where a variable can appear to have multiple types because of how we fail to account for qualified names when comparing type names.
33 lines
842 B
C++
33 lines
842 B
C++
// This is a small C++ addition to the compatible_c test.
|
|
// Note that we decided to follow the C compatibility rules for merging types,
|
|
// not the C++ ODR rules.
|
|
|
|
// Definitions of Apple are exactly the same in b1.c and b2.c
|
|
class AppleCompatible {
|
|
int apple_x;
|
|
};
|
|
|
|
// Definitions of Banana are compatible but this copy uses int for the field type
|
|
class BananaCompatible {
|
|
int banana_x;
|
|
};
|
|
|
|
// Definitions of Cherry are not compatible - the field types differ
|
|
class Cherry {
|
|
int cherry_x;
|
|
};
|
|
|
|
// This shows that we currently only consider member variables, and ignore
|
|
// functions when deciding on class compatibility. In this file there is a
|
|
// member function called `foo`, in b2.cpp there is one called `bar`.
|
|
class Damson {
|
|
int damson_x;
|
|
void foo();
|
|
};
|
|
|
|
namespace unrelated {
|
|
class AppleCompatible {
|
|
long apple_x;
|
|
};
|
|
}
|