/// IndirectFieldDecl - An instance of this class is created to represent a
/// field injected from an anonymous union/struct into the parent scope.
/// IndirectFieldDecl are always implicit.
-class IndirectFieldDecl : public ValueDecl {
+class IndirectFieldDecl : public ValueDecl,
+ public Mergeable<IndirectFieldDecl> {
void anchor() override;
NamedDecl **Chaining;
unsigned ChainingSize;
return dyn_cast<VarDecl>(*chain_begin());
}
+ IndirectFieldDecl *getCanonicalDecl() override { return getFirstDecl(); }
+ const IndirectFieldDecl *getCanonicalDecl() const { return getFirstDecl(); }
+
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == IndirectField; }
for (unsigned I = 0; I != FD->ChainingSize; ++I)
FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx);
+
+ mergeMergeable(FD);
}
ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
return X->getASTContext().hasSameType(FDX->getType(), FDY->getType());
}
+ // Indirect fields with the same target field match.
+ if (auto *IFDX = dyn_cast<IndirectFieldDecl>(X)) {
+ auto *IFDY = cast<IndirectFieldDecl>(Y);
+ return IFDX->getAnonField()->getCanonicalDecl() ==
+ IFDY->getAnonField()->getCanonicalDecl();
+ }
+
// Enumerators with the same name match.
if (isa<EnumConstantDecl>(X))
// FIXME: Also check the value is odr-equivalent.
typedef X X;
using RedeclDifferentDeclKind::X;
}
+
+namespace Anon {
+ struct X {
+ union {
+ int n;
+ };
+ };
+}
J<> post_j2;
FriendDefArg::Y<int> friend_def_arg;
FriendDefArg::D<> friend_def_arg_d;
+int post_anon_x_n = Anon::X().n;
MergeFunctionTemplateSpecializations::X<int>::Q<char> xiqc;