The search for the complete class definition can also produce entries which are not of the expected type. This can happen for instance when there is a function with the same name as the class we're looking up (which means that the class needs to be disambiguated with the struct/class tag in most contexts). Previously we were just picking the first Decl that the lookup returned, which later caused crashes or assertion failures if it was not of the correct type. This patch changes that to search for an entry of the correct type. Differential Revision: https://reviews.llvm.org/D85904
33 lines
664 B
C++
33 lines
664 B
C++
#include "onetwo.h"
|
|
|
|
struct InheritsFromOne : One {
|
|
int member = 47;
|
|
} inherits_from_one;
|
|
|
|
struct InheritsFromTwo : Two {
|
|
int member = 47;
|
|
} inherits_from_two;
|
|
|
|
struct OneAsMember {
|
|
member::One one;
|
|
int member = 47;
|
|
} one_as_member;
|
|
|
|
struct TwoAsMember {
|
|
member::Two two;
|
|
int member = 47;
|
|
} two_as_member;
|
|
|
|
array::One array_of_one[3];
|
|
array::Two array_of_two[3];
|
|
|
|
result::One get_one() { return result::One(124); }
|
|
result::Two get_two() { return result::Two(224); }
|
|
|
|
// Note that there's also a function with the name func_shadow::One.
|
|
struct ShadowedOne : func_shadow::One {
|
|
int member = 47;
|
|
} shadowed_one;
|
|
|
|
int main() { return get_one().member; }
|