[clang] [clang] Allow delayed function instantiation at TU end if initial instantiation fails (PR #117167)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 25 10:28:23 PST 2024


================
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// expected-no-diagnostics
+
+template <typename T>
+auto foo(T const& arg) -> T;
+
+template <typename Fp, typename Vis>
+auto dispatch(Fp fp, Vis vis) {
+  return fp(vis);
+}
+
+auto baz(int v) {
+  auto callable = []<typename Arg>(Arg const& arg) -> int {
+    return foo(arg);
+  };
+  return dispatch(callable, v);
+}
+
+template <typename T>
+auto foo(T const& arg) -> T {
+  return arg;
+}
+
+int main() {
+  return baz(5);
+}
----------------
erichkeane wrote:

newline needed at the end of test.  

Also, would like to see a codegen test that shows that we are properly generating the right instantiations.

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


More information about the cfe-commits mailing list