mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 00:20:14 +00:00
[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with multiple bases.
Summary: Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths even though a qualified name is used. For example: ``` class B { protected: int i; union { int j; }; }; class X : public B { }; class Y : public B { }; class Z : public X, public Y { int a() { return X::i; } // works int b() { return X::j; } // fails }; ``` Reviewers: rsmith, aaron.ballman, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45411 llvm-svn: 329521
This commit is contained in:
parent
80440deed4
commit
4b8c991870
@ -848,7 +848,7 @@ Sema::BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS,
|
||||
// Build the first member access in the chain with full information.
|
||||
result =
|
||||
BuildFieldReferenceExpr(result, baseObjectIsPointer, SourceLocation(),
|
||||
EmptySS, field, foundDecl, memberNameInfo)
|
||||
SS, field, foundDecl, memberNameInfo)
|
||||
.get();
|
||||
if (!result)
|
||||
return ExprError();
|
||||
|
@ -2239,7 +2239,6 @@ public:
|
||||
// We have a reference to an unnamed field. This is always the
|
||||
// base of an anonymous struct/union member access, i.e. the
|
||||
// field is always of record type.
|
||||
assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
|
||||
assert(Member->getType()->isRecordType() &&
|
||||
"unnamed member not of record type?");
|
||||
|
||||
|
21
clang/test/SemaCXX/PR35832.cpp
Normal file
21
clang/test/SemaCXX/PR35832.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
// expected-no-diagnostics
|
||||
|
||||
class B {
|
||||
public:
|
||||
int i;
|
||||
struct { struct { union { int j; }; }; };
|
||||
union { int k; };
|
||||
};
|
||||
|
||||
class X : public B { };
|
||||
class Y : public B { };
|
||||
|
||||
class Z : public X, public Y {
|
||||
public:
|
||||
int a() { return X::i; }
|
||||
int b() { return X::j; }
|
||||
int c() { return X::k; }
|
||||
int d() { return this->X::j; }
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user