[clang] [clang] Distinguish unresolved templates in UnresolvedLookupExpr (PR #89019)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 18 10:17:33 PDT 2024


================
@@ -186,3 +186,74 @@ class E {
 #endif
 template<typename T> using D = int; // expected-note {{declared here}} 
 E<D> ed; // expected-note {{instantiation of}}
+
+namespace non_functions {
+
+#if __cplusplus >= 201103L
+namespace PR88832 {
+template <typename T> struct O {
+  static const T v = 0;
+};
+
+struct P {
+  template <typename T> using I = typename O<T>::v; // #TypeAlias
+};
+
+struct Q {
+  template <typename T> int foo() {
+    return T::template I<int>; // expected-error {{'P::I' is expected to be a non-type template, but instantiated to a type alias template}}
+    // expected-note@#TypeAlias {{type alias template declared here}}
----------------
erichkeane wrote:

Yeah, it doesn't make sense for errors/warnings: Those should be "right next" to the thing that caused them (so I prefer the  +/- Numeral for those).  However, with Notes, it makes a TON of sense, and IMO, should nearly ALWAYS be used.

Without them, we end up getting 'errors' and their notes are completely unintelligible, because they are spread out around the file and in no reasonable order.  It makes it so figuring out "this is an error only because of these instantiations" is impossible.

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


More information about the cfe-commits mailing list