[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 21 07:00:27 PST 2024
================
@@ -185,3 +185,46 @@ template<typename T> struct S {
friend void X::f(T::type);
};
}
+
+namespace GH113324 {
+template <typename = int> struct S1 {
+ friend void f1(S1, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
+ friend void f2(S1 a, S1 = decltype(a){}); // expected-error {{friend declaration specifying a default argument must be a definition}}
+};
+
+template <class T> using alias = int;
+template <typename T> struct S2 {
+ // FIXME: We miss diagnosing the default argument instantiation failure
+ // (forming reference to void)
+ friend void f3(S2, int a = alias<T &>(1)); // expected-error {{friend declaration specifying a default argument must be a definition}}
+};
+
+struct S3 {
+ friend void f4(S3, int = 42) { }
+};
----------------
a-tarasyuk wrote:
@zyn0217 I've moved the tests that caused failures to `CodeGenCXX/default-arguments.cpp`
https://github.com/llvm/llvm-project/pull/115487
More information about the cfe-commits
mailing list