[clang] [clang] Inject IndirectFieldDecl even if name conflicts. (PR #153140)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 14 06:19:47 PDT 2025
================
@@ -5494,55 +5494,62 @@ InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner,
RecordDecl *AnonRecord, AccessSpecifier AS,
StorageClass SC,
SmallVectorImpl<NamedDecl *> &Chaining) {
+
bool Invalid = false;
// Look every FieldDecl and IndirectFieldDecl with a name.
for (auto *D : AnonRecord->decls()) {
if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
cast<NamedDecl>(D)->getDeclName()) {
ValueDecl *VD = cast<ValueDecl>(D);
- if (CheckAnonMemberRedeclaration(SemaRef, S, Owner, VD->getDeclName(),
- VD->getLocation(), AnonRecord->isUnion(),
- SC)) {
- // C++ [class.union]p2:
- // The names of the members of an anonymous union shall be
- // distinct from the names of any other entity in the
- // scope in which the anonymous union is declared.
+ // C++ [class.union]p2:
+ // The names of the members of an anonymous union shall be
+ // distinct from the names of any other entity in the
+ // scope in which the anonymous union is declared.
+
+ const bool FieldInvalid = CheckAnonMemberRedeclaration(
----------------
erichkeane wrote:
```suggestion
bool FieldInvalid = CheckAnonMemberRedeclaration(
```
https://github.com/llvm/llvm-project/pull/153140
More information about the cfe-commits
mailing list