Files
codeql/cpp/ql/test/library-tests/structs/compatible_cpp/b1.cpp
Jonas Jensen b633ee1bc4 C++: Add more tests of resolveClass
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.
2018-09-17 15:48:02 +02:00

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;
};
}