[clang] [clang] fix crash in friend definition (PR #186398)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 15 13:52:10 PDT 2026


================
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
+
+
+template<class>
+struct D;
+
+template<class T>
+void foo(D<T>);
+
+template<class T>
+struct D {
+  friend void ::foo(D) {} // expected-error {{friend function definition cannot be qualified with '::'}}
+};
+
+int main() {
+  foo(D<int>{});
+}
----------------
mizvekov wrote:

another nit, but please include a trailing new line on all files, unless the test requires otherwise.

Most non-windows editors will automatically add this, so it creates future diff noise if you don't.

So I'd recommend to try to set up your editor to enforce this.

I haven't checked if there is this problem in this patch, but another common problem in this department is trailing whitespace before new lines, please make sure your changes don't contain them, unless required by tests.

Please make sure your editor supports enforcing this stuff.

https://github.com/llvm/llvm-project/pull/186398


More information about the cfe-commits mailing list