[clang] [clang] Clang should detect illegal copy constructor with template class as its parameter (PR #81251)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 22 12:54:08 PST 2024


================
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template < class T, class V > struct A
+{
+    A ();
+    A (A &);
+    A (A < V,T >);
+    // expected-error at -1 {{copy constructor must pass its first argument by reference}}
+};
+
+void f ()
+{
+    A <int, int> (A < int, int >());
+    // expected-note at -1 {{in instantiation of template class 'A<int, int>' requested here}}
----------------
shafik wrote:

We should also test the case where the parameters are not the same, since that should not fail.

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


More information about the cfe-commits mailing list