declarations. We can't expect to find them in the canonical definition
of the class, because that's not where they live.
This means we no longer reject real ODR violations with friend declarations,
but we weren't consistently doing so anyway.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216369
91177308-0d34-0410-b5e6-
96231b3b80d8
//
// FIXME: We should do something similar if we merge two definitions of the
// same template specialization into the same CXXRecordDecl.
- if (Reader.MergedDeclContexts.count(D->getLexicalDeclContext()))
+ auto MergedDCIt = Reader.MergedDeclContexts.find(D->getLexicalDeclContext());
+ if (MergedDCIt != Reader.MergedDeclContexts.end() &&
+ MergedDCIt->second == D->getDeclContext())
Reader.PendingOdrMergeChecks.push_back(D);
return FindExistingResult(Reader, D, /*Existing=*/nullptr);
int n;
} x1;
+template<typename T>
+struct F {
+ int n;
+ friend bool operator==(const F &a, const F &b) { return a.n == b.n; }
+};
+
int f() {
return y1.n + e1 + y1.f + x1.n;
}
} y2;
enum E { e2 };
+template<typename T>
+struct F {
+ int n;
+ friend bool operator==(const F &a, const F &b) { return a.n == b.n; }
+};
+
int g() {
- return y2.m + e2 + y2.f;
+ return y2.m + e2 + y2.f + (F<int>{0} == F<int>{1});
}
};
@import a;
+
+bool b = F<int>{0} == F<int>{1};
+
@import b;
// Trigger the declarations from a and b to be imported.