[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 18:00:35 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) { }
+};
----------------
zyn0217 wrote:
Does the regression fail within `fsyntax-only` mode previously? I remembered those reports were related to codegen parts, so you might need to move the case to e.g. `test/CodeGenCXX/default-arguments.cpp`.
https://github.com/llvm/llvm-project/pull/115487
More information about the cfe-commits
mailing list