[clang] [clang] Implement instantiation context note for checking template parameters (PR #126088)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 20 10:59:17 PST 2025


================
@@ -5294,10 +5294,14 @@ def err_template_missing_args : Error<
   "%select{class template|function template|variable template|alias template|"
   "template template parameter|concept|template}0 %1 requires template "
   "arguments">;
-def err_template_arg_list_different_arity : Error<
-  "%select{too few|too many}0 template arguments for "
+def err_template_param_missing_arg : Error<
+  "missing template argument for template parameter">;
+def err_template_template_param_missing_param : Error<
+  "missing template parameter to bind to template template parameter">;
----------------
mizvekov wrote:

For comparison, before this patch, the diagnostic for this example is bad:
```
test.cc:3:19: error: too few template arguments for class template 'A'
    3 | template struct B<A>;
      |                   ^
test.cc:3:19: note: template template argument has different template parameters than its corresponding template template parameter
test.cc:2:37: note: previous template template parameter is here
    2 | template <template <class T3> class TT> struct B;
      |           ~~~~~~~~~~~~~~~~~~~       ^
test.cc:1:38: note: template is declared here
    1 | template <class T1, class T2> struct A;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        ^
```

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


More information about the cfe-commits mailing list